CGRect

Struct CGRect 

Source
#[repr(C)]
pub struct CGRect { pub origin: CGPoint, pub size: CGSize, }
Expand description

The location and dimensions of a rectangle.

See documentation.

Fields§

§origin: CGPoint

The coordinates of the rectangle’s origin.

§size: CGSize

The height and width of the rectangle.

Implementations§

Source§

impl CGRect

Rectangle construction.

Source

pub const ZERO: Self

A rectangle with zero origin and size.

Source

pub const NULL: Self

The null rectangle, representing an invalid value.

See documentation.

Source

pub const INFINITE: Self

A rectangle that has infinite extent.

See documentation.

Source

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.

Source

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.

Source

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.

Source

pub const fn x(&self) -> CGFloat

Returns the x-coordinate of self.

Source

pub const fn y(&self) -> CGFloat

Returns the y-coordinate of self.

Source

pub const fn width(&self) -> CGFloat

Returns the width of self.

Source

pub const fn height(&self) -> CGFloat

Returns the height of self.

Source

pub const fn with_x(self, x: CGFloat) -> Self

Returns self with an updated x-coordinate.

Source

pub const fn with_y(self, y: CGFloat) -> Self

Returns self with an updated y-coordinate.

Source

pub const fn with_width(self, width: CGFloat) -> Self

Returns self with an updated width.

Source

pub const fn with_height(self, height: CGFloat) -> Self

Returns self with an updated height.

Source

pub fn set_x(&mut self, x: CGFloat) -> &mut Self

Updates the x-coordinate of self in-place.

Source

pub fn set_y(&mut self, y: CGFloat) -> &mut Self

Updates the y-coordinate of self in-place.

Source

pub fn set_width(&mut self, width: CGFloat) -> &mut Self

Updates the width of self in-place.

Source

pub fn set_height(&mut self, height: CGFloat) -> &mut Self

Updates the height of self in-place.

Source§

impl CGRect

Get rectangle bounds.

Source

pub fn min_x(&self) -> CGFloat

Returns the smallest value for the x-coordinate of self.

See documentation.

Source

pub fn min_y(&self) -> CGFloat

Returns the smallest value for the y-coordinate of self.

See documentation.

Source

pub fn mid_x(&self) -> CGFloat

Returns the center value for the x-coordinate of self.

See documentation.

Source

pub fn mid_y(&self) -> CGFloat

Returns the center value for the y-coordinate of self.

See documentation.

Source

pub fn max_x(&self) -> CGFloat

Returns the largest value for the x-coordinate of self.

See documentation.

Source

pub fn max_y(&self) -> CGFloat

Returns the largest value for the y-coordinate of self.

See documentation.

Source§

impl CGRect

Source

pub fn is_empty(&self) -> bool

Returns true if self has zero width or height, or is a null rectangle.

See documentation.

Source

pub fn is_null(&self) -> bool

Returns true if self is a null rectangle.

See documentation.

Source

pub fn is_infinite(&self) -> bool

Returns true if self is infinite.

See documentation.

Source

pub fn contains_point(&self, point: CGPoint) -> bool

Returns true if self contains point.

See documentation.

Source

pub fn contains_rect(&self, other: &Self) -> bool

Returns true if self contains other.

See documentation.

Source

pub fn intersects(&self, other: &Self) -> bool

Returns true if self intersects other.

See documentation.

Source

pub fn standardize(self) -> Self

Returns self with a positive width and height.

See documentation.

Source

pub fn integral(self) -> Self

Returns the smallest rectangle that results from converting the values of self to integers.

See documentation.

Source

pub fn apply(self, transform: CGAffineTransform) -> Self

Returns the result of applying an affine transformation to self.

See documentation.

Source

pub fn offset(self, dx: CGFloat, dy: CGFloat) -> Self

Returns self with its origin offset.

See documentation.

Source

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.

Source

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 by edge, with width equal to amount.

  • remainder: The component rectangle equal to the remaining area of the original rectangle not included in the slice rectangle.

See documentation.

Source

pub fn union(self, other: Self) -> Self

Returns the smallest rectangle that contains self and other.

See documentation.

Source

pub fn intersection(self, other: Self) -> Self

Returns the intersection of self and other.

See documentation.

Trait Implementations§

Source§

impl Clone for CGRect

Source§

fn clone(&self) -> CGRect

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CGRect

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for CGRect

Source§

fn default() -> CGRect

Returns the “default value” for a type. Read more
Source§

impl PartialEq for CGRect

Source§

fn eq(&self, other: &CGRect) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for CGRect

Source§

fn partial_cmp(&self, other: &CGRect) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Copy for CGRect

Source§

impl StructuralPartialEq for CGRect

Auto Trait Implementations§

§

impl Freeze for CGRect

§

impl RefUnwindSafe for CGRect

§

impl Send for CGRect

§

impl Sync for CGRect

§

impl Unpin for CGRect

§

impl UnwindSafe for CGRect

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.