#[repr(C)]pub struct CGPoint {
pub x: f64,
pub y: f64,
}Expand description
CGPoint representation
Represents a point in 2D space.
§Examples
use screencapturekit::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§
Source§impl CGPoint
impl CGPoint
Sourcepub const fn new(x: f64, y: f64) -> Self
pub const fn new(x: f64, y: f64) -> Self
Create a new point
§Examples
use screencapturekit::cg::CGPoint;
let point = CGPoint::new(100.0, 200.0);
assert_eq!(point.x, 100.0);Sourcepub const fn zero() -> Self
pub const fn zero() -> Self
Create a point at origin (0, 0)
§Examples
use screencapturekit::cg::CGPoint;
let point = CGPoint::zero();
assert!(point.is_zero());Sourcepub fn distance_to(&self, other: &Self) -> f64
pub fn distance_to(&self, other: &Self) -> f64
Calculate distance to another point
Sourcepub const fn distance_squared_to(&self, other: &Self) -> f64
pub const fn distance_squared_to(&self, other: &Self) -> 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 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