pub struct TileId {
pub x: i32,
pub y: i32,
}Expand description
A tile address on the integer grid. Coordinates may be negative.
Fields§
§x: i32§y: i32Implementations§
Source§impl TileId
impl TileId
pub fn new(x: i32, y: i32) -> Self
Sourcepub fn origin(self, extent: u32) -> Option<Coord<i32>>
pub fn origin(self, extent: u32) -> Option<Coord<i32>>
This tile’s origin in global coordinates — self · extent, the global position its local
[0, 0] corner maps to. Add it to a tile-local coordinate to lift it into the global
frame, or subtract it to drop a global coordinate into this tile’s local frame.
Returns None if self · extent overflows i32 (a tile far outside the representable range
for this extent).
let origin = TileId::new(2, 3).origin(25).expect("in range");
assert_eq!(origin, Coord { x: 50, y: 75 });
assert_eq!(Coord { x: 4, y: 1 } + origin, Coord { x: 54, y: 76 }); // local → global
assert_eq!(Coord { x: 54, y: 76 } - origin, Coord { x: 4, y: 1 }); // global → localTrait Implementations§
impl Copy for TileId
impl Eq for TileId
Source§impl Ord for TileId
impl Ord for TileId
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl PartialOrd for TileId
impl PartialOrd for TileId
impl StructuralPartialEq for TileId
Auto Trait Implementations§
impl Freeze for TileId
impl RefUnwindSafe for TileId
impl Send for TileId
impl Sync for TileId
impl Unpin for TileId
impl UnsafeUnpin for TileId
impl UnwindSafe for TileId
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more