[][src]Crate fart

fart: fitzgen's generative art

Example

Drawing a random triangle!

use fart::prelude::*;

fn main() {
    fart::generate(|cfg| {
        let mut canvas = Canvas::new(Aabb::new(
            point2(0, 0),
            point2(1000, 1000),
        ));

        let x_dist = Uniform::new(0, 1000);
        let y_dist = Uniform::new(0, 1000);

        let triangle = fart::geom::Polygon::new(vec![
            point2(x_dist.sample(cfg.rng()), y_dist.sample(cfg.rng())),
            point2(x_dist.sample(cfg.rng()), y_dist.sample(cfg.rng())),
            point2(x_dist.sample(cfg.rng()), y_dist.sample(cfg.rng())),
        ]);

        canvas.draw(&triangle);

        Ok(canvas.create_svg(Millis(200.0), Millis(200.0)))
    });
}

Re-exports

pub use euclid;
pub use failure;
pub use fart_2d_geom as geom;
pub use fart_aabb as aabb;
pub use lazy_static;
pub use noise;
pub use num_traits;
pub use rand;
pub use svg;

Modules

canvas

A canvas for drawing paths on.

path

Paths describe a series lines and curves.

prelude

The most common functionality re-exported.

process

Incrementally computed processs for drawing onto a canvas.

Macros

user_const

User-defined, runtime "constants".

Structs

Config

Configuration options for SVG generation.

FartThreadRng

An RNG that is seeded with a fart::user_const!.

Functions

generate

Generate an SVG with the given function f.

rng

Get this thread's FartThreadRng!

Type Definitions

Result

Either an Ok(T) or an Err(failure::Error).