mirror of
https://github.com/lospec/pixel-editor.git
synced 2023-08-10 21:12:51 +03:00
line tool symmetry
This commit is contained in:
parent
c5113db10c
commit
c47686e4c8
@ -77,6 +77,47 @@ class LineTool extends ResizableTool {
|
|||||||
while (true) {
|
while (true) {
|
||||||
context.fillRect(x0-Math.floor(this.currSize/2), y0-Math.floor(this.currSize/2), this.currSize, this.currSize);
|
context.fillRect(x0-Math.floor(this.currSize/2), y0-Math.floor(this.currSize/2), this.currSize, this.currSize);
|
||||||
|
|
||||||
|
// handle symmetry
|
||||||
|
let midY = (currFile.canvasSize[1] / 2);
|
||||||
|
let midX = (currFile.canvasSize[0] / 2);
|
||||||
|
let mirrorX, mirrorY;
|
||||||
|
|
||||||
|
if (currFile.hSymmetricLayer.isEnabled) {
|
||||||
|
if (y0 <= midY) {
|
||||||
|
mirrorY = Math.floor(midY + Math.abs(midY - y0));
|
||||||
|
} else {
|
||||||
|
mirrorY = Math.floor(midY - Math.abs(midY - y0));
|
||||||
|
}
|
||||||
|
mirrorY -= (this.currSize % 2 === 0) ? 0 : 1;
|
||||||
|
context.fillRect(
|
||||||
|
x0 - Math.floor(this.currSize/2),
|
||||||
|
mirrorY - Math.floor(this.currSize/2),
|
||||||
|
this.currSize, this.currSize
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currFile.vSymmetricLayer.isEnabled) {
|
||||||
|
if (x0 <= midX) {
|
||||||
|
mirrorX = Math.floor(midX + Math.abs(midX - x0));
|
||||||
|
} else {
|
||||||
|
mirrorX = Math.floor(midX - Math.abs(midX - x0));
|
||||||
|
}
|
||||||
|
mirrorX -= (this.currSize % 2 === 0) ? 0 : 1;
|
||||||
|
context.fillRect(
|
||||||
|
mirrorX - Math.floor(this.currSize/2),
|
||||||
|
y0 - Math.floor(this.currSize/2),
|
||||||
|
this.currSize, this.currSize
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currFile.hSymmetricLayer.isEnabled && currFile.vSymmetricLayer.isEnabled) {
|
||||||
|
context.fillRect(
|
||||||
|
mirrorX - Math.floor(this.currSize/2),
|
||||||
|
mirrorY - Math.floor(this.currSize/2),
|
||||||
|
this.currSize, this.currSize
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
//if we've reached the end goal, exit the loop
|
//if we've reached the end goal, exit the loop
|
||||||
if ((x0==x1) && (y0==y1)) break;
|
if ((x0==x1) && (y0==y1)) break;
|
||||||
var e2 = 2*err;
|
var e2 = 2*err;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user