gdritter repos axidraw-experiments / 639562f
some basic map-drawing Getty Ritter 6 years ago
1 changed file(s) with 6 addition(s) and 4 deletion(s). Collapse all Expand all
2323
2424 let get_cell = |x: usize, y: usize| {
2525 let idx = x + y * rows;
26 MAP[idx]
26 MAP.get(idx)
2727 };
2828
2929 for (x, y) in iproduct!(0..rows-1, 0..cols-1) {
3131 let yc = y_offset + y as f64 * N;
3232 let d = N / 5.0;
3333 let cs = N / 10.0;
34 if get_cell(x, y) != get_cell(x + 1, 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) {
3537 drawing.add(gt::line(xc+N, yc).to(xc+N, yc+N));
3638
3739 let xt = if get_cell(x, y) == '0' as u8 {
4446 drawing.add(gt::line(xc+N, yt).to(xt, yt));
4547 }
4648
47 } else if get_cell(x, y) == '1' as u8 {
49 } else if get_cell(x, y).unwrap() == '1' as u8 {
4850 for n in 1..5 {
4951 drawing.add(gt::line(xc+N, yc + d * n as f64));
5052 }
6365 drawing.add(gt::line(xt, yc+N).to(xt, yt));
6466 }
6567
66 } else if get_cell(x, y) == '1' as u8 {
68 } else if get_cell(x, y).unwrap() == '1' as u8 {
6769 for n in 1..5 {
6870 drawing.add(gt::line(xc + d * n as f64, yc+N));
6971 }