path_offset/path/
point.rs1#[derive(Debug, Clone, Copy)]
2pub struct Point(pub f64, pub f64);
3
4pub trait PointConvert {
5 fn use_as<T>(&self) -> T
7 where
8 T: From<Point>,
10 Point: From<Self>,
12 Self: Copy; }
14
15impl<P> PointConvert for P
16where
17 P: Copy,
18 Point: From<P>,
19{
20 fn use_as<T>(&self) -> T
21 where
22 T: From<Point>,
23 {
24 let canonical_point = Point::from(*self);
26 T::from(canonical_point)
27 }
28}
29
30impl From<lyon::math::Point> for Point {
31 fn from(value: lyon::math::Point) -> Self {
32 Self(value.x as f64, value.y as f64)
33 }
34}
35impl From<Point> for lyon::math::Point {
36 fn from(point: Point) -> Self {
37 lyon::geom::euclid::point2(point.0 as f32, point.1 as f32)
38 }
39}
40
41impl From<flo_curves::bezier::Coord2> for Point {
42 fn from(value: flo_curves::bezier::Coord2) -> Self {
43 Self(value.0, value.1)
44 }
45}
46impl From<Point> for flo_curves::bezier::Coord2 {
47 fn from(point: Point) -> Self {
48 flo_curves::bezier::Coord2(point.0, point.1)
49 }
50}