2021-11-01 15:02:18 +03:00
|
|
|
class EraserTool extends ResizableTool {
|
2021-10-27 11:43:51 +03:00
|
|
|
constructor(name, options, switchFunction) {
|
|
|
|
super(name, options);
|
|
|
|
|
|
|
|
Events.on('click', this.mainButton, switchFunction, this);
|
|
|
|
Events.on('click', this.biggerButton, this.increaseSize.bind(this));
|
|
|
|
Events.on('click', this.smallerButton, this.decreaseSize.bind(this));
|
2022-01-26 01:47:01 +03:00
|
|
|
|
|
|
|
this.resetTutorial();
|
|
|
|
this.addTutorialTitle("Eraser tool");
|
|
|
|
this.addTutorialKey("E", " to select the eraser");
|
|
|
|
this.addTutorialKey("Left drag", " to erase an area");
|
|
|
|
this.addTutorialKey("Right drag", " to resize the eraser");
|
|
|
|
this.addTutorialKey("+ or -", " to resize the eraser");
|
|
|
|
this.addTutorialImg("eraser-tutorial.gif");
|
2021-10-27 11:43:51 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
onStart(mousePos) {
|
|
|
|
super.onStart(mousePos);
|
2021-11-09 14:19:57 +03:00
|
|
|
new HistoryState().EditCanvas();
|
2021-10-27 11:43:51 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
onDrag(mousePos, cursorTarget) {
|
|
|
|
super.onDrag(mousePos);
|
|
|
|
|
|
|
|
if (cursorTarget === undefined)
|
|
|
|
return;
|
|
|
|
//draw line to current pixel
|
|
|
|
if (cursorTarget.className == 'drawingCanvas' || cursorTarget.className == 'drawingCanvas') {
|
2021-12-06 19:37:43 +03:00
|
|
|
currFile.currentLayer.drawLine(Math.floor(this.prevMousePos[0]/currFile.zoom),
|
|
|
|
Math.floor(this.prevMousePos[1]/currFile.zoom),
|
|
|
|
Math.floor(this.currMousePos[0]/currFile.zoom),
|
|
|
|
Math.floor(this.currMousePos[1]/currFile.zoom),
|
2022-01-06 01:54:29 +03:00
|
|
|
this.currSize, true
|
2021-10-27 11:43:51 +03:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-12-06 19:37:43 +03:00
|
|
|
currFile.currentLayer.updateLayerPreview();
|
2021-10-27 11:43:51 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
onEnd(mousePos) {
|
|
|
|
super.onEnd(mousePos);
|
|
|
|
this.endMousePos = mousePos;
|
|
|
|
}
|
|
|
|
|
|
|
|
onSelect() {
|
|
|
|
super.onSelect();
|
|
|
|
}
|
|
|
|
|
|
|
|
onDeselect() {
|
|
|
|
super.onDeselect();
|
|
|
|
}
|
|
|
|
}
|