pub struct TileRect {
pub position: Vector2<i32>,
pub size: Vector2<i32>,
}Expand description
This is a variation of Rect that is specifically designed for use with
TileMap. While the y-axis of Rect points downward to match the y-axis
of UI, the y-axis of TileRect points upward to match the y-axis of
TileMap, TileSet, and TileMapBrush.
Unlike Rect, TileRect is designed to contain a WxH region of tiles,
which means that position + size is not considered to be a point
contained in the rect. A point is only contained in the rect if its
entire 1x1 area is contained in the rect, so the left-top corner
of the rect is position + size - (1,1).
Fields§
§position: Vector2<i32>The left-bottom corner of the rect.
size: Vector2<i32>The width and height of the rect.
Implementations§
Source§impl TileRect
impl TileRect
Sourcepub fn new(x: i32, y: i32, w: i32, h: i32) -> Self
pub fn new(x: i32, y: i32, w: i32, h: i32) -> Self
Creates a new rectangle from X, Y, width, height.
Sourcepub fn from_points(p0: Vector2<i32>, p1: Vector2<i32>) -> Self
pub fn from_points(p0: Vector2<i32>, p1: Vector2<i32>) -> Self
Create a new rectangle from two diagonally opposite corner points. In other words, create the smallest rectangle containing both given points.
Sourcepub fn with_position(self, position: Vector2<i32>) -> Self
pub fn with_position(self, position: Vector2<i32>) -> Self
Sets the new position of the rectangle.
Sourcepub fn inflate(&self, dw: i32, dh: i32) -> Self
pub fn inflate(&self, dw: i32, dh: i32) -> Self
Inflates the rectangle by the given amounts. It offsets the rectangle by (-dw, -dh) and
increases its size by (2 * dw, 2 * dh).
Sourcepub fn deflate(&self, dw: i32, dh: i32) -> OptionTileRect
pub fn deflate(&self, dw: i32, dh: i32) -> OptionTileRect
Deflates the rectangle by the given amounts. It offsets the rectangle by (dw, dh) and
decreases its size by (2 * dw, 2 * dh).
Sourcepub fn contains(&self, pt: Vector2<i32>) -> bool
pub fn contains(&self, pt: Vector2<i32>) -> bool
Checks if the given point lies within the bounds of the rectangle.
Sourcepub fn clip_by(&self, other: TileRect) -> OptionTileRect
pub fn clip_by(&self, other: TileRect) -> OptionTileRect
Clips the rectangle by some other rectangle and returns a new rectangle that corresponds to the intersection of both rectangles. If the rectangles does not intersects, the method returns none.
Sourcepub fn intersects(&self, other: TileRect) -> bool
pub fn intersects(&self, other: TileRect) -> bool
Checks if the rectangle intersects with some other rectangle.
Sourcepub fn translate(&self, translation: Vector2<i32>) -> Self
pub fn translate(&self, translation: Vector2<i32>) -> Self
Offsets the given rectangle and returns a new rectangle.
Sourcepub fn extend_to_contain(&mut self, other: TileRect)
pub fn extend_to_contain(&mut self, other: TileRect)
Extends the rectangle so it will contain the other rectangle.
Sourcepub fn left_top_corner(&self) -> Vector2<i32>
pub fn left_top_corner(&self) -> Vector2<i32>
Returns the top left corner of the rectangle.
Sourcepub fn right_top_corner(&self) -> Vector2<i32>
pub fn right_top_corner(&self) -> Vector2<i32>
Returns the top right corner of the rectangle.
Sourcepub fn right_bottom_corner(&self) -> Vector2<i32>
pub fn right_bottom_corner(&self) -> Vector2<i32>
Returns the bottom right corner of the rectangle.
Sourcepub fn left_bottom_corner(&self) -> Vector2<i32>
pub fn left_bottom_corner(&self) -> Vector2<i32>
Returns the bottom left corner of the rectangle.
Trait Implementations§
Source§impl From<TileRect> for OptionTileRect
impl From<TileRect> for OptionTileRect
Source§impl IntoIterator for TileRect
impl IntoIterator for TileRect
impl Copy for TileRect
impl Eq for TileRect
impl StructuralPartialEq for TileRect
Auto Trait Implementations§
impl Freeze for TileRect
impl RefUnwindSafe for TileRect
impl Send for TileRect
impl Sync for TileRect
impl Unpin for TileRect
impl UnwindSafe for TileRect
Blanket Implementations§
Source§impl<T> AsyncTaskResult for T
impl<T> AsyncTaskResult for T
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Any. Could be used to downcast a trait object
to a particular type.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Any. Could be used to downcast a trait object
to a particular type.fn into_any(self: Box<T>) -> Box<dyn Any>
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> FieldValue for Twhere
T: 'static,
impl<T> FieldValue for Twhere
T: 'static,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> MessageData for T
impl<T> MessageData for T
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> ScriptMessagePayload for T
impl<T> ScriptMessagePayload for T
Source§fn as_any_ref(&self) -> &(dyn Any + 'static)
fn as_any_ref(&self) -> &(dyn Any + 'static)
self as &dyn AnySource§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
self as &dyn AnySource§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.