diff --git a/src/web/thurtle/programs.ts b/src/web/thurtle/programs.ts index 596aa48..2e74255 100644 --- a/src/web/thurtle/programs.ts +++ b/src/web/thurtle/programs.ts @@ -202,6 +202,47 @@ HERE RND ! 1 SETPENSIZE SIZE 0 PLANT +`, + }, + { + name: "🌱", + isExample: true, + program: ` +450 CONSTANT +7 CONSTANT +160 CONSTANT +HEX 006A47 DECIMAL CONSTANT 🟩 +HEX 825E5C DECIMAL CONSTANT 🟫 + +VARIABLE RND +134348 RND ! + +: RANDOM ( -- n ) + RND @ 75 * 74 + 65537 MOD + DUP RND ! +; + +: CHOOSE ( n1 -- n2 ) + RANDOM 65537 */MOD SWAP DROP +; + +: 🌱 ( size angle -- ) + OVER 10 < IF 2DROP EXIT THEN + OVER 50 / 1 MAX SETPENSIZE + OVER 50 > IF 🟫 ELSE 🟩 THEN SETPENCOLOR + DUP ➡️ + OVER ⬆️ + 0 DO + OVER 2/ + CHOOSE 2/ - + RECURSE + LOOP + PENUP SWAP ⬇️ PENDOWN + ⬅️ +; + + 0 🌱 +HIDETURTLE `, }, ].map((e) => ({ ...e, program: e.program.trimStart() }));