aboutsummaryrefslogtreecommitdiff
path: root/1-mandelbrot
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2025-02-09 21:49:50 +0530
committerAkshay Nair <phenax5@gmail.com>2025-02-09 21:51:56 +0530
commit6a567713303530d8c71bd5c83a7f19bd992de6d7 (patch)
treefa524a7f6c03c8e37bf636e148bfe0a2c6c0904f /1-mandelbrot
parent2b5ac273c2adee5327f58fb34ac30b66da917347 (diff)
downloaduiua-creative-coding-6a567713303530d8c71bd5c83a7f19bd992de6d7.tar.gz
uiua-creative-coding-6a567713303530d8c71bd5c83a7f19bd992de6d7.zip
Add mandelbrot fractal generator
Diffstat (limited to '1-mandelbrot')
-rw-r--r--1-mandelbrot/main.ua20
1 files changed, 20 insertions, 0 deletions
diff --git a/1-mandelbrot/main.ua b/1-mandelbrot/main.ua
new file mode 100644
index 0000000..ed2a132
--- /dev/null
+++ b/1-mandelbrot/main.ua
@@ -0,0 +1,20 @@
+W ← 400 # width
+H ← 300 # height
+S ← 0.4 # scale
+I ← 30 # max iterations
+Ox ← ÷3 W # offset x
+Oy ← 0 # offset y
+
+ToPixel ← ⍣(
+ 0.18_0.2_0.25_1 ⍤.=I
+| 0.92_0.93_0.96_1 ⍤.≥20
+| 0.37_0.5_0.67_1 ⍤.>13
+| 0.64_0.75_0.55_1 ⍤.>11
+| 0.74_0.38_0.41_1 ⍤.>8
+| 0_0_0_0
+)
+
+Iterations ← ◌:◌: ⌵ ⍢(⊙(+⊙.×.) +1|× ⊙(<100⌵) <I) 0 (ℂ 0 0)
+Img ← ∵(ToPixel Iterations) ⊞ℂ ∩(÷S -0.5 ÷H) ⊓(-Oy)(-Ox) ⇡H⇡W
+
+&fwa "./output/mandelbrot.png" img "png" Img