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!
The rule only gets executed if `n` is non-zero. When called recursively, it is implicitly decremented.
Fractal | Axiom | Rules |
---|---|---|
Sierpinski’s | One point | Move the appropriate side-length length 60º and 0º and draw yourself. If n = 0=, become a triangle |
Vonkoch’s | Three points | For each adjacent pair of points, find three more such that a new inline equilateral triangle exists |
Basic Tree | A vertical line | Draw two branches angled theta and -theta in relation to their root |
Pythagoras’ | A horizontal line | Draw 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.
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
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).