kopia lustrzana https://github.com/backface/turtlestitch
fix bugs with stage scales (applied to forwad, mouse positions)
and bugs in tatami stitchespull/68/head
rodzic
0fc1644036
commit
a42aa51546
|
@ -357,7 +357,7 @@ SpriteMorph.prototype.satinStitch = function (width=10, center=true, autoadjust=
|
|||
}
|
||||
}
|
||||
|
||||
SpriteMorph.prototype.tatamiStitch = function (width=100, interval=30, offset=0, center=false) {
|
||||
SpriteMorph.prototype.tatamiStitch = function (width=100, interval=30, center=false, offset=0) {
|
||||
if (width > 0) {
|
||||
this.stitchtype = "tatami";
|
||||
this.isRunning = true;
|
||||
|
@ -421,7 +421,7 @@ SpriteMorph.prototype.tieStitch = function () {
|
|||
SpriteMorph.prototype.origForward = SpriteMorph.prototype.forward;
|
||||
SpriteMorph.prototype.forward = function (steps) {
|
||||
var dest,
|
||||
dist = steps * this.parent.scale || 0;
|
||||
dist = steps; //* this.parent.scale || 0;
|
||||
stage = this.parentThatIsA(StageMorph);
|
||||
warn = false;
|
||||
|
||||
|
@ -453,13 +453,13 @@ SpriteMorph.prototype.forward = function (steps) {
|
|||
|
||||
SpriteMorph.prototype.forwardByNr = function (totalsteps, steps) {
|
||||
stepsize = totalsteps / steps;
|
||||
|
||||
this.forwardSegemensWithEndCheck(steps, stepsize)
|
||||
};
|
||||
|
||||
SpriteMorph.prototype.forwardBy = function (totalsteps, stepsize) {
|
||||
steps = Math.floor(totalsteps / stepsize);
|
||||
rest = totalsteps - (steps * stepsize);
|
||||
|
||||
this.forwardSegemensWithEndCheck(steps, stepsize)
|
||||
|
||||
if (rest > 0) {
|
||||
|
@ -595,14 +595,16 @@ SpriteMorph.prototype.tatamiForward = function (steps, width=100) {
|
|||
|
||||
// just for move to the next line in 2 bz 10
|
||||
|
||||
var offset = (this.stitchoptions.segment_count % Math.floor(this.stitchoptions.interval / this.stitchoptions.offset)) *
|
||||
this.stitchoptions.offset;
|
||||
var offset = (
|
||||
( this.stitchoptions.segment_count *
|
||||
(this.stitchoptions.offset + this.stitchoptions.interval)
|
||||
) % this.stitchoptions.interval
|
||||
);
|
||||
|
||||
b = Math.max(2, offset + this.stitchoptions.offset / 2)
|
||||
var c = Math.sqrt(steps/2*steps/2 + b * b);
|
||||
var c = Math.sqrt(steps/2*steps/2);
|
||||
var alpha = degrees(Math.asin((steps/2)/c));
|
||||
|
||||
var distance = width - b - offset;
|
||||
var distance = width - offset;
|
||||
var interval = this.stitchoptions.interval;
|
||||
var count = Math.floor(distance / interval);
|
||||
var rest = distance - (count * interval);
|
||||
|
@ -623,14 +625,16 @@ SpriteMorph.prototype.tatamiForward = function (steps, width=100) {
|
|||
|
||||
this.stitchoptions.segment_count+=1;
|
||||
|
||||
offset = (this.stitchoptions.segment_count % Math.floor(this.stitchoptions.interval / this.stitchoptions.offset)) *
|
||||
this.stitchoptions.offset;
|
||||
var offset = (
|
||||
( this.stitchoptions.segment_count *
|
||||
(this.stitchoptions.offset + this.stitchoptions.interval)
|
||||
) % this.stitchoptions.interval
|
||||
);
|
||||
|
||||
b = Math.max(2, offset + this.stitchoptions.offset / 2)
|
||||
c = Math.sqrt(steps/2*steps/2 + b * b);
|
||||
c = Math.sqrt(steps/2*steps/2);
|
||||
alpha = degrees(Math.asin((steps/2)/c));
|
||||
|
||||
distance = width - b - offset;
|
||||
distance = width - offset;
|
||||
interval = this.stitchoptions.interval;
|
||||
count = Math.floor(distance / interval);
|
||||
rest = distance - (count * interval);
|
||||
|
@ -659,6 +663,7 @@ SpriteMorph.prototype.tatamiForwardStart = function (steps, width=10) {
|
|||
var c = Math.sqrt(steps*steps + width * width);
|
||||
var alpha = degrees(Math.asin(width/c));
|
||||
|
||||
console.log(width);
|
||||
this.turn(-90);
|
||||
this.doMoveForward(width/2);
|
||||
this.turn(90);
|
||||
|
@ -2619,6 +2624,10 @@ StageMorph.prototype.initCamera = function () {
|
|||
this.applyZoom();
|
||||
};
|
||||
|
||||
myself.camera.getZoom = function () {
|
||||
return this.zoomFactor;
|
||||
};
|
||||
|
||||
myself.camera.applyZoom = function () {
|
||||
var zoom = myself.camera ? myself.camera.zoomFactor : 2,
|
||||
width = Math.max(myself.width(), 480),
|
||||
|
|
|
@ -8,8 +8,13 @@ Process.prototype.reportMouseX = function () {
|
|||
if (stage) {
|
||||
world = stage.world();
|
||||
if (world) {
|
||||
var factor = stage.renderer.isParallelProjection ? 65 / stage.camera.zoomFactor : stage.controls.object.position.length() / 10;
|
||||
return ((world.hand.position().x - stage.center().x)) / stage.camera.zoomFactor * 2 + stage.controls.center.x;
|
||||
return (
|
||||
(world.hand.position().x - stage.center().x)
|
||||
/ stage.camera.zoomFactor
|
||||
/ stage.scale
|
||||
* 2
|
||||
+ stage.controls.center.x
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -23,8 +28,13 @@ Process.prototype.reportMouseY = function () {
|
|||
if (stage) {
|
||||
world = stage.world();
|
||||
if (world) {
|
||||
var factor = stage.renderer.isParallelProjection ? 65 / stage.camera.zoomFactor : stage.controls.object.position.length() / 10;
|
||||
return ((stage.center().y - world.hand.position().y)) / stage.camera.zoomFactor * 2 + stage.controls.center.y;
|
||||
return (
|
||||
(stage.center().y - world.hand.position().y)
|
||||
/ stage.camera.zoomFactor
|
||||
/ stage.scale
|
||||
* 2
|
||||
+ stage.controls.center.y
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue