aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--1-mandelbrot/main.ua20
-rw-r--r--flake.nix7
-rw-r--r--justfile4
-rw-r--r--main.ua5
4 files changed, 29 insertions, 7 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
diff --git a/flake.nix b/flake.nix
index 151edd3..aee510d 100644
--- a/flake.nix
+++ b/flake.nix
@@ -7,8 +7,11 @@
let
pkgs = import nixpkgs { system = "x86_64-linux"; };
in {
- devShells.x86_64-linux.default = pkgs.mkShell {
- buildInputs = [pkgs.uiua];
+ devShells.x86_64-linux.default = with pkgs; mkShell {
+ buildInputs = [
+ uiua
+ just
+ ];
};
};
}
diff --git a/justfile b/justfile
new file mode 100644
index 0000000..0150b34
--- /dev/null
+++ b/justfile
@@ -0,0 +1,4 @@
+
+mandelbrot:
+ uiua run 1-mandelbrot/main.ua
+
diff --git a/main.ua b/main.ua
deleted file mode 100644
index 7b1ef26..0000000
--- a/main.ua
+++ /dev/null
@@ -1,5 +0,0 @@
-ImgW ← &fwa "./output/mandelbrot.png" img "png"
-
-Imgdata ← ⍉⊞<⊞+⇡3∿∩(÷25)⇡240⇡80
-
-ImgW Imgdata