diff options
| author | Akshay Nair <phenax5@gmail.com> | 2023-10-29 16:09:56 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2023-10-29 16:09:56 +0530 |
| commit | b6ebba87606d180735994d62e2d71c3fbf0b8763 (patch) | |
| tree | 3aa0ff77d8d3c569be285e911e9ed44f10777b50 /sketches/week-1/mandelbrot.bqn | |
| parent | 95eae658a4845f86e1b6b2c16387a41dd36f9d42 (diff) | |
| download | creative-coding-playground-b6ebba87606d180735994d62e2d71c3fbf0b8763.tar.gz creative-coding-playground-b6ebba87606d180735994d62e2d71c3fbf0b8763.zip | |
feat: week 1 sort-of done? but not really
Diffstat (limited to 'sketches/week-1/mandelbrot.bqn')
| -rw-r--r-- | sketches/week-1/mandelbrot.bqn | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/sketches/week-1/mandelbrot.bqn b/sketches/week-1/mandelbrot.bqn new file mode 100644 index 0000000..e844df8 --- /dev/null +++ b/sketches/week-1/mandelbrot.bqn @@ -0,0 +1,23 @@ +CMul ← { ⟨a, b⟩𝕊⟨c, d⟩: ⟨a×c - b×d, a×d + b×c⟩ } +CMag ← +´×˜ +MandelbrotFn ← +⟜(CMul˜) + +MBValue ← {⟨w, h⟩ 𝕊 ⟨x, y⟩: + p ← 6 × ⟨(x - w÷2)÷w, (y - h÷2)÷h⟩ + iters ← 0 + old ← 0‿0 + CMag p⊸MandelbrotFn •_while_ { + isFinite ← 70 > CMag (𝕩 - old) + old↩𝕩 + iters+↩1 + isFinite ∧ iters < 10 + } 0‿0 +} + +MBGrid ← {dimens 𝕊 grid: {⟨0.7, 0.4, 1⟩ × (dimens MBValue 𝕩) | 255}¨grid} + +{𝕊⟨w, h⟩: + grid ← (>{↕h}¨↕w) ∾¨ h⥊˘↕w + p ← ⟨1, 1⟩ + ⟨w, h⟩ MBGrid grid +} |
