extern crate gunpowder_treason as gt; extern crate itertools; use std::f64::consts::PI; fn main() { let cent = 0.393701f64; let mut drawing = gt::svg(23.0 * cent, 30.0 * cent); drawing.add(gt::rect((0.0, 0.0), (23.0 * cent, 30.0 * cent))); const N: f64 = 0.2; const THETA: f64 = PI / 3.0; const COLS: u32 = 13; const ROWS: u32 = 30; const XO: f64 = 0.8; const YO: f64 = 0.8; let a = THETA.cos() * N; let h = THETA.sin() * N; let h2 = THETA.sin() * N * 2.0; let d = 2.0 * (N + THETA.cos() * N); for y in 0..ROWS { let by = YO + y as f64 * h2; for x in 0..COLS { drawing.add( gt::line(XO + d * x as f64 - a, by + h) .to(XO + d * x as f64, by) ); drawing.add( gt::line(XO + d * x as f64, by) .to(XO + d * x as f64 + N, by) ); drawing.add( gt::line(XO + d * x as f64 + N, by) .to(XO + d * x as f64 + N + a, by + h) ); if x < COLS - 1 { drawing.add( gt::line(XO + d * x as f64 + N + a, by + h) .to(XO + d * x as f64 + N * 2.0 + a, by + h) ); } } for x in 0..COLS { drawing.add( gt::line(XO + d * x as f64, by + h * 2.0) .to(XO + d * x as f64 - a, by + h) ); if y == ROWS - 1 { drawing.add( gt::line(XO + d * x as f64, by + h * 2.0) .to(XO + d * x as f64 + N, by + h * 2.0) ); } drawing.add( gt::line(XO + d * x as f64 + N + a, by + h) .to(XO + d * x as f64 + N, by + h * 2.0) ); } } if let Err(e) = drawing.output("hexes") { eprintln!("{}", e); } }