Struct CGPoint
#[repr(C)]pub struct CGPoint {
pub x: f64,
pub y: f64,
}Expand description
CGPoint representation
Represents a point in 2D space.
§Examples
use apple_cf::cg::CGPoint;
let p1 = CGPoint::new(0.0, 0.0);
let p2 = CGPoint::new(3.0, 4.0);
assert_eq!(p1.distance_to(&p2), 5.0);Fields§
§x: f64§y: f64Implementations§
§impl CGPoint
impl CGPoint
pub const fn new(x: f64, y: f64) -> CGPoint
pub const fn new(x: f64, y: f64) -> CGPoint
Create a new point
§Examples
use apple_cf::cg::CGPoint;
let point = CGPoint::new(100.0, 200.0);
assert_eq!(point.x, 100.0);pub const fn zero() -> CGPoint
pub const fn zero() -> CGPoint
Create a point at origin (0, 0)
§Examples
use apple_cf::cg::CGPoint;
let point = CGPoint::zero();
assert!(point.is_zero());pub fn distance_to(&self, other: &CGPoint) -> f64
pub fn distance_to(&self, other: &CGPoint) -> f64
Calculate distance to another point
pub const fn distance_squared_to(&self, other: &CGPoint) -> f64
pub const fn distance_squared_to(&self, other: &CGPoint) -> f64
Calculate squared distance to another point (faster than distance_to)
Trait Implementations§
impl Copy for CGPoint
impl Eq for CGPoint
impl StructuralPartialEq for CGPoint
Auto Trait Implementations§
impl Freeze for CGPoint
impl RefUnwindSafe for CGPoint
impl Send for CGPoint
impl Sync for CGPoint
impl Unpin for CGPoint
impl UnsafeUnpin for CGPoint
impl UnwindSafe for CGPoint
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