use hilbert_2d::{h2xy_discrete, Variant};
use plotlib::page::Page;
use plotlib::repr::Plot;
use plotlib::style::LineStyle;
use plotlib::view::ContinuousView;
fn main() {
let variant = Variant::Hilbert;
let mut order1 = Vec::new();
for h in 0..4 {
order1.push(h2xy_discrete(h, 1, variant));
}
let mut order2 = Vec::new();
for h in 0..16 {
order2.push(h2xy_discrete(h, 2, variant));
}
let mut order3 = Vec::new();
for h in 0..64 {
order3.push(h2xy_discrete(h, 3, variant));
}
let line1 = order1
.into_iter()
.map(|(x, y)| (((x as f64) + 0.5) / 2.0, ((y as f64) + 0.5) / 2.0))
.collect();
let line2 = order2
.into_iter()
.map(|(x, y)| (((x as f64) + 0.5) / 4.0, ((y as f64) + 0.5) / 4.0))
.collect();
let line3 = order3
.into_iter()
.map(|(x, y)| (((x as f64) + 0.5) / 8.0, ((y as f64) + 0.5) / 8.0))
.collect();
let plot1 = Plot::new(line1).line_style(LineStyle::new().colour("#f00"));
let plot2 = Plot::new(line2).line_style(LineStyle::new().colour("#0f0"));
let plot3 = Plot::new(line3).line_style(LineStyle::new().colour("#00f"));
let view = ContinuousView::new()
.add(plot1)
.add(plot2)
.add(plot3)
.x_range(0.0, 1.0)
.y_range(0.0, 1.0);
Page::single(&view)
.dimensions(700 + 72, 700 + 36)
.save("simple.svg")
.unwrap();
}