#[repr(C)]pub struct CGRect {
pub origin: CGPoint,
pub size: CGSize,
}Expand description
The location and dimensions of a rectangle.
See documentation.
Fields§
§origin: CGPointThe coordinates of the rectangle’s origin.
size: CGSizeThe height and width of the rectangle.
Implementations§
Source§impl CGRect
Rectangle construction.
impl CGRect
Rectangle construction.
Sourcepub const NULL: Self
pub const NULL: Self
The null rectangle, representing an invalid value.
See documentation.
Sourcepub const INFINITE: Self
pub const INFINITE: Self
A rectangle that has infinite extent.
See documentation.
Sourcepub const fn new(
x: CGFloat,
y: CGFloat,
width: CGFloat,
height: CGFloat,
) -> Self
pub const fn new( x: CGFloat, y: CGFloat, width: CGFloat, height: CGFloat, ) -> Self
Returns a rectangle with the given components.
This is equivalent to
CGRectMake.
Sourcepub const fn from_i16s(x: i16, y: i16, width: i16, height: i16) -> Self
pub const fn from_i16s(x: i16, y: i16, width: i16, height: i16) -> Self
Returns a rectangle with the given components losslessly converted to
CGFloats.
Sourcepub const fn from_parts(origin: CGPoint, size: CGSize) -> Self
pub const fn from_parts(origin: CGPoint, size: CGSize) -> Self
Returns a rectangle with the specified parts.
Source§impl CGRect
Get and set rectangle properties.
impl CGRect
Get and set rectangle properties.
Sourcepub const fn with_width(self, width: CGFloat) -> Self
pub const fn with_width(self, width: CGFloat) -> Self
Returns self with an updated width.
Sourcepub const fn with_height(self, height: CGFloat) -> Self
pub const fn with_height(self, height: CGFloat) -> Self
Returns self with an updated height.
Sourcepub fn set_height(&mut self, height: CGFloat) -> &mut Self
pub fn set_height(&mut self, height: CGFloat) -> &mut Self
Updates the height of self in-place.
Source§impl CGRect
Get rectangle bounds.
impl CGRect
Get rectangle bounds.
Sourcepub fn min_x(&self) -> CGFloat
pub fn min_x(&self) -> CGFloat
Returns the smallest value for the x-coordinate of self.
See documentation.
Sourcepub fn min_y(&self) -> CGFloat
pub fn min_y(&self) -> CGFloat
Returns the smallest value for the y-coordinate of self.
See documentation.
Sourcepub fn mid_x(&self) -> CGFloat
pub fn mid_x(&self) -> CGFloat
Returns the center value for the x-coordinate of self.
See documentation.
Sourcepub fn mid_y(&self) -> CGFloat
pub fn mid_y(&self) -> CGFloat
Returns the center value for the y-coordinate of self.
See documentation.
Sourcepub fn max_x(&self) -> CGFloat
pub fn max_x(&self) -> CGFloat
Returns the largest value for the x-coordinate of self.
See documentation.
Sourcepub fn max_y(&self) -> CGFloat
pub fn max_y(&self) -> CGFloat
Returns the largest value for the y-coordinate of self.
See documentation.
Source§impl CGRect
impl CGRect
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true if self has zero width or height, or is a null
rectangle.
See documentation.
Sourcepub fn is_null(&self) -> bool
pub fn is_null(&self) -> bool
Returns true if self is a null rectangle.
See documentation.
Sourcepub fn is_infinite(&self) -> bool
pub fn is_infinite(&self) -> bool
Returns true if self is infinite.
See documentation.
Sourcepub fn contains_point(&self, point: CGPoint) -> bool
pub fn contains_point(&self, point: CGPoint) -> bool
Returns true if self contains point.
See documentation.
Sourcepub fn contains_rect(&self, other: &Self) -> bool
pub fn contains_rect(&self, other: &Self) -> bool
Returns true if self contains other.
See documentation.
Sourcepub fn intersects(&self, other: &Self) -> bool
pub fn intersects(&self, other: &Self) -> bool
Returns true if self intersects other.
See documentation.
Sourcepub fn standardize(self) -> Self
pub fn standardize(self) -> Self
Returns self with a positive width and height.
See documentation.
Sourcepub fn integral(self) -> Self
pub fn integral(self) -> Self
Returns the smallest rectangle that results from converting the values
of self to integers.
See documentation.
Sourcepub fn apply(self, transform: CGAffineTransform) -> Self
pub fn apply(self, transform: CGAffineTransform) -> Self
Returns the result of applying an affine transformation to self.
See documentation.
Sourcepub fn offset(self, dx: CGFloat, dy: CGFloat) -> Self
pub fn offset(self, dx: CGFloat, dy: CGFloat) -> Self
Returns self with its origin offset.
See documentation.
Sourcepub fn inset(self, dx: CGFloat, dy: CGFloat) -> Self
pub fn inset(self, dx: CGFloat, dy: CGFloat) -> Self
Returns a rectangle that is smaller or larger than self, with the same
center point.
See documentation.
Sourcepub fn divide(self, amount: CGFloat, edge: CGRectEdge) -> (Self, Self)
pub fn divide(self, amount: CGFloat, edge: CGRectEdge) -> (Self, Self)
Returns two rectangles by dividing self.
Together edge and amount define a line (parallel to the specified
edge of the rectangle and at the specified distance from that edge) that
divides the rectangle into two component rectangles.
The returned tuple consists of:
-
slice: The component rectangle nearest the edge of the original rectangle specified byedge, with width equal toamount. -
remainder: The component rectangle equal to the remaining area of the original rectangle not included in theslicerectangle.
See documentation.
Sourcepub fn union(self, other: Self) -> Self
pub fn union(self, other: Self) -> Self
Returns the smallest rectangle that contains self and other.
See documentation.
Sourcepub fn intersection(self, other: Self) -> Self
pub fn intersection(self, other: Self) -> Self
Returns the intersection of self and other.
See documentation.