Expand description
A rectangle of f32
s.
Fields§
§x: f32
The X co-ordinate of the rectangle.
y: f32
The Y co-ordinate of the rectangle.
width: f32
The width of the rectangle.
height: f32
The height of the rectangle.
Implementations§
source§impl Rectangle
impl Rectangle
sourcepub fn row(
x: f32,
y: f32,
width: f32,
height: f32
) -> impl Iterator<Item = Rectangle>
pub fn row(
x: f32,
y: f32,
width: f32,
height: f32
) -> impl Iterator<Item = Rectangle>
Returns an infinite iterator of horizontally adjecent rectangles, starting at the specified point and increasing along the X axis.
This can be useful when slicing spritesheets.
Examples
let rects: Vec<Rectangle> = Rectangle::row(0.0, 0.0, 16.0, 16.0).take(3).collect();
assert_eq!(Rectangle::new(0.0, 0.0, 16.0, 16.0), rects[0]);
assert_eq!(Rectangle::new(16.0, 0.0, 16.0, 16.0), rects[1]);
assert_eq!(Rectangle::new(32.0, 0.0, 16.0, 16.0), rects[2]);
sourcepub fn column(
x: f32,
y: f32,
width: f32,
height: f32
) -> impl Iterator<Item = Rectangle>
pub fn column(
x: f32,
y: f32,
width: f32,
height: f32
) -> impl Iterator<Item = Rectangle>
Returns an infinite iterator of vertically adjecent rectangles, starting at the specified point and increasing along the Y axis.
This can be useful when slicing spritesheets.
Examples
let rects: Vec<Rectangle> = Rectangle::column(0.0, 0.0, 16.0, 16.0).take(3).collect();
assert_eq!(Rectangle::new(0.0, 0.0, 16.0, 16.0), rects[0]);
assert_eq!(Rectangle::new(0.0, 16.0, 16.0, 16.0), rects[1]);
assert_eq!(Rectangle::new(0.0, 32.0, 16.0, 16.0), rects[2]);
Trait Implementations§
impl Copy for Rectangle
impl StructuralPartialEq for Rectangle
Auto Trait Implementations§
impl RefUnwindSafe for Rectangle
impl Send for Rectangle
impl Sync for Rectangle
impl Unpin for Rectangle
impl UnwindSafe for Rectangle
Blanket Implementations§
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> SetParameter for T
impl<T> SetParameter for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self
from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self
is actually part of its subset T
(and can be converted to it).§unsafe fn to_subset_unchecked(&self) -> SS
unsafe fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self
to the equivalent element of its superset.