export to canvas size

This commit is contained in:
Hugh Bord 2021-06-26 10:19:52 +10:00
parent a77222d63f
commit 884e0c619e
3 changed files with 23 additions and 4 deletions

View File

@ -16,10 +16,13 @@
```
# BUGS
* Odd row width makes brush off by one
* If you resize an ascii, and then undo and try fill in blocks it will error cuz the blocks don't exist
* Redo (ctrl y) is a buggy
# FOCUSING ON NOW
* EXPORT ascii, trim to canvas size
* Circle brush
* SELECT
@ -35,6 +38,8 @@
* Context Menus (right click menu) - we started this
* Keyboard shortcuts
* LAYERS
# KILLER ASCIIBIRD FEATURES DONE
* Tabbed editing for asciis

View File

@ -309,7 +309,8 @@ export default {
.split("\u0003\u0003")
.join("\u0003")
.split("\u000F").join("")
.split("\u0003\n").join("\n");
.split("\u0003\n").join("\n")
.split("\u0002\u0003").join("\u0003");
// This will end up in the asciibirdMeta
const finalAscii = {
@ -380,7 +381,10 @@ export default {
if (!finalAscii.width && widthOfColCodes > 0) {
finalAscii.width =
maxWidthLoop - widthOfColCodes; // minus \n for the proper width
} else if (!finalAscii.width && widthOfColCodes === 0) {
}
if (!finalAscii.width && widthOfColCodes === 0) {
// Plain text
finalAscii.width =
maxWidthFound; // minus \n for the proper width
@ -548,9 +552,19 @@ export default {
const output = [];
let curBlock = null;
let prevBlock = { bg: -1, fg: -1 };
for (let y = 0; y <= blocks.length - 1; y++) {
if (y >= currentAscii.height) {
continue;
}
for (let x = 0; x <= blocks[y].length - 1; x++) {
if (x >= currentAscii.width) {
continue;
}
curBlock = blocks[y][x];
// If we have a difference between our previous block

View File

@ -203,7 +203,7 @@ export default {
targetX = targetX - 1;
}
if (this.blocks[y]) {
if (this.blocks[y] && this.blocks[y][targetX]) {
if (x % 2 === 0) {
this.blocks[y][targetX] = Object.assign({}, emptyBlock);
} else {