Crate barnsley

Crate barnsley 

Source
Expand description

§barnsley

barnsley is a library and executeable for exploring iterated function systems. It’s based and inspired by pyifs written by James Tauber for Python.

§Running the executable

Simply install using cargo install barnsley. Run barnsley in a terminal to get a CLI. Each command is documented there.

§Defining an iterated function system

An iterated function is defined by a vector of transforms. You add them one at a time.

use barnsley::{ifs::IFS, transform::AffineTransform, image::Image};
let mut ifs = IFS::new();
ifs.add_transform(AffineTransform::random().into());
 
let width: usize = 100;
let height: usize = 100;
let num_points: usize = 100;
let num_iterations: usize = 10;
let mut image = Image::new(width, height);
ifs.evaluate(&mut image, num_points, num_iterations);

§Defining iterated function systems in files

There are two kinds of files that are used to define a IFS:

  1. templates: These are toml files specify which transforms you want to run but not their parameters. Each time you run one you will get a different result. They’re good for generating many different images.
  2. configs: These are json files that fully specify the transforms and their parameters. You can use them to regenerate an image at a higher resolution, change the color scheme, or explore how changing parameters impacts the IFS.

Modules§

animation
a struct and associated methods for animations
config
core definition for an IFS run that can be serialized to a file
ifs
iterated function system
image
two-dimensional image representation
template
representation of an non-parameterized, random IFS
transform
functions used in the IFS
util
useful support functionality