#[repr(C)]pub struct CGRect {
pub origin: CGPoint,
pub size: CGSize,
}Available on crate feature
cg only.Expand description
CGRect representation
Represents a rectangle with an origin point and size dimensions.
§Examples
use apple_cf::cg::CGRect;
let rect = CGRect::new(10.0, 20.0, 100.0, 200.0);
assert_eq!(rect.origin.x, 10.0);
assert_eq!(rect.size.width, 100.0);
assert_eq!(rect.max_x(), 110.0);Fields§
§origin: CGPoint§size: CGSizeImplementations§
Source§impl CGRect
impl CGRect
Sourcepub const fn new(x: f64, y: f64, width: f64, height: f64) -> Self
pub const fn new(x: f64, y: f64, width: f64, height: f64) -> Self
Create a new rectangle
§Examples
use apple_cf::cg::CGRect;
let rect = CGRect::new(0.0, 0.0, 1920.0, 1080.0);
assert_eq!(rect.size.width, 1920.0);Sourcepub const fn zero() -> Self
pub const fn zero() -> Self
Create a zero-sized rectangle at origin
§Examples
use apple_cf::cg::CGRect;
let rect = CGRect::zero();
assert!(rect.is_null());Sourcepub const fn from_origin_size(origin: CGPoint, size: CGSize) -> Self
pub const fn from_origin_size(origin: CGPoint, size: CGSize) -> Self
Create a rect with origin and size.
Sourcepub const fn with_origin_and_size(origin: CGPoint, size: CGSize) -> Self
pub const fn with_origin_and_size(origin: CGPoint, size: CGSize) -> Self
Create a rect with origin and size.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns whether the rectangle has a non-positive width or height.
Sourcepub fn contains_point(&self, p: CGPoint) -> bool
pub fn contains_point(&self, p: CGPoint) -> bool
Returns whether the rectangle contains the provided point.
Trait Implementations§
impl Copy for CGRect
impl Eq for CGRect
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 UnsafeUnpin for CGRect
impl UnwindSafe for CGRect
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more