|
@@ -1,61 +1,65 @@
|
|
|
extern crate gunpowder_treason as gt;
|
|
|
-#[macro_use] extern crate itertools;
|
|
|
+extern crate itertools;
|
|
|
|
|
|
use std::f64::consts::PI;
|
|
|
|
|
|
fn main() {
|
|
|
- let mut drawing = gt::svg(11.0, 14.0);
|
|
|
- drawing.add(gt::rect((0.0, 0.0), (11.0, 14.0)));
|
|
|
+ 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 = 16;
|
|
|
- const ROWS: u32 = 36;
|
|
|
+ const COLS: u32 = 13;
|
|
|
+ const ROWS: u32 = 30;
|
|
|
|
|
|
const XO: f64 = 0.8;
|
|
|
const YO: f64 = 0.8;
|
|
|
|
|
|
- for (y, x) in iproduct!(0..ROWS, 0..COLS) {
|
|
|
- let d = 2.0 * (N + THETA.cos() * N);
|
|
|
- let a = THETA.cos() * N;
|
|
|
- let h = THETA.sin() * N;
|
|
|
- let h2 = THETA.sin() * N * 2.0;
|
|
|
-
|
|
|
+ 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, by)
|
|
|
- .to(XO + d * x as f64 - a, by + h)
|
|
|
- );
|
|
|
- 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)
|
|
|
+ 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)
|
|
|
+ );
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- drawing.add(
|
|
|
- gt::line(XO + d * x as f64 - a, by + h)
|
|
|
- .to(XO + d * x as f64, by + h * 2.0)
|
|
|
- );
|
|
|
- if y == ROWS - 1 {
|
|
|
+ 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)
|
|
|
);
|
|
|
}
|
|
|
- drawing.add(
|
|
|
- gt::line(XO + d * x as f64 + N + a, by + h)
|
|
|
- .to(XO + d * x as f64 + N, by + h * 2.0)
|
|
|
- );
|
|
|
-
|
|
|
}
|
|
|
drawing.to_stdout();
|
|
|
}
|