kanoko 0.3.0

Generate a random pattern inspired by the traditional Japanese kanoko pattern
Documentation
use kanoko::{
    Canvas, Color,
    geometry::{Angle::Degree, Coordinate},
    point_set::lattice::{Index, Lattice},
    shape::Polygon,
};
use rand::Rng;

fn main() {
    let background_color = Color::from_hex("#ffc36c").unwrap();

    let grid = Lattice::new_hexagonal(Index { x: 10, y: 10 }, 300.0);

    let mut canvas = Canvas::new(
        Coordinate {
            x: 2560.0,
            y: 1440.0,
        },
        background_color,
        grid,
    );
    canvas.add_shape(Polygon::new_static(
        12,
        220.0,
        Degree(0.0),
        Color::from_hex("#20131a").unwrap(),
        Some(12.0),
    ));

    canvas.add_shape(Polygon::new_static(
        12,
        160.0,
        Degree(0.0),
        Color::from_hex("#c06a2f").unwrap(),
        Some(12.0),
    ));

    let document = canvas.render(|_| rand::rng().random_bool(0.9));
    svg::save("examples/leopard.svg", &document).unwrap();
}