sunflowerseastar / fractals

fractals on canvas

Home Page:https://fractals.sunflowerseastar.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

quick start

# run
lein fig:build
# check connection
(js/alert "Am I connected?")

# clean and prod build
lein clean
lein fig:min

diagrams

(generate-pascal-triangle 5) => ...
[[1]
 [1 1]
 [1 2 1]
 [1 3 3 1]
 [1 4 6 4 1]
 [1 5 10 10 5 1]
 [1 6 15 20 15 6 1]]

(generate-sierpinski-triangle 5) => ...
[[1]
 [1 1]
 [1 0 1]
 [1 1 1 1]
 [1 0 0 0 1]]

Vertical, aka plot-straight-along-the-bottom

“Vertical” plot type, with the triangle starting at the middle top, and widening downward until the bottom straight edge of the triangle is at the bottom of the canvas:

[[1]
 [1 1]
 [1 0 1]
 [1 1 1 1]
 [1 0 0 0 1]]

    1       [4,0]
   1 1      [3,1] [5,1]
  1 0 1     [2,2] [6,2]
 1 1 1 1    [1,3] [3,3] [5,3] [7,3]
1 0 0 0 1   [0,4] [8,4]

Note that this way means that each plot point will need to be a 2x2 rectangle:

    11       [4,0]
    11
   1111      [3,2], [5,2]
   1111
  11  11     [2,4], [6,4]
  11  11
 11111111    [1,6], [3,6], [5,6], [7,6]
 11111111
11      11   [0,8], [8,8]
11      11

Horizontal, aka plot-straight-along-the-top

“Horizontal” plot type, with one of the straight triangle edges against the top of the canvas:

[[1]
 [1 1]
 [1 0 1]
 [1 1 1 1]
 [1 0 0 0 1]
 [a b c d e f]]

1 1 1 1 1 a
  1 0 1 0 b
    1 1 0 c
      1 0 d
        1 e
          f

This is from Clojure Data Structures and Algorithms Cookbook, by Rakif Naccache, section Using Pascal’s triangle to draw fractals.

reference

This project was inspired by and started from Clojure Data Structures and Algorithms Cookbook, by Rakif Naccache. Thank you for the great book, Rafik. =)

About

fractals on canvas

https://fractals.sunflowerseastar.com

License:Eclipse Public License 1.0


Languages

Language:Clojure 90.2%Language:CSS 8.9%Language:HTML 0.9%