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