- Options

# Fern 1

This Fern is an L-System Fractal. It is generated by the L-System Algorithm with the following settings:

```
const fern1: Ruleset = {
color: "#adff00",
minIterations: 1,
maxIterations: 8,
axiom: "X",
replace: {
X: "F+[[X]-X]-F[-FX]+X",
F: "FF",
},
angle: -25,
initLength: (ctx) => ctx.height * 0.37,
initTranslation: (ctx) => [ctx.width / 2, ctx.height],
divideFactor: 2,
};
```

Ferns are cool, and they are one of the original applications of L-Systems. There is a great book out there called ABOP - The Algorithmic Beauty of Plants. It covers how to model plants with algorithms in-depth and incidentally, and also has a long section on how to use L-Systems to generate grasses, bushes, trees and ferns.

This fractal, by its nature as an L-System, is also related to all the other L-System Fractals. A few you can check out: Hilbert Curve, Sierpinski Triangle, and the Lévy Curve.

You can also check out the other plant-like structures from the Fractal Garden – the Barnsley Fern and the Fractal Canopy.

The alphabet to instructions set used to draw this fractal are the same as for the other L-Systems:

```
const drawRules: Record<string, () => void> = {
V: () => {},
W: () => {},
X: () => {},
Y: () => {},
Z: () => {},
G: drawForward,
F: drawForward,
f: () => ctx.translate(0, -len),
"+": () => ctx.rotate(angle * rotationDirection),
"-": () => ctx.rotate(angle * -rotationDirection),
"|": () => ctx.rotate(180),
"[": () => ctx.push(),
"]": () => ctx.pop(),
"#": () => (ctx.lineWidth = weight += weightIncrement) ,
"!": () => (ctx.lineWidth = weight -= weightIncrement) ,
">": () => (len *= scale),
"<": () => (len /= scale),
"&": () => (rotationDirection = -rotationDirection),
"(": () => (angle += angleIncrement),
")": () => (angle -= angleIncrement),
};
```