geometry.rs

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