From 4f8f2319617e9cd9537eb388bc8ac4f455af49fd Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 21 Feb 2022 23:02:09 +0100 Subject: [PATCH] show error with non positive degrees. fix bug in tatami --- stitchcode/objects.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/stitchcode/objects.js b/stitchcode/objects.js index 8dd35b0a..31bf4c1e 100644 --- a/stitchcode/objects.js +++ b/stitchcode/objects.js @@ -484,8 +484,10 @@ SpriteMorph.prototype.arcRight = function (radius, degrees) { if (degrees % 10 !== 0) { this.turn((degrees % 10)/2); this.forward(((radius * 0.174532) / 10) / (degrees % 10)) - this.turn((degrees % 10)/2 * this.sign) + this.turn((degrees % 10)/2 ) } + } else { + throw new Error('degrees must be positive'); } }; @@ -498,10 +500,12 @@ SpriteMorph.prototype.arcLeft = function (radius, degrees) { this.turn(-5) } if (degrees % 10 !== 0) { - this.turn(-(degrees % 10)/2); + this.turn(-((degrees % 10)/2)); this.forward(((radius * 0.174532) / 10) / (degrees % 10)) - this.turn(-(degrees % 10)/2) + this.turn(-((degrees % 10)/2)) } + } else { + throw new Error('degrees must be positive'); } }; @@ -711,7 +715,7 @@ SpriteMorph.prototype.tatamiForwardEnd = function (steps, width=10) { var alpha = degrees(Math.asin(width/c)); this.turn(90); - this.doMoveForward((c/2)*this.sign); + this.doMoveForward((width/2)*this.sign); this.turn(-90); }