lindenmayer2
TypeScript icon, indicating that this package has built-in type declarations

0.5.3 • Public • Published

Lindenmayer2

Stochastic, Parametric and context-sensitive l-systems with complex symbols.

This lindenmayer-system implementation is not driven by a text-based representation (and manipulation) of state and therefore systems are not limited by needing to be text-encodable. Symbol parameters can be instances of classes for example.

The drawback of this approach is that the production rules and outputs are of course not so easily to read as a simple text representation of state.

Example

import { LSystem, matchSymbol } from "lindenmayer2";

const system = new LSystem({
  initial: [{ symbol: "A" }],
  rules: [
    {
      id: "A",
      condition: matchSymbol("A"),
      successor: [
        {
          symbol: "A",
        },
        {
          symbol: "B",
        },
      ],
    },
    {
      id: "B",
      condition: matchSymbol("B"),
      successor: [
        {
          symbol: "A",
        },
      ],
    },
  ],
});

const tenthIteration = system.getOutput(10);

Credits

  • Inspired by the project lindenmayer by nylki

Readme

Keywords

none

Package Sidebar

Install

npm i lindenmayer2

Weekly Downloads

1

Version

0.5.3

License

MIT

Unpacked Size

110 kB

Total Files

18

Last publish

Collaborators

  • mspae