map_rotations_check/
map_rotations_check.rs

1//! Small demo which creates 3 maps, translated, scaled, and rotated, and writes them out if the
2//! debug_maps feature is enabled
3
4use cell_map::{Bounds, CellMap, CellMapParams, Layer};
5use nalgebra::Vector2;
6use serde::Serialize;
7
8#[derive(Debug, Clone, Copy, Layer, Serialize)]
9enum Layers {
10    Layer0,
11    Layer1,
12    Layer2,
13}
14
15fn main() {
16    let translated = CellMap::<Layers, f64>::new(CellMapParams {
17        cell_size: Vector2::new(1.0, 1.0),
18        cell_bounds: Bounds::new((0, 10), (0, 10)).unwrap(),
19        position_in_parent: Vector2::new(5.0, 5.0),
20        ..Default::default()
21    });
22
23    let rotated = CellMap::<Layers, f64>::new(CellMapParams {
24        cell_bounds: Bounds::new((0, 10), (0, 10)).unwrap(),
25        cell_size: Vector2::new(1.0, 1.0),
26        position_in_parent: Vector2::new(5.0, 5.0),
27        rotation_in_parent_rad: std::f64::consts::FRAC_PI_4,
28        ..Default::default()
29    });
30
31    let scaled = CellMap::<Layers, f64>::new(CellMapParams {
32        cell_bounds: Bounds::new((0, 10), (0, 10)).unwrap(),
33        cell_size: Vector2::new(0.5, 0.5),
34        position_in_parent: Vector2::new(5.0, 5.0),
35        rotation_in_parent_rad: std::f64::consts::FRAC_PI_4,
36        ..Default::default()
37    });
38
39    #[cfg(all(feature = "debug_maps"))]
40    {
41        use cell_map::write_debug_map;
42
43        write_debug_map(&translated, "translated");
44        write_debug_map(&rotated, "rotated");
45        write_debug_map(&scaled, "scaled");
46    }
47}