Removed selection reconstruction

Selecting out of bounds isn't a problem anymore
This commit is contained in:
Nicola 2022-01-22 12:23:39 +01:00
parent fd688a3e86
commit 6900ecb0c0
1 changed files with 0 additions and 105 deletions

View File

@ -214,8 +214,6 @@ class SelectionTool extends Tool {
let selected = [];
let visited = {};
let data = currFile.VFXLayer.context.getImageData(0, 0, currFile.canvasSize[0], currFile.canvasSize[1]).data;
data = this.reconstructSelection(data);
// BFS: a pixel that causes the algorithm to visit a pixel of the bounding box is outside the
// selection. Otherwise, since the algorithm stops visiting when it reaches the outline,
@ -251,109 +249,6 @@ class SelectionTool extends Tool {
return this.previewData;
}
reconstructSelection(data) {
let x, y, index;
let fill = false;
if (this.reconstruct.top) {
y = Math.max(this.boundingBox.minY, 0);
this.boundingBox.minY = y;
for (x=this.boundingBox.minX; x<this.boundingBox.maxX; x++) {
index = (y * currFile.canvasSize[1] + x) * 4;
if (data[index + 3] == 255)
fill = !fill;
if (fill) {
data[index] = 0;
data[index+1] = 0;
data[index+2] = 0;
data[index+3] = 255;
currFile.VFXLayer.context.fillRect(x, y, 1, 1);
}
}
}
if (this.reconstruct.left) {
x = Math.max(this.boundingBox.minX, 0);
this.boundingBox.minX = x;
let startPixel = data[(this.boundingBox.minY * currFile.canvasSize[1] + x) * 4];
if ((this.reconstruct.top || this.reconstruct.bottom) && startPixel[3] == 255)
fill = !fill;
for (y=this.boundingBox.minY; y<this.boundingBox.maxY; y++) {
index = (y * currFile.canvasSize[1] + x) * 4;
if (data[index + 3] == 255)
fill = !fill;
if (fill) {
data[index] = 0;
data[index+1] = 0;
data[index+2] = 0;
data[index+3] = 255;
currFile.VFXLayer.context.fillRect(x, y, 1, 1);
}
}
}
if (this.reconstruct.bottom) {
y = Math.min(this.boundingBox.maxY, currFile.canvasSize[1]-1);
this.boundingBox.maxY = y+1;
let startPixel = data[(y * currFile.canvasSize[1] + this.boundingBox.minX) * 4];
if ((this.reconstruct.left || this.reconstruct.right) && startPixel[3] == 255)
fill = !fill;
for (x=this.boundingBox.minX; x<this.boundingBox.maxX; x++) {
index = (y * currFile.canvasSize[1] + x) * 4;
if (data[index + 3] == 255)
fill = !fill;
if (fill) {
data[index] = 0;
data[index+1] = 0;
data[index+2] = 0;
data[index+3] = 255;
currFile.VFXLayer.context.fillRect(x, y, 1, 1);
}
}
}
if (this.reconstruct.right) {
x = Math.min(this.boundingBox.maxX, currFile.canvasSize[0]-1);
this.boundingBox.maxX = x+1;
let startPixel = data[(this.boundingBox.minY * currFile.canvasSize[1] + x) * 4];
if ((this.reconstruct.top || this.reconstruct.bottom) && startPixel[3] == 255)
fill = !fill;
for (y=this.boundingBox.minY; y<this.boundingBox.maxY; y++) {
index = (y * currFile.canvasSize[1] + x) * 4;
if (data[index + 3] == 255)
fill = !fill;
if (fill) {
data[index] = 0;
data[index+1] = 0;
data[index+2] = 0;
data[index+3] = 255;
currFile.VFXLayer.context.fillRect(x, y, 1, 1);
}
}
}
return data;
}
drawSelectedArea() {
for (const key in this.currSelection) {
let x = parseInt(key.split(",")[0]);