utiles_core/macros.rs
1/// Tile macro to create a new tile.
2/// - do you need this? probably not
3/// - Did I write to figure out how to write a macro? yes
4#[macro_export]
5macro_rules! utile {
6 ($x:expr, $y:expr, $z:expr) => {
7 Tile::new($x, $y, $z)
8 };
9 { x: $x:expr, y: $y:expr, z: $z:expr } => {
10 Tile::new($x, $y, $z)
11 };
12}
13
14/// Macro to create tile from x-y(up)-z
15///
16/// The `y` coordinate is imediately flipped.
17#[macro_export]
18macro_rules! utile_yup {
19 ($x:expr, $y:expr, $z:expr) => {
20 Tile::new($x, flipy($y, $z), $z)
21 };
22 { x: $x:expr, y: $y:expr, z: $z:expr } => {
23 Tile::new($x, flipy($y, $z), $z)
24 };
25}
26
27/// point2d macro to create a new point.
28/// Replacement for coord! macro from geo-types
29///
30/// # Examples
31///
32/// ```
33/// use utiles_core::{point2d, Point2d};
34/// let p = point2d!{ x: 1.0, y: 2.0 };
35/// assert_eq!(p.x(), 1.0);
36/// assert_eq!(p.y(), 2.0);
37/// ```
38#[macro_export]
39macro_rules! point2d {
40 { x: $x:expr, y: $y:expr } => {
41 Point2d::new($x, $y)
42 };
43 ($x:expr, $y:expr ) => {
44 Point2d::new($x, $y)
45 };
46}