Fix not rendering preview on zoom 1

main
kts of kettek 2024-02-15 11:13:47 -08:00
parent 732bc467f9
commit b20caab1d7
1 changed files with 19 additions and 17 deletions

View File

@ -163,7 +163,7 @@
ctx.strokeStyle = '#ff0000'
ctx.lineWidth = 1
if (zoom > 1) {
// Draw brush preview.
let shape: PixelPosition[]
if (brushType === 'square' || brushSize <= 2) {
// FIXME: This is daft to adjust +1,+1 for size 2 -- without this, the rect preview draws one pixel offset to the top-left, which is not the same as when the filled rect is placed.
@ -180,9 +180,11 @@
for (let i = 0; i < shape.length; i++) {
ctx.fillRect(offsetX*zoom+(mousePixelX+shape[i].x)*zoom, offsetY*zoom+(mousePixelY+shape[i].y)*zoom, zoom, zoom)
}
// Draw zoomed pixel-sized square where mouse is.
if (zoom > 1) {
ctx.rect(offsetX*zoom+mousePixelX*zoom, offsetY*zoom+mousePixelY*zoom, 1*zoom, 1*zoom)
}
// Draw pixel square where mouse is.
if (zoom <= 1 || zoom > 4) {
ctx.rect(mouseX, mouseY, 1, 1)
}