mirror of
https://github.com/lospec/pixel-editor.git
synced 2023-08-10 21:12:51 +03:00
Fixed wonky rectangle drawing
This commit is contained in:
parent
d7b04d7699
commit
d35e768ce8
@ -40,7 +40,7 @@ function updateRectDrawing(mouseEvent) {
|
|||||||
let pos = getCursorPosition(mouseEvent);
|
let pos = getCursorPosition(mouseEvent);
|
||||||
|
|
||||||
// Drawing the rect at the right position
|
// Drawing the rect at the right position
|
||||||
drawRectangle(Math.round(pos[0] / zoom) + 0.5, Math.round(pos[1] / zoom) + 0.5);
|
drawRectangle(Math.floor(pos[0] / zoom) + 0.5, Math.floor(pos[1] / zoom) + 0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Finishes drawing the rect, decides the end coordinates and moves the preview rectangle to the
|
/** Finishes drawing the rect, decides the end coordinates and moves the preview rectangle to the
|
||||||
@ -53,8 +53,8 @@ function endRectDrawing(mouseEvent) {
|
|||||||
let currentPos = getCursorPosition(mouseEvent);
|
let currentPos = getCursorPosition(mouseEvent);
|
||||||
let vfxContext = VFXCanvas.getContext("2d");
|
let vfxContext = VFXCanvas.getContext("2d");
|
||||||
|
|
||||||
endRectX = Math.round(currentPos[0] / zoom) + 0.5;
|
endRectX = Math.floor(currentPos[0] / zoom) + 0.5;
|
||||||
endRectY = Math.round(currentPos[1] / zoom) + 0.5;
|
endRectY = Math.floor(currentPos[1] / zoom) + 0.5;
|
||||||
|
|
||||||
// Inverting end and start (start must always be the top left corner)
|
// Inverting end and start (start must always be the top left corner)
|
||||||
if (endRectX < startRectX) {
|
if (endRectX < startRectX) {
|
||||||
|
Loading…
Reference in New Issue
Block a user