From 47b83fc6103c5b333d94ff02b31f25fe8280fed2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Remko=20Tron=C3=A7on?= Date: Sun, 15 May 2022 21:49:37 +0200 Subject: [PATCH] thurtle: Tweak examples --- src/web/thurtle/examples.ts | 33 +++++++++++++++++---------------- src/web/thurtle/thurtle.tsx | 2 +- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/src/web/thurtle/examples.ts b/src/web/thurtle/examples.ts index 2b819b3..f1aee4f 100644 --- a/src/web/thurtle/examples.ts +++ b/src/web/thurtle/examples.ts @@ -65,10 +65,10 @@ export default [ name: "Flower", program: ` : SQUARE ( n -- ) -4 0 DO - DUP FORWARD - 90 RIGHT -LOOP + 4 0 DO + DUP FORWARD + 90 RIGHT + LOOP ; : FLOWER ( n -- ) @@ -95,31 +95,32 @@ LOOP `, }, { - name: "Square Spiral", + name: "Outward Square Spiral", program: ` : SPIRAL ( n1 n2 -- ) - OVER 1 < IF 2DROP EXIT THEN + OVER 800 > IF 2DROP EXIT THEN OVER FORWARD DUP RIGHT - SWAP 95 100 */ SWAP + SWAP 10 + SWAP RECURSE ; -450 90 SPIRAL +1 90 SPIRAL `, }, { - name: "Crooked Square Spiral", + name: "Crooked Outward Square Spiral", program: ` -: SPIRAL ( n1 n2 -- ) - OVER 1 < IF 2DROP EXIT THEN - OVER FORWARD - DUP RIGHT - SWAP 95 100 */ SWAP +91 CONSTANT ANGLE + +: SPIRAL ( n -- ) + DUP 800 > IF DROP EXIT THEN + DUP FORWARD + ANGLE RIGHT + 10 + RECURSE ; -450 91 SPIRAL -`, +1 SPIRAL`, }, ].map((e) => ({ ...e, program: e.program.trimStart() })); diff --git a/src/web/thurtle/thurtle.tsx b/src/web/thurtle/thurtle.tsx index d461f6f..b3ee43b 100644 --- a/src/web/thurtle/thurtle.tsx +++ b/src/web/thurtle/thurtle.tsx @@ -326,4 +326,4 @@ document.addEventListener("keydown", (ev) => { reset(); -loadExample(examples[1].name); +loadExample(examples[4].name);