Crate rusty_systems

source ·
Expand description

A crate for procedurally generating content using L-systems.

NOTE: this crate is still under early development, and might change rapidly. The next released version will likely have breaking changes.

§Introduction

This crate currently supports producing strings using context-free and stochastic L-Systems.

The system module contains the primary tools for defining and running these grammars. As a convenience, the geometry module contains types for easily handling the interpretation of the grammar’s output in a 2D space. Note that the geometry tools are not meant to be complete or high performance — it’s meant to only be utilitarian.

§Parsing and Derivation

The easiest way to parse:

use rusty_systems::prelude::*;
use rusty_systems::parser;

let system = System::new();
system.parse_production("CompanyName -> Surname Surname").unwrap();

let starting_axiom = parser::parse_prod_string("CompanyName").unwrap();
let result = system.derive(starting_axiom, RunSettings::default()).unwrap();

println!("The resulting string is:\n{result}");

If you would like to parse without using a System instance, you can use the following underlying functions:

See parser for more information, and for generic parsing functions that do not need you to use System.

§Features

Some features that you might find useful:

  • Some support for interpreting L-Systems as defined in the Algorithmic Beauty of Plants (ABOP). See the abop module documentation.
  • Some native, limited support for geometric primitives. See the geometry module. This is not meant as a replacement for libraries such as nalgebra, just as something convenient to use.
  • Native support for creating and outputting SVGs. See the svg module.
  • A command line app, lsystem, for creating SVGs of systems from ABOP. You can read about using this tool here

§Examples

The crate’s example directory has various examples:

  • Vector graphics plant

    This example uses two rules to produce a small plant. The symbols are interpreted using a classic logo turtle interpretation to produce vector graphics. While the example uses tiny skia, this can be replaced with any vector graphic library.

    If you clone the code repository, you can run this using:

    cargo run --example skia-plant

§Learn more about L-Systems

If you would like to learn more about L-Systems, the original Algorithmic Beauty of Plants book by Prusinkiewicz and Lindenmayer is available for free, online.

§Code repository, license, and versioning.

This crate has a website available at https://theriver.github.io/rusty-systems/.

The code repository is hosted on GitHub and is distributed under an MIT license. A changelog is also available.

This crate versioning uses semantic versioning.

Modules§

Type Aliases§

  • A result type for functions that can return errors.