https://github.com/sameer/lsys
L-systems in Rust
https://github.com/sameer/lsys
Last synced: 2 months ago
JSON representation
L-systems in Rust
- Host: GitHub
- URL: https://github.com/sameer/lsys
- Owner: sameer
- License: mit
- Created: 2019-04-20T23:52:31.000Z (almost 7 years ago)
- Default Branch: main
- Last Pushed: 2024-08-19T06:05:34.000Z (over 1 year ago)
- Last Synced: 2025-03-24T18:11:40.154Z (about 1 year ago)
- Language: Rust
- Homepage: https://sameer.github.io/lsys/
- Size: 1.27 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# L-systems in Rust
Render [L-systems](https://en.wikipedia.org/wiki/L-system) as [SVGs](https://en.wikipedia.org/wiki/SVG) using [Rust](https://www.rust-lang.org/) and [Cairo](https://www.cairographics.org/).
Some useful resources on getting started:
- https://en.wikipedia.org/wiki/L-system
- https://fedimser.github.io/l-systems.html
- https://paulbourke.net/fractals/lsys/
## Usage
This tool has a command line interface:
```
Visualize 2D L-Systems with SVGs.
Usage: lsys [OPTIONS] --width --height [RULES]...
Arguments:
Initial string
Variables that should be treated as a stroke and drawn
Turn angle in degrees
Number of times the rules will run
[RULES]... Rules for replacing characters with a new string (i.e. "F=>F+F")
Options:
--width Width of the SVG Canvas in millimeters
--height Height of the SVG Canvas in millimeters
-o, --out Path to write the SVG to
-h, --help Print help
-V, --version Print version
```
To draw four iterations of the [Koch snowflake](https://en.wikipedia.org/wiki/Koch_snowflake) on a 100mm x 100m SVG:
```
cargo run --release -- --width 100 --height 100 'F++F++F' 'F' 60 4 'F=>F-F++F-F' -o out.svg
```
## Examples
Many of the systems below come from [Paul Bourke's site](http://paulbourke.net/fractals/lsys/).
### Sierpinski Triangle

### Sierpinski Arrowhead

### Koch Curve

### Dragon Curve

### Fractal Plant

### Moore Curve

### Hilbert Curve

### Sierpinski Carpet

### Koch Snowflake

### Hexagonal Gosper

### Kolam

### Crystal
