Expand description
A rectangle.
Fields§
§x0: f64
The minimum x coordinate (left edge).
y0: f64
The minimum y coordinate (top edge in y-down spaces).
x1: f64
The maximum x coordinate (right edge).
y1: f64
The maximum y coordinate (bottom edge in y-down spaces).
Implementations§
source§impl Rect
impl Rect
sourcepub fn new(x0: f64, y0: f64, x1: f64, y1: f64) -> Rect
pub fn new(x0: f64, y0: f64, x1: f64, y1: f64) -> Rect
A new rectangle from minimum and maximum coordinates.
sourcepub fn from_points(p0: Vec2, p1: Vec2) -> Rect
pub fn from_points(p0: Vec2, p1: Vec2) -> Rect
A new rectangle from two points.
The result will have non-negative width and height.
sourcepub fn from_origin_size(origin: Vec2, size: Vec2) -> Rect
pub fn from_origin_size(origin: Vec2, size: Vec2) -> Rect
A new rectangle from origin and size.
The result will have non-negative width and height.
sourcepub fn height(&self) -> f64
pub fn height(&self) -> f64
The height of the rectangle.
Note: nothing forbids negative height.
sourcepub fn origin(&self) -> Vec2
pub fn origin(&self) -> Vec2
The origin of the vector.
This is the top left corner in a y-down space and with non-negative width and height.
sourcepub fn abs(&self) -> Rect
pub fn abs(&self) -> Rect
Take absolute value of width and height.
The resulting rect has the same extents as the original, but is guaranteed to have non-negative width and height.
sourcepub fn union(&self, other: Rect) -> Rect
pub fn union(&self, other: Rect) -> Rect
The smallest rectangle enclosing two rectangles.
Results are valid only if width and height are non-negative.
Trait Implementations§
source§impl Shape for Rect
impl Shape for Rect
source§fn winding(&self, pt: Vec2) -> i32
fn winding(&self, pt: Vec2) -> i32
Note: this function is carefully designed so that if the plane is tiled with rectangles, the winding number will be nonzero for exactly one of them.
§type BezPathIter = RectPathIter
type BezPathIter = RectPathIter
to_bez_path
.