geometry.rs

 1use cocoa::foundation::{NSPoint, NSRect, NSSize};
 2use pathfinder_geometry::{rect::RectF, vector::Vector2F};
 3
 4pub trait Vector2FExt {
 5    fn to_ns_point(&self) -> NSPoint;
 6    fn to_ns_size(&self) -> NSSize;
 7}
 8
 9pub trait RectFExt {
10    fn to_ns_rect(&self) -> NSRect;
11}
12
13impl Vector2FExt for Vector2F {
14    fn to_ns_point(&self) -> NSPoint {
15        NSPoint::new(self.x() as f64, self.y() as f64)
16    }
17
18    fn to_ns_size(&self) -> NSSize {
19        NSSize::new(self.x() as f64, self.y() as f64)
20    }
21}
22
23impl RectFExt for RectF {
24    fn to_ns_rect(&self) -> NSRect {
25        NSRect::new(self.origin().to_ns_point(), self.size().to_ns_size())
26    }
27}