kopia lustrzana https://github.com/backface/turtlestitch
arc blocks
rodzic
863969c99f
commit
18aa8d7030
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
VERSION="2.7.2"
|
VERSION="2.7.3"
|
||||||
|
|
||||||
// get debug mode
|
// get debug mode
|
||||||
url = new URL(window.location.href);
|
url = new URL(window.location.href);
|
||||||
|
|
|
@ -181,7 +181,6 @@ SpriteMorph.prototype.addJumpLine = function(x1, y1, x2, y2) {
|
||||||
];
|
];
|
||||||
var g = new MeshLine();
|
var g = new MeshLine();
|
||||||
g.setGeometry( geometry );
|
g.setGeometry( geometry );
|
||||||
|
|
||||||
this.cache.addGeometry('meshline', g, [x1,y1,x2,y2, color, this.color.a]);
|
this.cache.addGeometry('meshline', g, [x1,y1,x2,y2, color, this.color.a]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -314,7 +313,6 @@ SpriteMorph.prototype.crossStitch = function (length, width=10, center=true, aut
|
||||||
width: width,
|
width: width,
|
||||||
center: center,
|
center: center,
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -462,7 +460,6 @@ SpriteMorph.prototype.forward = function (steps) {
|
||||||
|
|
||||||
SpriteMorph.prototype.forwardByNr = function (totalsteps, steps) {
|
SpriteMorph.prototype.forwardByNr = function (totalsteps, steps) {
|
||||||
stepsize = totalsteps / steps;
|
stepsize = totalsteps / steps;
|
||||||
|
|
||||||
this.forwardSegemensWithEndCheck(steps, stepsize)
|
this.forwardSegemensWithEndCheck(steps, stepsize)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -474,9 +471,41 @@ SpriteMorph.prototype.forwardBy = function (totalsteps, stepsize) {
|
||||||
if (rest > 0) {
|
if (rest > 0) {
|
||||||
this.moveforward(rest);
|
this.moveforward(rest);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
SpriteMorph.prototype.arcRight = function (radius, degrees) {
|
||||||
|
if (degrees > 0) {
|
||||||
|
for (var n=0; n < Math.floor(degrees / 10); n++) {
|
||||||
|
this.turn(5);
|
||||||
|
this.forward(radius * 0.174532)
|
||||||
|
this.turn(5)
|
||||||
|
}
|
||||||
|
if (degrees % 10 !== 0) {
|
||||||
|
this.turn((degrees % 10)/2);
|
||||||
|
this.forward(((radius * 0.174532) / 10) / (degrees % 10))
|
||||||
|
this.turn((degrees % 10)/2 * this.sign)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
SpriteMorph.prototype.arcLeft = function (radius, degrees) {
|
||||||
|
if (degrees > 0) {
|
||||||
|
for (var n=0; i < Math.floor(degrees / 10); n++) {
|
||||||
|
this.turn(-5);
|
||||||
|
this.forward(radius * 0.174532)
|
||||||
|
this.turn(-5)
|
||||||
|
}
|
||||||
|
if (degrees % 10 !== 0) {
|
||||||
|
this.turn(-(degrees % 10)/2);
|
||||||
|
this.forward(((radius * 0.174532) / 10) / (degrees % 10))
|
||||||
|
this.turn(-(degrees % 10)/2)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
SpriteMorph.prototype.forwardSegemensWithEndCheck = function(steps, stepsize) {
|
SpriteMorph.prototype.forwardSegemensWithEndCheck = function(steps, stepsize) {
|
||||||
for(i=0;i<steps;i++) {
|
for(i=0;i<steps;i++) {
|
||||||
if (this.stitchtype == "tatami" && i == 0 && this.stitchoptions.center)
|
if (this.stitchtype == "tatami" && i == 0 && this.stitchoptions.center)
|
||||||
|
@ -1423,6 +1452,22 @@ SpriteMorph.prototype.initBlocks = function () {
|
||||||
spec: 'go to x: %n y: %n in %n',
|
spec: 'go to x: %n y: %n in %n',
|
||||||
defaults: [0, 0, 10]
|
defaults: [0, 0, 10]
|
||||||
};
|
};
|
||||||
|
this.blocks.arcRight =
|
||||||
|
{
|
||||||
|
only: SpriteMorph,
|
||||||
|
type: 'command',
|
||||||
|
category: 'motion',
|
||||||
|
spec: 'arc $turnRight radius: %n degress: %n ',
|
||||||
|
defaults: [50, 30]
|
||||||
|
};
|
||||||
|
this.blocks.arcLeft =
|
||||||
|
{
|
||||||
|
only: SpriteMorph,
|
||||||
|
type: 'command',
|
||||||
|
category: 'motion',
|
||||||
|
spec: 'arc $turnLeft radius: %n degress: %n ',
|
||||||
|
defaults: [50, 30]
|
||||||
|
};
|
||||||
this.blocks.pointTowards =
|
this.blocks.pointTowards =
|
||||||
{
|
{
|
||||||
only: SpriteMorph,
|
only: SpriteMorph,
|
||||||
|
@ -1829,6 +1874,9 @@ SpriteMorph.prototype.blockTemplates = function (category) {
|
||||||
blocks.push(block('doGotoObject'));
|
blocks.push(block('doGotoObject'));
|
||||||
blocks.push(block('reportRandomPosition'));
|
blocks.push(block('reportRandomPosition'));
|
||||||
blocks.push('-');
|
blocks.push('-');
|
||||||
|
blocks.push(block('arcRight'));
|
||||||
|
blocks.push(block('arcLeft'));
|
||||||
|
blocks.push('-');
|
||||||
blocks.push(block('changeXPosition'));
|
blocks.push(block('changeXPosition'));
|
||||||
blocks.push(block('setXPosition'));
|
blocks.push(block('setXPosition'));
|
||||||
blocks.push(block('changeYPosition'));
|
blocks.push(block('changeYPosition'));
|
||||||
|
|
Ładowanie…
Reference in New Issue