https://github.com/morphx666/lsysint
A simple L-System parser, interpreter and renderer, written in VB.NET
https://github.com/morphx666/lsysint
lsystem lsystem-parser
Last synced: 3 months ago
JSON representation
A simple L-System parser, interpreter and renderer, written in VB.NET
- Host: GitHub
- URL: https://github.com/morphx666/lsysint
- Owner: morphx666
- License: mit
- Created: 2016-12-29T04:50:41.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2025-12-17T00:48:50.000Z (6 months ago)
- Last Synced: 2025-12-20T07:36:23.255Z (6 months ago)
- Topics: lsystem, lsystem-parser
- Language: Visual Basic .NET
- Size: 49.8 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# LSysInt
A simple L-System parser, interpreter and renderer, written in VB.NET
This is, in fact, a very rough and simple interpreter to render [L-system](https://en.wikipedia.org/wiki/L-system) formulas.

The grammar is very similar to that of the more mature project [LILiS](https://github.com/Drup/LILiS), with a few distinctions:
- A curve is defined using a name with its body enclosed between curly brackets.
- Parameters names must always end with a colon.
- So far, only eigth parameters are supported:
- **level**: defines the maximum recursion level
- **axiom**: defines the initial conditions
- **rule**: defines one or more rules to be applied to the axiom
- **angle**: defines the default angle when none is specified
- **offsetX**: defines a rendering origin offset in the horizontal direction
- **offsetY**: defines a rendering origin offset in the vertical direction
- **length**: defines the default length of a segment when none is specified
- **constant**: defines a simple string-based substitution (no function support yet)
- Although LSysInt does not currently support "definitions", most of the time these can be represented through one or more rules.
- These are the currently supported internal functions:
- **F(x)**: move forward and draw `x` amount of pixels
- **B(x)**: move backwards and draw `x` amount of pixels
- **f(x)**: move forward `x` amount of pixels
- **+(x)**: increase the angle by `x` amount
- **-(x)**: decrease the angle by `x` amount
- **[**: save current vector state
- **]**: restore saved vector state
- **%(r, g, b, a)**: set vector color
Here's a sample code to render the dragon curve up to its 13th iteration:
```
Dragon {
level: 13
axiom: -(45) f(0.47) * F(0.6) X(0.6)
rule: X(n) = X(n/Sqrt(2)) +(90) Y(n/Sqrt(2)) F(n/Sqrt(2)) +(90)
rule: Y(n) = -(90) F(n/Sqrt(2)) X(n/Sqrt(2)) -(90) Y(n/Sqrt(2))
rule: F(n) = F(n/Sqrt(2))
rule: * = * -(45)
}
```
