Merge pull request #77 from lospec/bug-fixes

Fixed brush not working on start
This commit is contained in:
Nicola 2022-01-24 22:09:42 +01:00 committed by GitHub
commit b9687c85d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 1 deletions

View File

@ -7,9 +7,24 @@ class BrushTool extends ResizableTool {
Events.on('click', this.smallerButton, this.decreaseSize.bind(this));
}
onStart(mousePos) {
onStart(mousePos, cursorTarget) {
super.onStart(mousePos);
if (cursorTarget === undefined)
return;
new HistoryState().EditCanvas();
//draw line to current pixel
if (cursorTarget.className == 'drawingCanvas' || cursorTarget.className == 'drawingCanvas') {
currFile.currentLayer.drawLine(
Math.floor(mousePos[0]/currFile.zoom),
Math.floor(mousePos[1]/currFile.zoom),
Math.floor(mousePos[0]/currFile.zoom),
Math.floor(mousePos[1]/currFile.zoom),
this.currSize
);
}
currFile.currentLayer.updateLayerPreview();
}
onDrag(mousePos, cursorTarget) {