1 | 1 |
extern crate gunpowder_treason as gt;
|
2 | |
#[macro_use] extern crate itertools;
|
| 2 |
extern crate itertools;
|
3 | 3 |
|
4 | 4 |
use std::f64::consts::PI;
|
5 | 5 |
|
6 | 6 |
fn main() {
|
7 | |
let mut drawing = gt::svg(11.0, 14.0);
|
8 | |
drawing.add(gt::rect((0.0, 0.0), (11.0, 14.0)));
|
| 7 |
let cent = 0.393701f64;
|
| 8 |
let mut drawing = gt::svg(23.0 * cent, 30.0 * cent);
|
| 9 |
drawing.add(gt::rect((0.0, 0.0), (23.0 * cent, 30.0 * cent)));
|
9 | 10 |
const N: f64 = 0.2;
|
10 | 11 |
const THETA: f64 = PI / 3.0;
|
11 | |
const COLS: u32 = 16;
|
12 | |
const ROWS: u32 = 36;
|
| 12 |
const COLS: u32 = 13;
|
| 13 |
const ROWS: u32 = 30;
|
13 | 14 |
|
14 | 15 |
const XO: f64 = 0.8;
|
15 | 16 |
const YO: f64 = 0.8;
|
16 | 17 |
|
17 | |
for (y, x) in iproduct!(0..ROWS, 0..COLS) {
|
18 | |
let d = 2.0 * (N + THETA.cos() * N);
|
19 | |
let a = THETA.cos() * N;
|
20 | |
let h = THETA.sin() * N;
|
21 | |
let h2 = THETA.sin() * N * 2.0;
|
| 18 |
let a = THETA.cos() * N;
|
| 19 |
let h = THETA.sin() * N;
|
| 20 |
let h2 = THETA.sin() * N * 2.0;
|
| 21 |
let d = 2.0 * (N + THETA.cos() * N);
|
| 22 |
for y in 0..ROWS {
|
| 23 |
let by = YO + y as f64 * h2;
|
| 24 |
for x in 0..COLS {
|
22 | 25 |
|
23 | |
let by = YO + y as f64 * h2;
|
| 26 |
drawing.add(
|
| 27 |
gt::line(XO + d * x as f64 - a, by + h)
|
| 28 |
.to(XO + d * x as f64, by)
|
| 29 |
);
|
| 30 |
drawing.add(
|
| 31 |
gt::line(XO + d * x as f64, by)
|
| 32 |
.to(XO + d * x as f64 + N, by)
|
| 33 |
);
|
| 34 |
drawing.add(
|
| 35 |
gt::line(XO + d * x as f64 + N, by)
|
| 36 |
.to(XO + d * x as f64 + N + a, by + h)
|
| 37 |
);
|
| 38 |
if x < COLS - 1 {
|
| 39 |
drawing.add(
|
| 40 |
gt::line(XO + d * x as f64 + N + a, by + h)
|
| 41 |
.to(XO + d * x as f64 + N * 2.0 + a, by + h)
|
| 42 |
);
|
| 43 |
}
|
| 44 |
}
|
24 | 45 |
|
25 | |
drawing.add(
|
26 | |
gt::line(XO + d * x as f64, by)
|
27 | |
.to(XO + d * x as f64 - a, by + h)
|
28 | |
);
|
29 | |
drawing.add(
|
30 | |
gt::line(XO + d * x as f64, by)
|
31 | |
.to(XO + d * x as f64 + N, by)
|
32 | |
);
|
33 | |
drawing.add(
|
34 | |
gt::line(XO + d * x as f64 + N, by)
|
35 | |
.to(XO + d * x as f64 + N + a, by + h)
|
36 | |
);
|
37 | |
if x < COLS - 1 {
|
| 46 |
for x in 0..COLS {
|
| 47 |
|
| 48 |
drawing.add(
|
| 49 |
gt::line(XO + d * x as f64, by + h * 2.0)
|
| 50 |
.to(XO + d * x as f64 - a, by + h)
|
| 51 |
);
|
| 52 |
if y == ROWS - 1 {
|
| 53 |
drawing.add(
|
| 54 |
gt::line(XO + d * x as f64, by + h * 2.0)
|
| 55 |
.to(XO + d * x as f64 + N, by + h * 2.0)
|
| 56 |
);
|
| 57 |
}
|
38 | 58 |
drawing.add(
|
39 | 59 |
gt::line(XO + d * x as f64 + N + a, by + h)
|
40 | |
.to(XO + d * x as f64 + N * 2.0 + a, by + h)
|
41 | |
);
|
42 | |
}
|
43 | |
|
44 | |
drawing.add(
|
45 | |
gt::line(XO + d * x as f64 - a, by + h)
|
46 | |
.to(XO + d * x as f64, by + h * 2.0)
|
47 | |
);
|
48 | |
if y == ROWS - 1 {
|
49 | |
drawing.add(
|
50 | |
gt::line(XO + d * x as f64, by + h * 2.0)
|
51 | 60 |
.to(XO + d * x as f64 + N, by + h * 2.0)
|
52 | 61 |
);
|
53 | 62 |
}
|
54 | |
drawing.add(
|
55 | |
gt::line(XO + d * x as f64 + N + a, by + h)
|
56 | |
.to(XO + d * x as f64 + N, by + h * 2.0)
|
57 | |
);
|
58 | |
|
59 | 63 |
}
|
60 | 64 |
drawing.to_stdout();
|
61 | 65 |
}
|