some basic map-drawing
Getty Ritter
6 years ago
23 | 23 | |
24 | 24 | let get_cell = |x: usize, y: usize| { |
25 | 25 | let idx = x + y * rows; |
26 |
MAP |
|
26 | MAP.get(idx) | |
27 | 27 | }; |
28 | 28 | |
29 | 29 | for (x, y) in iproduct!(0..rows-1, 0..cols-1) { |
31 | 31 | let yc = y_offset + y as f64 * N; |
32 | 32 | let d = N / 5.0; |
33 | 33 | let cs = N / 10.0; |
34 |
if get_cell(x, y) |
|
34 | if get_cell(x, y) | |
35 | .and_then(|l| get_cell(x + 1, y) | |
36 | .and_then(|r| l != r)).unwrap_or(false) { | |
35 | 37 | drawing.add(gt::line(xc+N, yc).to(xc+N, yc+N)); |
36 | 38 | |
37 | 39 | let xt = if get_cell(x, y) == '0' as u8 { |
44 | 46 | drawing.add(gt::line(xc+N, yt).to(xt, yt)); |
45 | 47 | } |
46 | 48 | |
47 |
} else if get_cell(x, y) |
|
49 | } else if get_cell(x, y).unwrap() == '1' as u8 { | |
48 | 50 | for n in 1..5 { |
49 | 51 | drawing.add(gt::line(xc+N, yc + d * n as f64)); |
50 | 52 | } |
63 | 65 | drawing.add(gt::line(xt, yc+N).to(xt, yt)); |
64 | 66 | } |
65 | 67 | |
66 |
} else if get_cell(x, y) |
|
68 | } else if get_cell(x, y).unwrap() == '1' as u8 { | |
67 | 69 | for n in 1..5 { |
68 | 70 | drawing.add(gt::line(xc + d * n as f64, yc+N)); |
69 | 71 | } |