Cleanups (#10)

* Cleanup fillTool

* Cleanup fillTool

* Fix typo in canvas resize

* Remove unneeded return

* simplify layers loop in mirc export
This commit is contained in:
Fred Akers 2021-08-18 20:23:12 -04:00 committed by GitHub
parent c45bfabcaa
commit 8acef070da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 50 deletions

View File

@ -485,32 +485,28 @@ export const exportMirc = () => {
}
for (let i = blocks.length - 1; i >= 0; i--) {
if (blocks[i].visible === true) {
currentLayer = i;
if (
blocks[i].data &&
blocks[i].data[y] &&
blocks[i].data[y][x] &&
i > 0 &&
JSON.stringify(blocks[i].data[y][x]) ===
JSON.stringify(emptyBlock)
) {
continue;
} else if (
// Otherwise if we are on the very first layer we need to render it
blocks[i].data &&
blocks[i].data[y] &&
blocks[i].data[y][x]
) {
curBlock = {
...blocks[i].data[y][x]
};
break;
}
if (blocks[i].visible !== true) {
continue;
}
currentLayer = i;
if (
!blocks[i].data ||
!blocks[i].data[y] ||
!blocks[i].data[y][x]
) {
continue;
}
if (
i > 0 &&
JSON.stringify(blocks[i].data[y][x]) ===
JSON.stringify(emptyBlock)
) {
continue;
}
curBlock = {
...blocks[i].data[y][x]
};
break;
}
// If we have a difference between our previous block
@ -614,7 +610,6 @@ export const checkForGetRequest = async () => {
const asciiName = haxAscii.split('/').pop();
const asciiData = await res.text();
parseMircAscii(asciiData, asciiName);
return;
}
}

View File

@ -322,8 +322,6 @@ export default {
icon: "fa-check-cross",
singleton: true,
});
return;
}
},
checkVisible(top) {
@ -474,7 +472,7 @@ export default {
});
this.$refs.canvasdrag.width = width;
this.$refs.canvasdrag.width = height;
this.$refs.canvasdrag.height = height;
this.delayRedrawCanvas();
},
@ -1257,27 +1255,7 @@ export default {
);
},
fillTool(fillBlocks, y, x, current, eraser) {
// If row is less than 0
if (x < 0) {
return;
}
// If column is less than 0
if (y < 0) {
return;
}
// If row is greater than image length
if (x >= this.currentAsciiWidth) {
return;
}
// If column is greater than image length
if (y >= this.currentAsciiHeight) {
return;
}
if (!fillBlocks[y] && !fillBlocks[y][x]) {
if(fillBlocks[y] === undefined || fillBlocks[y][x] === undefined) {
return;
}