[][src]Crate fart

fart: fitzgen's generative art

Example

Drawing a random triangle!

use fart::prelude::*;

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

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

        scene.add(Triangle {
            a: point2(x_dist.sample(cfg.rng()), y_dist.sample(cfg.rng())),
            b: point2(x_dist.sample(cfg.rng()), y_dist.sample(cfg.rng())),
            c: point2(x_dist.sample(cfg.rng()), y_dist.sample(cfg.rng())),
        });

        Ok(scene.create_svg(Inches(7.0), Inches(7.0)))
    });
}

Re-exports

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

Modules

path

Paths describe a series lines and curves.

prelude

The most common functionality re-exported.

scene

A scene of shapes.

shape

Shapes in a scene.

Structs

Config

Configuration options for SVG generation.

Functions

generate

Generate an SVG with the given function f.

Type Definitions

Result

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