From 49b1cb6328f8344b2c7b83934975a6fd00a0fce3 Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Tue, 11 Feb 2025 18:37:54 +0530 Subject: Refactor dragon curve + add to output --- 2-dragon/main.ua | 30 +++++++++++++++++------------- 2-dragon/output-12.png | Bin 0 -> 36392 bytes 2-dragon/output.png | Bin 1388 -> 36392 bytes 3 files changed, 17 insertions(+), 13 deletions(-) create mode 100644 2-dragon/output-12.png (limited to '2-dragon') diff --git a/2-dragon/main.ua b/2-dragon/main.ua index 86ece69..be47b59 100644 --- a/2-dragon/main.ua +++ b/2-dragon/main.ua @@ -1,18 +1,22 @@ -W ← 200 -H ← 200 -S ← 4 -I ← 2 +W ← 600 # width +H ← 600 # height +S ← 4 # size of segment +I ← 12 # iterations -P ← ℂ: +StartLine ← [(ℂ: (-(÷2 S) ÷2 W) (÷2 H)) (ℂ: (+(÷2 S) ÷2 W) (÷2 H))] +Rotate ← +× ⊙⤚- ℂ: ∿+η ⊙∿. +Dragon ← ⍥(⊂ Rotate η ⊣. ⊙(↘1) ⇌.)I StartLine -PStart ← [(P (-(÷2 S) ÷2 W) (÷2 H)) (P (+(÷2 S) ÷2 W) (÷2 H))] +# Center the image +MinX ← /↧ ◌°ℂ Dragon +MaxX ← /↥ ◌°ℂ Dragon +MinY ← /↧ ◌:°ℂ Dragon +MaxY ← /↥ ◌:°ℂ Dragon +CenteredDragon ← +ℂ: (-MinX ÷2 +MinX -MaxX W) (-MinY ÷2 +MinY -MaxY H) Dragon -RotP ← +× ⊙⤚- P ∿+η ⊙∿. -Dragon ← ⍥(⊂ RotP η ⊣. ⇌.)I PStart -IsOnLine ← <0.01 ⌵- /+ ⊙(⌵-⊃⊢⊣)◡(⌵-) ⊟ -IsOnDragon ← ⊙◌ ≥1 /+ ≡(IsOnLine⊃⊢⊣) ⧈∘ 2 Dragon +IsOnLine ← ◌: <0.01 ⌵- /+ ⊙(⌵-⊃⊢⊣)◡(⌵-) +IsOnDragon ← ≥1 /+ ≡(⨬(0◌)IsOnLine ◡(≤S⌵-⊢)) ⧈∘ 2 CenteredDragon -ToPix ← ⨬(0_0_0)(255_255_255) IsOnDragon - -Img ← ∵ToPix (⍉ ⊞P ⇡W⇡H) +ToPix ← ⨬(0_0_0)(⊂: 0.3_0.05 +0.1 ÷W ◌°ℂ) IsOnDragon. +Img ← ∵ToPix (⍉ ⊞(ℂ:) ⇡W⇡H) &fwa "./2-dragon/output.png" img "png" Img diff --git a/2-dragon/output-12.png b/2-dragon/output-12.png new file mode 100644 index 0000000..aa7b485 Binary files /dev/null and b/2-dragon/output-12.png differ diff --git a/2-dragon/output.png b/2-dragon/output.png index 6c02658..aa7b485 100644 Binary files a/2-dragon/output.png and b/2-dragon/output.png differ -- cgit v1.3.1