kopia lustrzana https://github.com/backface/turtlestitch
imperial unit toggle
rodzic
8f35b53392
commit
77a08a6da7
|
@ -789,8 +789,24 @@ IDE_Morph.prototype.createStatusDisplay = function () {
|
|||
function () {
|
||||
return stage.isFastTracked;
|
||||
});
|
||||
toggleTurboButton.newLines = 3;
|
||||
toggleTurboButton.columns = 4;
|
||||
toggleTurboButton.newColumn = 3;
|
||||
elements.push(toggleTurboButton);
|
||||
|
||||
var toggleUnitButton = new ToggleMorph(
|
||||
'checkbox',
|
||||
null,
|
||||
function () {
|
||||
stage.turtleShepherd.toggleMetric();
|
||||
stage.scene.grid.draw();
|
||||
stage.renderer.changed = true;
|
||||
},
|
||||
'Imperial units',
|
||||
function () {
|
||||
return !stage.turtleShepherd.isMetric();
|
||||
});
|
||||
toggleUnitButton.newLines = 3;
|
||||
elements.push(toggleUnitButton);
|
||||
|
||||
var downloadSVGButton = new PushButtonMorph(
|
||||
null,
|
||||
|
|
|
@ -386,8 +386,14 @@ StageMorph.prototype.initScene = function () {
|
|||
|
||||
this.lines = [];
|
||||
|
||||
limit = this.interval.x * 50;
|
||||
|
||||
c = 2.54;
|
||||
if (myself.turtleShepherd.isMetric()) {
|
||||
this.interval = new Point(5, 5);
|
||||
limit = this.interval.x * 50;
|
||||
} else {
|
||||
this.interval = new Point(Math.round(5 * c), Math.round(5 * c));
|
||||
limit = Math.round(this.interval.x * 50 * c);
|
||||
}
|
||||
for (x = -limit / this.interval.x; x <= limit / this.interval.x; x++) {
|
||||
p1 = new THREE.Vector3(x * this.interval.x, -limit, 0);
|
||||
p2 = new THREE.Vector3(x * this.interval.x, limit, 0);
|
||||
|
@ -404,7 +410,11 @@ StageMorph.prototype.initScene = function () {
|
|||
this.lines.push(l);
|
||||
}
|
||||
|
||||
limit = this.interval.x * 200;
|
||||
if (myself.turtleShepherd.isMetric())
|
||||
limit = this.interval.x * 200;
|
||||
else
|
||||
limit = Math.round(this.interval.x * 200 * c);
|
||||
|
||||
|
||||
for (x = -limit/10 / this.interval.x; x <= limit/10 / this.interval.x; x++) {
|
||||
p1 = new THREE.Vector3(x * this.interval.x * 10, -limit,0);
|
||||
|
|
|
@ -15,8 +15,10 @@ TurtleShepherd.prototype.init = function() {
|
|||
this.showStitches = false;
|
||||
this.showGrid = false;
|
||||
this.showTurtle = false;
|
||||
this.metric = true;
|
||||
};
|
||||
|
||||
|
||||
TurtleShepherd.prototype.clear = function() {
|
||||
this.cache = [];
|
||||
this.w = 0;
|
||||
|
@ -33,6 +35,20 @@ TurtleShepherd.prototype.clear = function() {
|
|||
this.jumpCount = 0;
|
||||
};
|
||||
|
||||
|
||||
TurtleShepherd.prototype.toggleMetric = function() {
|
||||
return this.metric = !this.metric;
|
||||
};
|
||||
|
||||
TurtleShepherd.prototype.setMetric = function(b) {
|
||||
this.metric = b;
|
||||
};
|
||||
|
||||
TurtleShepherd.prototype.isMetric = function() {
|
||||
return this.metric;
|
||||
};
|
||||
|
||||
|
||||
TurtleShepherd.prototype.hasSteps = function() {
|
||||
return this.steps > 0;
|
||||
};
|
||||
|
@ -45,9 +61,17 @@ TurtleShepherd.prototype.getJumpCount = function() {
|
|||
};
|
||||
|
||||
TurtleShepherd.prototype.getDimensions = function() {
|
||||
w= ((this.maxX - this.minX)/5).toFixed(2).toString();
|
||||
h= ((this.maxY - this.minY)/5).toFixed(2).toString();
|
||||
return w + " x " + h + " mm";
|
||||
|
||||
if (this.metric) {
|
||||
c = 1;
|
||||
unit = "mm";
|
||||
} else {
|
||||
c = 0.03937;
|
||||
unit = "in";
|
||||
}
|
||||
w= ((this.maxX - this.minX)/5 * c).toFixed(2).toString();
|
||||
h= ((this.maxY - this.minY)/5 * c).toFixed(2).toString();
|
||||
return w + " x " + h + " " + unit;
|
||||
};
|
||||
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue