From 3948f4329f2a9eca0f1f56798faf290bbe1f84d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Remko=20Tron=C3=A7on?= Date: Fri, 26 Jan 2024 19:10:46 +0100 Subject: [PATCH] =?UTF-8?q?thurtle:=20Add=20=F0=9F=8C=B1=20example?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/web/thurtle/programs.ts | 41 +++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) 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() }));