(fix by @liamortiz )
This commit is contained in:
unsettledgames
2021-06-30 22:13:59 +02:00
parent 645011bd4f
commit f37a85cf55
2 changed files with 9 additions and 15 deletions

View File

@ -95,20 +95,14 @@ class Tool {
}
moveBrushPreview(cursorLocation) {
let toSub = 0;
// Prevents the brush to be put in the middle of pixels
if (this.currentBrushSize % 2 == 0) {
toSub = 0.5;
}
brushPreview.style.left = (Math.ceil(cursorLocation[0] / zoom) * zoom // Stick to pixel grid
+ currentLayer.canvas.offsetLeft // Account for canvas offset
- this.currentBrushSize * zoom / 2 // Center the brush preview
- zoom / 2 - toSub * zoom) + 'px'; // ???
brushPreview.style.top = (Math.ceil(cursorLocation[1] / zoom) * zoom + currentLayer.canvas.offsetTop - this.currentBrushSize * zoom / 2 - zoom / 2 - toSub * zoom) + 'px';
console.log("Brush coords: " + brushPreview.style.left + "," + brushPreview.style.top);
}
let toSub = 1;
// Prevents the brush to be put in the middle of pixels
if (this.currentBrushSize % 2 == 0) {
toSub = 0.5;
}
brushPreview.style.left = (Math.floor(cursorLocation[0] / zoom) * zoom + currentLayer.canvas.offsetLeft - this.currentBrushSize * zoom / 2 - zoom / 2 + toSub * zoom) + 'px';
brushPreview.style.top = (Math.floor(cursorLocation[1] / zoom) * zoom + currentLayer.canvas.offsetTop - this.currentBrushSize * zoom / 2 - zoom / 2 + toSub * zoom) + 'px';
}
}