kopia lustrzana https://github.com/backface/turtlestitch
fixed issues:
* with svg export (inital color changes, initial pen size changes caused corrupted tag ending) * initial pen sizes and colors that diverged from default * reset now also resets pensizepull/79/head
rodzic
817e08e9b7
commit
3c38be55bd
|
@ -1303,8 +1303,6 @@ SpriteMorph.prototype.wait = function(millis)
|
||||||
//SpriteMorph.prototype.thumbnail = function (extentPoint) {};
|
//SpriteMorph.prototype.thumbnail = function (extentPoint) {};
|
||||||
//SpriteMorph.prototype.drawNew = function () { this.hide() }
|
//SpriteMorph.prototype.drawNew = function () { this.hide() }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// THREE additions
|
// THREE additions
|
||||||
|
|
||||||
THREE.Object3D.prototype.addLineToPointWithColor = function (point, color, thickness) {
|
THREE.Object3D.prototype.addLineToPointWithColor = function (point, color, thickness) {
|
||||||
|
@ -1321,24 +1319,24 @@ THREE.Object3D.prototype.addLineFromPointToPointWithColor = function (originPoin
|
||||||
return line;
|
return line;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
SpriteMorph.prototype.resetAll = function () {
|
SpriteMorph.prototype.resetAll = function () {
|
||||||
var myself = this;
|
var myself = this;
|
||||||
myself.stitchtype = 0;
|
myself.stitchtype = 0;
|
||||||
myself.stitchoptions = {};
|
myself.stitchoptions = {};
|
||||||
myself.isRunning = false;
|
myself.isRunning = false;
|
||||||
myself.setColor(StageMorph.prototype.defaultPenColor);
|
myself.setColor(StageMorph.prototype.defaultPenColor);
|
||||||
|
myself.parentThatIsA(StageMorph).setPenSize(1);
|
||||||
myself.gotoXY(0,0);
|
myself.gotoXY(0,0);
|
||||||
myself.setHeading(90);
|
myself.setHeading(90);
|
||||||
myself.clear();
|
myself.clear();
|
||||||
myself.isDown = true;
|
myself.isDown = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
SpriteMorph.prototype.resetStitchSettings = function () {
|
SpriteMorph.prototype.resetStitchSettings = function () {
|
||||||
var myself = this;
|
var myself = this;
|
||||||
myself.stitchoptions = {}
|
myself.stitchoptions = {}
|
||||||
myself.stitchtype = 0;
|
myself.stitchtype = 0;
|
||||||
myself.isRunning = false;
|
myself.isRunning = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Block specs
|
// Block specs
|
||||||
|
|
|
@ -49,8 +49,8 @@ TurtleShepherd.prototype.clear = function() {
|
||||||
this.densityWarning = false;
|
this.densityWarning = false;
|
||||||
this.colors = [];
|
this.colors = [];
|
||||||
this.newColor = 0;
|
this.newColor = 0;
|
||||||
this.oldColor = 0;
|
this.oldColor = this.defaultColor;
|
||||||
this.penSize = 1;
|
this.penSize = 1;
|
||||||
this.newPenSize = 0;
|
this.newPenSize = 0;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -165,11 +165,11 @@ TurtleShepherd.prototype.moveTo= function(x1, y1, x2, y2, penState) {
|
||||||
if (this.colors.length < 1) {
|
if (this.colors.length < 1) {
|
||||||
if (this.newColor) {
|
if (this.newColor) {
|
||||||
this.colors.push(this.newColor);
|
this.colors.push(this.newColor);
|
||||||
this.newColor = false;
|
//this.newColor = false;
|
||||||
} else {
|
} else {
|
||||||
this.colors.push(this.defaultColor);
|
this.colors.push(this.defaultColor);
|
||||||
}
|
}
|
||||||
this.oldColor = this.colors[this.colors.length-1];
|
//this.oldColor = this.colors[this.colors.length-1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -359,16 +359,20 @@ TurtleShepherd.prototype.toSVG = function() {
|
||||||
penSize = 1;
|
penSize = 1;
|
||||||
lastStitch = null;
|
lastStitch = null;
|
||||||
color = this.defaultColor;
|
color = this.defaultColor;
|
||||||
|
|
||||||
|
//console.log("export svg");
|
||||||
|
//console.log(this.colors);
|
||||||
|
//console.log(this.cache);
|
||||||
|
|
||||||
for (var i=0; i < this.cache.length; i++) {
|
for (var i=0; i < this.cache.length; i++) {
|
||||||
if (this.cache[i].cmd == "color" && !this.ignoreColors) {
|
if (this.cache[i].cmd == "color" && !this.ignoreColors) {
|
||||||
color = this.cache[i].color;
|
color = this.cache[i].color;
|
||||||
colorChanged = true;
|
if (hasFirst) colorChanged = true;
|
||||||
if (tagOpen) svgStr += '" />\n';
|
if (tagOpen) svgStr += '" />\n';
|
||||||
tagOpen = false;
|
tagOpen = false;
|
||||||
} else if (this.cache[i].cmd == "pensize") {
|
} else if (this.cache[i].cmd == "pensize") {
|
||||||
penSize = this.cache[i].pensize;
|
penSize = this.cache[i].pensize;
|
||||||
penSizeChanged = true;
|
if (hasFirst) penSizeChanged = true;
|
||||||
if (tagOpen) svgStr += '" />\n';
|
if (tagOpen) svgStr += '" />\n';
|
||||||
tagOpen = false;
|
tagOpen = false;
|
||||||
} else if (this.cache[i].cmd == "move") {
|
} else if (this.cache[i].cmd == "move") {
|
||||||
|
|
Ładowanie…
Reference in New Issue