aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2025-02-11 18:37:54 +0530
committerAkshay Nair <phenax5@gmail.com>2025-02-11 18:38:10 +0530
commit49b1cb6328f8344b2c7b83934975a6fd00a0fce3 (patch)
tree06a2a6eb96c42986a1ab0e6b833b17ec567a0468
parent9cf999f802b30a50453af430b3764ebc2282376b (diff)
downloaduiua-creative-coding-49b1cb6328f8344b2c7b83934975a6fd00a0fce3.tar.gz
uiua-creative-coding-49b1cb6328f8344b2c7b83934975a6fd00a0fce3.zip
Refactor dragon curve + add to output
Diffstat (limited to '')
-rw-r--r--2-dragon/main.ua30
-rw-r--r--2-dragon/output-12.pngbin0 -> 36392 bytes
-rw-r--r--2-dragon/output.pngbin1388 -> 36392 bytes
-rw-r--r--README.md4
4 files changed, 20 insertions, 14 deletions
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
--- /dev/null
+++ b/2-dragon/output-12.png
Binary files differ
diff --git a/2-dragon/output.png b/2-dragon/output.png
index 6c02658..aa7b485 100644
--- a/2-dragon/output.png
+++ b/2-dragon/output.png
Binary files differ
diff --git a/README.md b/README.md
index b6e41f1..df9bade 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,6 @@
# Playing with [uiua](https://www.uiua.org/)
-![mandelbrot fractal](./1-mandelbrot/output-1080.png)
+| | |
+|---|---|
+| ![mandelbrot fractal](./1-mandelbrot/output-1080.png) | ![dragon curve](./2-dragon/output-12.png) |