Skip to content

Latest commit

 

History

History
47 lines (33 loc) · 2.6 KB

README.org

File metadata and controls

47 lines (33 loc) · 2.6 KB

Svg Fractal Generator

This Rust library offers functions that, given the iteration count and extra fractal-dependent variables, return a String containing the raw svg content. It mainly targets wasm for reasonably (for some definition of reasonable) easy use in my site. Fractals included so far include:

  • Sierpinski’s triangle
  • Vonkoch’s snowflake
  • Basic Tree
  • Pythegoras’ tree
  • All of System L’s ones that may be drawn by drawing/advancing/rotating only (for now)

With more to come!

Basic definitions

The rule only gets executed if `n` is non-zero. When called recursively, it is implicitly decremented.

FractalAxiomRules
Sierpinski’sOne pointMove the appropriate side-length length 60º and 0º and draw yourself. If n = 0=, become a triangle
Vonkoch’sThree pointsFor each adjacent pair of points, find three more such that a new inline equilateral triangle exists
Basic TreeA vertical lineDraw two branches angled theta and -theta in relation to their root
Pythagoras’A horizontal lineDraw a square whose base is the line. Draw a triangle on top such that one of the angles is theta and the opposite one is 90º. Repeat using the other triangle’s edges as roots

There’s also System L, which is a fractal generator. The site includes examples, and so does the Wikipedia Page.

Usage

Clone it, obviously

git clone https://github.com/amatgil/KochSnowflake

Compile the wasm:

just web # Requires just to be installed (cargo install just)

The justfile contains some other convenience functions, not strictly necessary. The commands inside of it can be executed manually

License

This project and all files contained therein and licensed under the [GNU GPLv3](https://www.gnu.org/licenses/gpl-3.0.txt) license (see [COPYING](COPYING) file).