kopia lustrzana https://github.com/backface/turtlestitch
remove zero stitches from EXP export
rodzic
115913b48e
commit
28c53a6a33
|
@ -501,27 +501,25 @@ TurtleShepherd.prototype.toEXP = function() {
|
||||||
if (this.cache[i].cmd == "color" && !this.ignoreColors) {
|
if (this.cache[i].cmd == "color" && !this.ignoreColors) {
|
||||||
expArr.push(0x80);
|
expArr.push(0x80);
|
||||||
expArr.push(0x01);
|
expArr.push(0x01);
|
||||||
expArr.push(0x00);
|
expArr.push(0x00);
|
||||||
expArr.push(0x00);
|
expArr.push(0x00);
|
||||||
weJustChangedColors = true;
|
weJustChangedColors = true;
|
||||||
|
|
||||||
} else if (this.cache[i].cmd == "move") {
|
} else if (this.cache[i].cmd == "move") {
|
||||||
|
|
||||||
stitch = this.cache[i];
|
stitch = this.cache[i];
|
||||||
|
|
||||||
if (!hasFirst) {
|
if (!hasFirst) {
|
||||||
origin.x = Math.round(stitch.x * scale);
|
origin.x = Math.round(stitch.x * scale);
|
||||||
origin.y = Math.round(stitch.y * scale);
|
origin.y = Math.round(stitch.y * scale);
|
||||||
if (!stitch.penDown) {
|
|
||||||
expArr.push(0x80);
|
|
||||||
expArr.push(0x04);
|
|
||||||
}
|
|
||||||
move(0,0);
|
|
||||||
lastStitch = {cmd: "move", x: 0, y: -0, penDown: stitch.penDown}
|
|
||||||
hasFirst = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hasFirst) {
|
// remove zero stitch - why is it here?
|
||||||
|
//if (!stitch.penDown) {
|
||||||
|
// expArr.push(0x80);
|
||||||
|
// expArr.push(0x04);
|
||||||
|
//}
|
||||||
|
//move(0,0);
|
||||||
|
|
||||||
|
lastStitch = {cmd: "move", x: 0, y: -0, penDown: stitch.penDown}
|
||||||
|
hasFirst = true;
|
||||||
|
} else if (hasFirst) {
|
||||||
x1 = Math.round(stitch.x * scale) - origin.x;
|
x1 = Math.round(stitch.x * scale) - origin.x;
|
||||||
y1 = -Math.round(stitch.y * scale) - origin.y;
|
y1 = -Math.round(stitch.y * scale) - origin.y;
|
||||||
x0 = Math.round(lastStitch.x * scale) - origin.x;
|
x0 = Math.round(lastStitch.x * scale) - origin.x;
|
||||||
|
@ -530,19 +528,21 @@ TurtleShepherd.prototype.toEXP = function() {
|
||||||
sum_x = 0;
|
sum_x = 0;
|
||||||
sum_y = 0;
|
sum_y = 0;
|
||||||
dmax = Math.max(Math.abs(x1 - x0), Math.abs(y1 - y0));
|
dmax = Math.max(Math.abs(x1 - x0), Math.abs(y1 - y0));
|
||||||
dsteps = Math.abs(dmax / 127);
|
dsteps = Math.abs(dmax / 127);
|
||||||
|
|
||||||
if (!lastStitch.penDown)
|
// remove zero stitch - why is it here?
|
||||||
move(0,0);
|
//if (!lastStitch.penDown)
|
||||||
|
// move(0,0);
|
||||||
|
|
||||||
if (weJustChangedColors) {
|
if (weJustChangedColors) {
|
||||||
if (!stitch.penDown) {
|
// remove zero stitch - why is it here?
|
||||||
expArr.push(0x80);
|
// if (!stitch.penDown) {
|
||||||
expArr.push(0x04);
|
// expArr.push(0x80);
|
||||||
}
|
// expArr.push(0x04);
|
||||||
move(0,0);
|
// }
|
||||||
weJustChangedColors = false;
|
// move(0,0);
|
||||||
}
|
weJustChangedColors = false;
|
||||||
|
}
|
||||||
|
|
||||||
if (dsteps <= 1) {
|
if (dsteps <= 1) {
|
||||||
if (!stitch.penDown) {
|
if (!stitch.penDown) {
|
||||||
|
@ -565,9 +565,7 @@ TurtleShepherd.prototype.toEXP = function() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
move(Math.round(Math.round(stitch.x * scale), -Math.round(stitch.y * scale)));
|
|
||||||
}
|
|
||||||
lastStitch = stitch;
|
lastStitch = stitch;
|
||||||
hasFirst = true;
|
hasFirst = true;
|
||||||
}
|
}
|
||||||
|
@ -774,12 +772,14 @@ TurtleShepherd.prototype.toDST = function(name="noname") {
|
||||||
stitch = this.cache[i];
|
stitch = this.cache[i];
|
||||||
|
|
||||||
if (!hasFirst) { // create a stitch at origin
|
if (!hasFirst) { // create a stitch at origin
|
||||||
origin.x = Math.round(stitch.x * scale);
|
origin.x = Math.round(stitch.x * scale);
|
||||||
origin.y = Math.round(stitch.y * scale);
|
origin.y = Math.round(stitch.y * scale);
|
||||||
encodeTajimaStitch(0, 0, !stitch.penDown);
|
|
||||||
lastStitch = {cmd: "move", x: 0, y:0, penDown: stitch.penDown}
|
// zero stitch: Why is it here
|
||||||
hasFirst = true;
|
encodeTajimaStitch(0, 0, !stitch.penDown);
|
||||||
} else {
|
lastStitch = {cmd: "move", x: 0, y:0, penDown: stitch.penDown}
|
||||||
|
hasFirst = true;
|
||||||
|
} else {
|
||||||
x1 = Math.round(stitch.x * scale) - origin.x;
|
x1 = Math.round(stitch.x * scale) - origin.x;
|
||||||
y1 = Math.round(stitch.y * scale) - origin.y;
|
y1 = Math.round(stitch.y * scale) - origin.y;
|
||||||
x0 = Math.round(lastStitch.x * scale) - origin.x;
|
x0 = Math.round(lastStitch.x * scale) - origin.x;
|
||||||
|
@ -791,16 +791,17 @@ TurtleShepherd.prototype.toDST = function(name="noname") {
|
||||||
dsteps = Math.abs(dmax / 121);
|
dsteps = Math.abs(dmax / 121);
|
||||||
|
|
||||||
if (!lastStitch.penDown)
|
if (!lastStitch.penDown)
|
||||||
encodeTajimaStitch(0,0, false);
|
// zero stitch: Why is it here
|
||||||
|
encodeTajimaStitch(0,0, false);
|
||||||
|
|
||||||
if (weJustChangedColors) {
|
if (weJustChangedColors) {
|
||||||
encodeTajimaStitch(0, 0, !stitch.penDown);
|
// zero stitch: Why is it here
|
||||||
weJustChangedColors = false;
|
encodeTajimaStitch(0, 0, !stitch.penDown);
|
||||||
}
|
weJustChangedColors = false;
|
||||||
|
}
|
||||||
|
|
||||||
if (dsteps <= 1) {
|
if (dsteps <= 1) {
|
||||||
encodeTajimaStitch((x1 - x0), (y1 - y0),
|
encodeTajimaStitch((x1 - x0), (y1 - y0), !stitch.penDown);
|
||||||
!stitch.penDown);
|
|
||||||
count_stitches++;
|
count_stitches++;
|
||||||
} else {
|
} else {
|
||||||
for(j=0;j<dsteps;j++) {
|
for(j=0;j<dsteps;j++) {
|
||||||
|
|
Ładowanie…
Reference in New Issue