Tried to refactor more, snapped the brush preview to the pixel grid

This commit is contained in:
unsettledgames
2020-07-21 23:36:12 +02:00
parent 81cc4c8900
commit d14deeb761
4 changed files with 5 additions and 13 deletions

View File

@ -95,8 +95,8 @@ class Tool {
}
moveBrushPreview(cursorLocation) {
brushPreview.style.left = cursorLocation[0] + currentLayer.canvas.offsetLeft - this.currentBrushSize * zoom / 2 + 'px';
brushPreview.style.top = cursorLocation[1] + currentLayer.canvas.offsetTop - this.currentBrushSize * zoom / 2 + 'px';
brushPreview.style.left = (Math.ceil(cursorLocation[0] / zoom) * zoom + currentLayer.canvas.offsetLeft - this.currentBrushSize * zoom / 2 - zoom / 2) + 'px';
brushPreview.style.top = (Math.ceil(cursorLocation[1] / zoom) * zoom + currentLayer.canvas.offsetTop - this.currentBrushSize * zoom / 2 - zoom / 2) + 'px';
}
}