extern crate gunpowder_treason as gt;
extern crate rand;

fn main() {
    let (w, h) = (8.5, 11.0);
    let mut drawing = gt::svg(w, h);

    let rs = (0u64..100)
        .scan((0u64, 5.5f64), |&mut (_, s), x: u64| {
            Some((x, s + (rand::random::<f64>() * 0.5) - 0.25))
    });

    for (x, r) in rs {
        let xn = 0.8 + (x as f64 * (8.5 - 1.6)) / 100.0;
        drawing.add(
            gt::line(xn, 0.8).to(xn, r - 0.8)
        );
        drawing.add(
            gt::line(xn, 10.2).to(xn, r + 0.8)
        );
    }

    if let Err(e) = drawing.output("sunburst") {
        eprintln!("{}", e);
    };
}
