Added back rectangle tool

This commit is contained in:
unsettledgames
2021-10-31 12:49:38 +01:00
parent b2fef6154d
commit 6b739f0ea7
8 changed files with 161 additions and 187 deletions

View File

@ -1,6 +1,7 @@
const ToolManager = (() => {
brush = new BrushTool("brush", {type: 'html'}, switchTool);
eraser = new EraserTool("eraser", {type: 'html'}, switchTool);
rectangle = new RectangleTool("rectangle", {type: 'html'}, switchTool);
currTool = brush;
@ -13,7 +14,7 @@ const ToolManager = (() => {
return;
let mousePos = Input.getCursorPosition(mouseEvent);
console.log("here");
switch(mouseEvent.which) {
case 1:
if (!Input.isDragging()) {
@ -47,15 +48,15 @@ const ToolManager = (() => {
let mousePos = Input.getCursorPosition(mouseEvent);
switch(mouseEvent.which) {
case 0:
case 1:
if (Input.isDragging()) {
currTool.onEnd(mousePos);
}
break;
case 1:
break;
case 2:
break;
case 3:
break;
default:
break;
}
@ -66,8 +67,6 @@ const ToolManager = (() => {
}
function switchTool(newTool) {
console.log("switch");
currTool.onDeselect();
currTool = newTool;
currTool.onSelect();