Skip to content

Instantly share code, notes, and snippets.

@jdh30
Created November 21, 2022 02:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jdh30/5977c4dfa7c89748c195d4418b20507b to your computer and use it in GitHub Desktop.
Save jdh30/5977c4dfa7c89748c195d4418b20507b to your computer and use it in GitHub Desktop.
Iterative Fractal System Fern
let ff ((rx, ry), i) =
if i=3000 then None else
let ((a,b),(c,d)), (vx,vy) =
let r = Random.next 100 in
if r < 75 then ((85, 4), (-4, 85)), (0, 160)
else if r < 88 then ((-15, 28), (-26, 24)), (0, 44)
else if r < 98 then ((20, -26), (23, 22)), (0, 160)
else ((0, 0), (0, 16)), (0, 0) in
Some((rx, ry), (((a*rx+b*ry+vx)/100, (c*rx+d*ry+vy)/100), i+1))
let () = Array.unfold ff ((0,0), 0) @ Chart.scatter "" "" ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment