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. =)
- https://github.com/reagent-project/reagent-cookbook/tree/master/recipes/canvas-fills-div
- https://piratefsh.github.io/2020/08/08/sierpinski-curve.html
- https://piratefsh.github.io/2020/08/07/koch-tesselation-uncommon-fractal-implementations.html
- https://www.r-bloggers.com/2017/06/a-shiny-app-to-draw-curves-based-on-l-system/
- https://books.google.com/books?id=FsH2DwAAQBAJ&pg=PA67&source=gbs_selected_pages&cad=2#v=onepage&q&f=false
- http://algorithmicbotany.org/papers/
- https://web.dev/canvas-performance/