StratoSDK is a framework with a declarative approach similar to Flutter/React, written and designed entirely for Rust.
| 1 | use cocoa::foundation::{NSPoint, NSRect, NSSize}; |
| 2 | use pathfinder_geometry::{rect::RectF, vector::Vector2F}; |
| 3 | pub trait Vector2FExt { |
| 4 | fn to_ns_point(&self) -> NSPoint; |
| 5 | fn to_ns_size(&self) -> NSSize; |
| 6 | } |
| 7 | |
| 8 | pub trait RectFExt { |
| 9 | fn to_ns_rect(&self) -> NSRect; |
| 10 | } |
| 11 | |
| 12 | impl 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 | |
| 22 | impl 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 | } |
| 27 |