[][src]Function geopattern::circle_packing

pub fn circle_packing(
    centers: &[(f32, f32)],
    (minr, maxr): (f32, f32),
    (width, height): (f32, f32),
    fill: &[(&str, f32)],
    stroke: (&str, f32, f32),
    background_color: &str
) -> Document

circle packing

https://generativeartistry.com/tutorials/circle-packing/

use geopattern::circle_packing;

let c = circle_packing(
    &(0..100).map(|ix| (ix as f32, ix as f32)).collect::<Vec<(f32, f32)>>(),
    (2.0, 24.0),
    (200.0, 200.0),
    &(0..100)
        .map(|v| {
            (
                if v & 1 == 0 { "#222" } else { "#ddd" },
                0.02 + (v as f32) / 4.0,
            )
        })
        .collect::<Vec<(&str, f32)>>(),
    ("#ddd", 1.0, 0.2),
    "#EEE",
);

println!("{}", c);