aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.envrc1
-rw-r--r--.gitignore1
-rw-r--r--.local.lua13
-rw-r--r--1-mandelbrot/main.ua20
-rw-r--r--flake.lock27
-rw-r--r--flake.nix17
-rw-r--r--justfile4
7 files changed, 83 insertions, 0 deletions
diff --git a/.envrc b/.envrc
new file mode 100644
index 0000000..3550a30
--- /dev/null
+++ b/.envrc
@@ -0,0 +1 @@
+use flake
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..ea1472e
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+output/
diff --git a/.local.lua b/.local.lua
new file mode 100644
index 0000000..3835641
--- /dev/null
+++ b/.local.lua
@@ -0,0 +1,13 @@
+-- My repl config: https://github.com/phenax/neovim-config/blob/main/lua/phenax/repl.lua
+--- @type table
+Repl = Repl
+
+Repl.replModes.uiua = {
+ config = {
+ command = 'uiua repl',
+ clear_screen = false,
+ width = function(w) return w * 0.4 end,
+ }
+}
+
+Repl.apply_repl_mode('uiua')
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.lock b/flake.lock
new file mode 100644
index 0000000..34d3333
--- /dev/null
+++ b/flake.lock
@@ -0,0 +1,27 @@
+{
+ "nodes": {
+ "nixpkgs": {
+ "locked": {
+ "lastModified": 1739020877,
+ "narHash": "sha256-mIvECo/NNdJJ/bXjNqIh8yeoSjVLAuDuTUzAo7dzs8Y=",
+ "owner": "nixos",
+ "repo": "nixpkgs",
+ "rev": "a79cfe0ebd24952b580b1cf08cd906354996d547",
+ "type": "github"
+ },
+ "original": {
+ "owner": "nixos",
+ "ref": "nixos-unstable",
+ "repo": "nixpkgs",
+ "type": "github"
+ }
+ },
+ "root": {
+ "inputs": {
+ "nixpkgs": "nixpkgs"
+ }
+ }
+ },
+ "root": "root",
+ "version": 7
+}
diff --git a/flake.nix b/flake.nix
new file mode 100644
index 0000000..aee510d
--- /dev/null
+++ b/flake.nix
@@ -0,0 +1,17 @@
+{
+ inputs = {
+ nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
+ };
+
+ outputs = { self, nixpkgs }:
+ let
+ pkgs = import nixpkgs { system = "x86_64-linux"; };
+ in {
+ 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
+