kopia lustrzana https://github.com/backface/turtlestitch
add embroidery debug helpers: denisty warning and too long stitch count
rodzic
cc139ffc5d
commit
4fae408dcc
|
@ -2,7 +2,7 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>TurtleStitch 2.0 Beta</title>
|
||||
<title>TurtleStitch 2.0</title>
|
||||
<link rel="shortcut icon" href="stitchcode/favicon-32x32.png" type="image/png" />
|
||||
<script type="text/javascript" src="morphic.js"></script>
|
||||
<script type="text/javascript" src="widgets.js"></script>
|
||||
|
|
|
@ -667,33 +667,62 @@ IDE_Morph.prototype.createStatusDisplay = function () {
|
|||
elements.push(space);
|
||||
|
||||
elements.push(' Total Stitches : ');
|
||||
element = new StringMorph();
|
||||
element = new StringMorph();
|
||||
element.update = function () {
|
||||
this.text = (stage.turtleShepherd.getStepCount()).toString()+ " ";
|
||||
};
|
||||
element.columns = 3;
|
||||
element.newColumn = 1;
|
||||
elements.push(element);
|
||||
|
||||
elements.push(' ');
|
||||
|
||||
elements.push('Jumps : ');
|
||||
element = new StringMorph();
|
||||
element.update = function () {
|
||||
this.text = (stage.turtleShepherd.getJumpCount()).toString()+ " ";
|
||||
};
|
||||
element.columns = 3;
|
||||
element.newColumn = 2;
|
||||
elements.push(element);
|
||||
elements.push(' ');
|
||||
|
||||
elements.push('Dimensions : ');
|
||||
element = new StringMorph();
|
||||
element.update = function () {
|
||||
this.text = (stage.turtleShepherd.getDimensions());
|
||||
};
|
||||
|
||||
element.newLines = 1;
|
||||
elements.push(element);
|
||||
element.newLines = 1;
|
||||
elements.push('-');
|
||||
|
||||
// too long
|
||||
elements.push(' ');
|
||||
element = new StringMorph();
|
||||
element.color = new Color(255, 0, 0);
|
||||
element.update = function () {
|
||||
this.text = "" + (stage.turtleShepherd.getTooLongStr());
|
||||
};
|
||||
element.columns = 3;
|
||||
element.newColumn = 1;
|
||||
elements.push(element);
|
||||
|
||||
// density warning
|
||||
elements.push('');
|
||||
element = new StringMorph();
|
||||
element.color = new Color(255, 0, 0);
|
||||
element.update = function () {
|
||||
this.text = "" + (stage.turtleShepherd.getDensityWarningStr());
|
||||
};
|
||||
element.columns = 3;
|
||||
element.newColumn = 2;
|
||||
elements.push(element);
|
||||
|
||||
|
||||
elements.push('-');
|
||||
// density warning
|
||||
elements.push('');
|
||||
element = new StringMorph("");
|
||||
element.newLines = 2;
|
||||
elements.push(element);
|
||||
|
||||
|
||||
var toogleShowStitchPointsButton = new ToggleMorph(
|
||||
'checkbox',
|
||||
|
@ -748,7 +777,7 @@ IDE_Morph.prototype.createStatusDisplay = function () {
|
|||
return stage.renderer.showingTurtle;
|
||||
});
|
||||
|
||||
toogleTurtleButton.newLines = 2;
|
||||
toogleTurtleButton.newLines = 1;
|
||||
elements.push(toogleTurtleButton);
|
||||
elements.push('-');
|
||||
|
||||
|
|
|
@ -17,6 +17,8 @@ TurtleShepherd.prototype.init = function() {
|
|||
this.showTurtle = false;
|
||||
this.metric = true;
|
||||
this.pixels_per_millimeter = 5;
|
||||
this.maxLength = 121;
|
||||
this.calcTooLong = true;
|
||||
};
|
||||
|
||||
|
||||
|
@ -34,6 +36,9 @@ TurtleShepherd.prototype.clear = function() {
|
|||
this.steps = 0;
|
||||
this.stitchCount = 0;
|
||||
this.jumpCount = 0;
|
||||
this.density = {};
|
||||
this.tooLongCount = 0;
|
||||
this.densityWarning = false;
|
||||
};
|
||||
|
||||
|
||||
|
@ -57,10 +62,32 @@ TurtleShepherd.prototype.hasSteps = function() {
|
|||
TurtleShepherd.prototype.getStepCount = function() {
|
||||
return this.steps;
|
||||
};
|
||||
|
||||
TurtleShepherd.prototype.getJumpCount = function() {
|
||||
return this.jumpCount;
|
||||
};
|
||||
|
||||
TurtleShepherd.prototype.getTooLongCount = function() {
|
||||
return this.tooLongCount;
|
||||
};
|
||||
|
||||
TurtleShepherd.prototype.getTooLongStr = function() {
|
||||
if (this.tooLongCount > 1)
|
||||
return this.tooLongCount + " are too long!"
|
||||
else if (this.tooLongCount == 1)
|
||||
return this.tooLongCount + " is too long!"
|
||||
else
|
||||
return "";
|
||||
};
|
||||
|
||||
|
||||
TurtleShepherd.prototype.getDensityWarningStr = function() {
|
||||
if (this.densityWarning)
|
||||
return "Density Warning!";
|
||||
else
|
||||
return "";
|
||||
};
|
||||
|
||||
TurtleShepherd.prototype.getDimensions = function() {
|
||||
|
||||
if (this.metric) {
|
||||
|
@ -79,13 +106,13 @@ TurtleShepherd.prototype.getDimensions = function() {
|
|||
|
||||
TurtleShepherd.prototype.getMetricWidth = function() {
|
||||
c = 0.1
|
||||
return ((this.maxX - this.minX)/5 * c).toFixed(2).toString();
|
||||
return ((this.maxX - this.minX)/ this.pixels_per_millimeter * c).toFixed(2).toString();
|
||||
};
|
||||
|
||||
|
||||
TurtleShepherd.prototype.getMetricHeight = function() {
|
||||
c = 0.1
|
||||
return((this.maxY - this.minY)/5 * c).toFixed(2).toString();
|
||||
return((this.maxY - this.minY)/ this.pixels_per_millimeter * c).toFixed(2).toString();
|
||||
};
|
||||
|
||||
|
||||
|
@ -109,12 +136,25 @@ TurtleShepherd.prototype.moveTo= function(x1, y1, x2, y2, penState) {
|
|||
"penDown":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] >= 10)
|
||||
this.densityWarning = true;
|
||||
} else {
|
||||
this.density[d] = 1;
|
||||
}
|
||||
|
||||
console.log(this.density);
|
||||
}
|
||||
this.cache.push(
|
||||
{
|
||||
|
@ -127,8 +167,16 @@ TurtleShepherd.prototype.moveTo= function(x1, y1, x2, y2, penState) {
|
|||
|
||||
this.w = this.maxX - this.minX;
|
||||
this.h = this.maxY - this.minY;
|
||||
|
||||
|
||||
|
||||
if ( this.calcTooLong) {
|
||||
if ( (Math.max(
|
||||
Math.abs(x2 - x1), Math.abs(y2 - y1)
|
||||
) / this.pixels_per_millimeter * 10) / this.maxLength > 1
|
||||
)
|
||||
this.tooLongCount += 1;
|
||||
}
|
||||
|
||||
|
||||
if (!penState)
|
||||
this.jumpCount++;
|
||||
else {
|
||||
|
|
Ładowanie…
Reference in New Issue