thurtle: Tweak examples

This commit is contained in:
Remko Tronçon 2022-05-15 21:49:37 +02:00
parent 629707587a
commit 47b83fc610
2 changed files with 18 additions and 17 deletions

View file

@ -65,10 +65,10 @@ export default [
name: "Flower", name: "Flower",
program: ` program: `
: SQUARE ( n -- ) : SQUARE ( n -- )
4 0 DO 4 0 DO
DUP FORWARD DUP FORWARD
90 RIGHT 90 RIGHT
LOOP LOOP
; ;
: FLOWER ( n -- ) : FLOWER ( n -- )
@ -95,31 +95,32 @@ LOOP
`, `,
}, },
{ {
name: "Square Spiral", name: "Outward Square Spiral",
program: ` program: `
: SPIRAL ( n1 n2 -- ) : SPIRAL ( n1 n2 -- )
OVER 1 < IF 2DROP EXIT THEN OVER 800 > IF 2DROP EXIT THEN
OVER FORWARD OVER FORWARD
DUP RIGHT DUP RIGHT
SWAP 95 100 */ SWAP SWAP 10 + SWAP
RECURSE RECURSE
; ;
450 90 SPIRAL 1 90 SPIRAL
`, `,
}, },
{ {
name: "Crooked Square Spiral", name: "Crooked Outward Square Spiral",
program: ` program: `
: SPIRAL ( n1 n2 -- ) 91 CONSTANT ANGLE
OVER 1 < IF 2DROP EXIT THEN
OVER FORWARD : SPIRAL ( n -- )
DUP RIGHT DUP 800 > IF DROP EXIT THEN
SWAP 95 100 */ SWAP DUP FORWARD
ANGLE RIGHT
10 +
RECURSE RECURSE
; ;
450 91 SPIRAL 1 SPIRAL`,
`,
}, },
].map((e) => ({ ...e, program: e.program.trimStart() })); ].map((e) => ({ ...e, program: e.program.trimStart() }));

View file

@ -326,4 +326,4 @@ document.addEventListener("keydown", (ev) => {
reset(); reset();
loadExample(examples[1].name); loadExample(examples[4].name);