kopia lustrzana https://github.com/backface/turtlestitch
fix encodig of jump stitches and possibly encoding of first stitch
rodzic
a91eacdcc3
commit
7e1ba3b6d7
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"0": [ [0,0], [8,0], [8,12], [0,12], [0,0], [8,12], "FONT_LAST" ],
|
||||
"1": [ [4,0], [4,12], [3,10], "FONT_LAST" ],
|
||||
"1": [ [4,0], [4,12], [2,10], "FONT_LAST" ],
|
||||
"2": [ [0,12], [8,12], [8,7], [0,5], [0,0], [8,0], "FONT_LAST" ],
|
||||
"3": [ [0,12], [8,12], [8,0], [0,0], "FONT_UP", [0,6], [8,6], "FONT_LAST" ],
|
||||
"4": [ [0,12], [0,6], [8,6], "FONT_UP", [8,12], [8,0], "FONT_LAST" ],
|
||||
|
@ -10,51 +10,51 @@
|
|||
"8": [ [0,0], [8,0], [8,12], [0,12], [0,0], "FONT_UP", [0,6], [8,6], "FONT_LAST" ],
|
||||
"9": [ [8,0], [8,12], [0,12], [0,6], [8,6], "FONT_LAST" ],
|
||||
" ": [ "FONT_LAST", "FONT_LAST" ],
|
||||
".": [ [3,0], [4,0], "FONT_LAST" ],
|
||||
".": [ [3,2], [3,0], [5,0], [5,2],[3,2], "FONT_LAST" ],
|
||||
",": [ [2,0], [4,2], "FONT_LAST" ],
|
||||
"-": [ [2,6], [6,6], "FONT_LAST" ],
|
||||
"+": [ [1,6], [7,6], "FONT_UP", [4,9], [4,3], "FONT_LAST" ],
|
||||
"!": [ [4,0], [3,2], [5,2], [4,0], "FONT_UP", [4,4], [4,12], "FONT_LAST" ],
|
||||
"#": [ [0,4], [8,4], [6,2], [6,10], [8,8], [0,8], [2,10], [2,2], "FONT_LAST" ],
|
||||
"!": [ [3,2], [3,0], [5,0], [5,2],[3,2], "FONT_UP", [4,4], [4,12], "FONT_LAST" ],
|
||||
"#": [ [0,4], [8,4], "FONT_UP", [6,2], [6,10], "FONT_UP", [8,8], [0,8], "FONT_UP", [2,10], [2,2], "FONT_LAST" ],
|
||||
"^": [ [2,6], [4,12], [6,6], "FONT_LAST" ],
|
||||
"=": [ [1,4], [7,4], "FONT_UP", [1,8], [7,8], "FONT_LAST" ],
|
||||
"*": [ [0,0], [4,12], [8,0], [0,8], [8,8], [0,0], "FONT_LAST" ],
|
||||
"*": [ [2,6], [6,6], "FONT_UP", [4,3], [4,9], "FONT_UP", [2,4], [6,8], "FONT_UP", [6,4], [2,8], "FONT_LAST" ],
|
||||
"_": [ [0,0], [8,0], "FONT_LAST" ],
|
||||
"/": [ [0,0], [8,12], "FONT_LAST" ],
|
||||
"\\": [ [0,12], [8,0], "FONT_LAST" ],
|
||||
"@": [ [8,4], [4,0], [0,4], [0,8], [4,12], [8,8], [4,4], [3,6], "FONT_LAST" ],
|
||||
"$": [ [6,2], [2,6], [6,10], "FONT_UP", [4,12], [4,0], "FONT_LAST" ],
|
||||
"&": [ [8,0], [4,12], [8,8], [0,4], [4,0], [8,4], "FONT_LAST" ],
|
||||
"$": [ [2,2], [6,2], [6,6], [2,6], [2,10], [6,10], "FONT_UP", [4,12], [4,0], "FONT_LAST" ],
|
||||
"&": [ [8,0], [2,8], [4,12], [6,8], [0,4], [4,0], [8,4], "FONT_LAST" ],
|
||||
"[": [ [6,0], [2,0], [2,12], [6,12], "FONT_LAST" ],
|
||||
"]": [ [2,0], [6,0], [6,12], [2,12], "FONT_LAST" ],
|
||||
"(": [ [6,0], [2,4], [2,8], [6,12], "FONT_LAST" ],
|
||||
")": [ [2,0], [6,4], [6,8], [2,12], "FONT_LAST" ],
|
||||
"{": [ [6,0], [4,2], [4,10], [6,12], "FONT_UP", [2,6], [4,6], "FONT_LAST" ],
|
||||
"}": [ [4,0], [6,2], [6,10], [4,12], "FONT_UP", [6,6], [8,6], "FONT_LAST" ],
|
||||
"%": [ [0,0], [8,12], "FONT_UP", [2,10], [2,8], "FONT_UP", [6,4], [6,2], "FONT_LAST" ],
|
||||
"<": [ [6,0], [2,6], [6,12], "FONT_LAST" ],
|
||||
">": [ [2,0], [6,6], [2,12], "FONT_LAST" ],
|
||||
"|": [ [4,0], [4,5], "FONT_UP", [4,6], [4,12], "FONT_LAST" ],
|
||||
":": [ [4,9], [4,7], "FONT_UP", [4,5], [4,3], "FONT_LAST" ],
|
||||
";": [ [4,9], [4,7], "FONT_UP", [4,5], [1,2], "FONT_LAST" ],
|
||||
"\"": [ [2,10], [2,6], "FONT_UP", [6,10], [6,6], "FONT_LAST" ],
|
||||
"'": [ [2,6], [6,10], "FONT_LAST" ],
|
||||
"`": [ [2,10], [6,6], "FONT_LAST" ],
|
||||
"%": [ [1,2], [7,10], "FONT_UP", [1,9], [1,7], [3,7], [3,9],[1,9], "FONT_UP", [5,5], [5,3], [7,3], [7,5], [5,5], "FONT_LAST" ],
|
||||
"<": [ [6,3], [2,6], [6,9], "FONT_LAST" ],
|
||||
">": [ [2,3], [6,6], [2,9], "FONT_LAST" ],
|
||||
"|": [ [4,0], [4,12], "FONT_LAST" ],
|
||||
":": [ [4,7], [4,5], "FONT_UP", [4,4], [4,2], "FONT_LAST" ],
|
||||
";": [ [4,7], [4,5], "FONT_UP", [2,0], [4,2], "FONT_LAST" ],
|
||||
"\"": [ [2,12], [2,8], "FONT_UP", [6,12], [6,8], "FONT_LAST" ],
|
||||
"'": [ [3,8], [6,12], "FONT_LAST" ],
|
||||
"`": [ [3,12], [6,8], "FONT_LAST" ],
|
||||
"~": [ [0,4], [2,8], [6,4], [8,8], "FONT_LAST" ],
|
||||
"?": [ [0,8], [4,12], [8,8], [4,4], "FONT_UP", [4,1], [4,0], "FONT_LAST" ],
|
||||
"A": [ [0,0], [0,8], [4,12], [8,8], [8,0], "FONT_UP", [0,4], [8,4], "FONT_LAST" ],
|
||||
"A": [ [0,0], [0,8], [4,12], [8,8], [8,0], "FONT_UP", [8,4], "FONT_UP", [0,4], [8,4], "FONT_UP", [8,0],"FONT_LAST" ],
|
||||
"B": [ [0,0], [0,12], [6,12], [8,10], [8,8], [6,6], [0,6], "FONT_UP", [6,6], [8,4], [8,2], [6,0], [0,0], "FONT_LAST" ],
|
||||
"C": [ [8,0], [0,0], [0,12], [8,12], "FONT_LAST" ],
|
||||
"D": [ [0,0], [0,12], [4,12], [8,8], [8,4], [4,0], [0,0], "FONT_LAST" ],
|
||||
"D": [ [0,0], [0,12], [6,12], [8,10], [8,2], [6,0], [0,0], "FONT_LAST" ],
|
||||
"E": [ [8,0], [0,0], [0,12], [8,12], "FONT_UP", [0,6], [6,6], "FONT_LAST" ],
|
||||
"F": [ [0,0], [0,12], [8,12], "FONT_UP", [0,6], [6,6], "FONT_LAST" ],
|
||||
"G": [ [6,4], [8,4], [8,0], [0,0], [0,12], [8,12], "FONT_LAST" ],
|
||||
"G": [ [4,4], [8,4], [8,0], [0,0], [0,12], [8,12], "FONT_LAST" ],
|
||||
"H": [ [0,0], [0,12], "FONT_UP", [0,6], [8,6], "FONT_UP", [8,12], [8,0], "FONT_LAST" ],
|
||||
"I": [ [0,0], [8,0], "FONT_UP", [4,0], [4,12], "FONT_UP", [0,12], [8,12], "FONT_LAST" ],
|
||||
"J": [ [0,4], [4,0], [8,0], [8,12], "FONT_LAST" ],
|
||||
"J": [ [0,2], [2,0], [8,0], [8,12], "FONT_LAST" ],
|
||||
"K": [ [0,0], [0,12], "FONT_UP", [8,12], [0,6], [6,0], "FONT_LAST" ],
|
||||
"L": [ [8,0], [0,0], [0,12], "FONT_LAST" ],
|
||||
"M": [ [0,0], [0,12], [4,8], [8,12], [8,0], "FONT_LAST" ],
|
||||
"M": [ [0,0], [0,12], [4,6], [8,12], [8,0], "FONT_LAST" ],
|
||||
"N": [ [0,0], [0,12], [8,0], [8,12], "FONT_LAST" ],
|
||||
"O": [ [0,0], [0,12], [8,12], [8,0], [0,0], "FONT_LAST" ],
|
||||
"P": [ [0,0], [0,12], [8,12], [8,6], [0,6], "FONT_LAST" ],
|
||||
|
@ -64,7 +64,7 @@
|
|||
"T": [ [0,12], [8,12], "FONT_UP", [4,12], [4,0], "FONT_LAST" ],
|
||||
"U": [ [0,12], [0,2], [4,0], [8,2], [8,12], "FONT_LAST" ],
|
||||
"V": [ [0,12], [4,0], [8,12], "FONT_LAST" ],
|
||||
"W": [ [0,12], [2,0], [4,4], [6,0], [8,12], "FONT_LAST" ],
|
||||
"W": [ [0,12], [0,0], [4,6], [8,0], [8,12], "FONT_LAST" ],
|
||||
"X": [ [0,0], [8,12], "FONT_UP", [0,12], [8,0], "FONT_LAST" ],
|
||||
"Y": [ [0,12], [4,6], [8,12], "FONT_UP", [4,6], [4,0], "FONT_LAST" ],
|
||||
"Z": [ [0,12], [8,12], [0,0], [8,0],"FONT_LAST" ]
|
||||
|
|
|
@ -334,6 +334,7 @@ SpriteMorph.prototype.pointTowards = function (x, y) {
|
|||
SpriteMorph.prototype.drawText = function (text, scale, fontnr) {
|
||||
var stage = this.parentThatIsA(StageMorph);
|
||||
var dest;
|
||||
var myself = this;
|
||||
|
||||
if (!stage) {return; }
|
||||
|
||||
|
@ -355,6 +356,15 @@ SpriteMorph.prototype.drawText = function (text, scale, fontnr) {
|
|||
scale = scale * 2;
|
||||
}
|
||||
|
||||
function doAJump(x, y) {
|
||||
var penState = myself.isDown;
|
||||
myself.isDown = false;
|
||||
myself.gotoXY(x, y);
|
||||
myself.gotoXY(x+2, y+2);
|
||||
myself.gotoXY(x, y);
|
||||
myself.isDown = penState;
|
||||
}
|
||||
|
||||
if (stage.fonts) {
|
||||
for(var i in text) {
|
||||
var index = text.charCodeAt(i) - 33;
|
||||
|
@ -372,10 +382,7 @@ SpriteMorph.prototype.drawText = function (text, scale, fontnr) {
|
|||
// ignore last
|
||||
} else {
|
||||
if (nextPenIsUp || j == 0 ) {
|
||||
var penState = this.isDown;
|
||||
this.isDown = false;
|
||||
this.gotoXY(x + coords[j][0] * scale, y + coords[j][1] * scale )
|
||||
this.isDown = penState;
|
||||
doAJump(x + coords[j][0] * scale, y + coords[j][1] * scale )
|
||||
nextPenIsUp = false;
|
||||
} else {
|
||||
this.gotoXYBy(x + coords[j][0] * scale, y + coords[j][1] * scale, 10 )
|
||||
|
@ -384,10 +391,7 @@ SpriteMorph.prototype.drawText = function (text, scale, fontnr) {
|
|||
}
|
||||
}
|
||||
if (i < text.length) {
|
||||
var penState = this.isDown;
|
||||
this.isDown = false;
|
||||
this.gotoXY(x + (10 * scale), y );
|
||||
this.isDown = penState;
|
||||
doAJump(x + (10 * scale), y );
|
||||
}
|
||||
} else {
|
||||
if (stage.fonts[font].chars[index]){
|
||||
|
@ -406,10 +410,7 @@ SpriteMorph.prototype.drawText = function (text, scale, fontnr) {
|
|||
var coord = commands[i].split(',');
|
||||
if (coord[0][0] == "M") {
|
||||
coord[0] = coord[0].replace('M','')
|
||||
var penState = this.isDown;
|
||||
this.isDown = false;
|
||||
this.gotoXY(x + parseInt(coord[0]) * scale, y + (maxy - parseInt(coord[1])) * scale,)
|
||||
this.isDown = penState;
|
||||
doAJump(x + parseInt(coord[0]) * scale, y + (maxy - parseInt(coord[1])) * scale,)
|
||||
} else if (coord[0][0] == "L") {
|
||||
coord[0] = coord[0].replace('L','');
|
||||
this.gotoXYBy(x + parseInt(coord[0]) * scale, y + (maxy - parseInt(coord[1])) * scale, 10 )
|
||||
|
@ -417,15 +418,9 @@ SpriteMorph.prototype.drawText = function (text, scale, fontnr) {
|
|||
this.gotoXYBy(x + parseInt(coord[0]) * scale, y + (maxy - parseInt(coord[1])) * scale, 10 )
|
||||
}
|
||||
}
|
||||
var penState = this.isDown;
|
||||
this.isDown = false;
|
||||
this.gotoXY(x + (stage.fonts[font].chars[index].o * 1.7) * scale, y)
|
||||
this.isDown = penState;
|
||||
doAJump(x + (stage.fonts[font].chars[index].o * 1.7) * scale, y)
|
||||
} else {
|
||||
var penState = this.isDown
|
||||
this.isDown = false;
|
||||
this.gotoXY(x + 10 * scale, y)
|
||||
this.isDown = penState;
|
||||
doAJump(x + 10 * scale, y)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -142,32 +142,33 @@ TurtleShepherd.prototype.moveTo= function(x1, y1, x2, y2, penState) {
|
|||
}
|
||||
);
|
||||
this.density[Math.round(x1) + "x" + Math.round(y1)] = 1;
|
||||
|
||||
} else {
|
||||
if (x2 < this.minX) this.minX = x2;
|
||||
if (x2 > this.maxX) this.maxX = x2;
|
||||
|
||||
if (y2 < this.minY) this.minY = y2;
|
||||
if (y2 > this.maxY) this.maxY = y2;
|
||||
|
||||
var d = Math.round(x2) + "x" + Math.round(y2);
|
||||
if (this.density[d]) {
|
||||
this.density[d] += 1;
|
||||
if (this.density[d] > this.densityMax) {
|
||||
this.densityWarning = true;
|
||||
if (this.density[d] <= this.densityMax+1)
|
||||
warn = true;
|
||||
}
|
||||
} else {
|
||||
this.density[d] = 1;
|
||||
}
|
||||
if ( this.calcTooLong && penState) {
|
||||
if ( (Math.max(
|
||||
Math.abs(x2 - x1), Math.abs(y2 - y1)
|
||||
) / this.pixels_per_millimeter * 10) / this.maxLength > 1)
|
||||
this.tooLongCount += 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (x2 < this.minX) this.minX = x2;
|
||||
if (x2 > this.maxX) this.maxX = x2;
|
||||
|
||||
if (y2 < this.minY) this.minY = y2;
|
||||
if (y2 > this.maxY) this.maxY = y2;
|
||||
|
||||
var d = Math.round(x2) + "x" + Math.round(y2);
|
||||
if (this.density[d]) {
|
||||
this.density[d] += 1;
|
||||
if (this.density[d] > this.densityMax) {
|
||||
this.densityWarning = true;
|
||||
if (this.density[d] <= this.densityMax+1)
|
||||
warn = true;
|
||||
}
|
||||
} else {
|
||||
this.density[d] = 1;
|
||||
}
|
||||
|
||||
if ( this.calcTooLong && penState) {
|
||||
if ( (Math.max(
|
||||
Math.abs(x2 - x1), Math.abs(y2 - y1)
|
||||
) / this.pixels_per_millimeter * 10) / this.maxLength > 1)
|
||||
this.tooLongCount += 1;
|
||||
}
|
||||
|
||||
this.cache.push(
|
||||
{
|
||||
"cmd":"move",
|
||||
|
|
Ładowanie…
Reference in New Issue