Type Alias oxygengine_ha_renderer::math::Rect
source · pub type Rect = Rect<Scalar, Scalar>;Aliased Type§
struct Rect {
pub x: f32,
pub y: f32,
pub w: f32,
pub h: f32,
}Fields§
§x: f32X position of the bottom-left corner.
y: f32Y position of the bottom-left corner.
w: f32Width.
h: f32Height, with Y axis going upwards.
Implementations§
source§impl<P, E> Rect<P, E>
impl<P, E> Rect<P, E>
sourcepub fn new(x: P, y: P, w: E, h: E) -> Rect<P, E>
pub fn new(x: P, y: P, w: E, h: E) -> Rect<P, E>
Creates a new rectangle from position elements and extent elements.
sourcepub fn set_position(&mut self, p: Vec2<P>)
pub fn set_position(&mut self, p: Vec2<P>)
Sets this rectangle’s position.
sourcepub fn set_extent(&mut self, e: Extent2<E>)
pub fn set_extent(&mut self, e: Extent2<E>)
Sets this rectangle’s extent (size).
sourcepub fn position_extent(self) -> (Vec2<P>, Extent2<E>)
pub fn position_extent(self) -> (Vec2<P>, Extent2<E>)
Gets this rectangle’s position and extent (size).
sourcepub fn map<DP, DE, PF, EF>(self, pf: PF, ef: EF) -> Rect<DP, DE>where
PF: FnMut(P) -> DP,
EF: FnMut(E) -> DE,
pub fn map<DP, DE, PF, EF>(self, pf: PF, ef: EF) -> Rect<DP, DE>where PF: FnMut(P) -> DP, EF: FnMut(E) -> DE,
Returns this rectangle, converted with the given closures (one for position elements, the other for extent elements).
sourcepub fn as_<DP, DE>(self) -> Rect<DP, DE>where
P: AsPrimitive<DP>,
DP: 'static + Copy,
E: AsPrimitive<DE>,
DE: 'static + Copy,
pub fn as_<DP, DE>(self) -> Rect<DP, DE>where P: AsPrimitive<DP>, DP: 'static + Copy, E: AsPrimitive<DE>, DE: 'static + Copy,
Converts this rectangle to a rectangle of another type, using the as conversion.
source§impl<T> Rect<T, T>where
T: Copy + Add<T, Output = T>,
impl<T> Rect<T, T>where T: Copy + Add<T, Output = T>,
sourcepub fn into_aabr(self) -> Aabr<T>
pub fn into_aabr(self) -> Aabr<T>
Converts this into the matching axis-aligned bounding shape representation.
sourcepub fn contains_point(self, p: Vec2<T>) -> boolwhere
T: PartialOrd<T>,
pub fn contains_point(self, p: Vec2<T>) -> boolwhere T: PartialOrd<T>,
Does this rectangle contain the given point ?
sourcepub fn contains_rect(self, other: Rect<T, T>) -> boolwhere
T: PartialOrd<T>,
pub fn contains_rect(self, other: Rect<T, T>) -> boolwhere T: PartialOrd<T>,
Does this rectangle fully contain the given one ?
sourcepub fn collides_with_rect(self, other: Rect<T, T>) -> boolwhere
T: PartialOrd<T>,
pub fn collides_with_rect(self, other: Rect<T, T>) -> boolwhere T: PartialOrd<T>,
Does this rectangle collide with another ?
source§impl<T> Rect<T, T>where
T: PartialOrd<T> + Sub<T, Output = T> + Add<T, Output = T> + Copy,
impl<T> Rect<T, T>where T: PartialOrd<T> + Sub<T, Output = T> + Add<T, Output = T> + Copy,
sourcepub fn expanded_to_contain_point(self, p: Vec2<T>) -> Rect<T, T>where
T: PartialOrd<T>,
pub fn expanded_to_contain_point(self, p: Vec2<T>) -> Rect<T, T>where T: PartialOrd<T>,
Returns this shape so that it contains the given point.
sourcepub fn expand_to_contain_point(&mut self, p: Vec2<T>)where
T: PartialOrd<T>,
pub fn expand_to_contain_point(&mut self, p: Vec2<T>)where T: PartialOrd<T>,
Expands this shape so that it contains the given point.
sourcepub fn union(self, other: Rect<T, T>) -> Rect<T, T>
pub fn union(self, other: Rect<T, T>) -> Rect<T, T>
Gets the smallest rectangle that contains both this one and another.
sourcepub fn intersection(self, other: Rect<T, T>) -> Rect<T, T>
pub fn intersection(self, other: Rect<T, T>) -> Rect<T, T>
Gets the largest rectangle contained by both this one and another.
sourcepub fn expand_to_contain(&mut self, other: Rect<T, T>)
pub fn expand_to_contain(&mut self, other: Rect<T, T>)
Sets this rectangle to the union of itself with another.
sourcepub fn intersect(&mut self, other: Rect<T, T>)
pub fn intersect(&mut self, other: Rect<T, T>)
Sets this rectangle to the intersection of itself with another.
sourcepub fn collision_vector_with_rect(self, other: Rect<T, T>) -> Vec2<T>where
T: One + Div<T, Output = T>,
pub fn collision_vector_with_rect(self, other: Rect<T, T>) -> Vec2<T>where T: One + Div<T, Output = T>,
Gets a vector that tells how much self penetrates other.
sourcepub fn split_at_x(self, sp: T) -> [Rect<T, T>; 2]
pub fn split_at_x(self, sp: T) -> [Rect<T, T>; 2]
Splits this shape in two, by a straight plane along the
x
axis.
The returned tuple is (low, high).
Panics
sp is assumed to be a position along the
x
axis that is within this shape’s bounds.
sourcepub fn split_at_y(self, sp: T) -> [Rect<T, T>; 2]
pub fn split_at_y(self, sp: T) -> [Rect<T, T>; 2]
Splits this shape in two, by a straight plane along the
y
axis.
The returned tuple is (low, high).
Panics
sp is assumed to be a position along the
y
axis that is within this shape’s bounds.