@@ -55,15 +55,12 @@ pub struct CubicSegmentFull {
5555 pub rest : CubicSegment ,
5656}
5757
58- impl CubicSegmentFull {
59- /// Converts this segment into the equivalent [`kurbo::PathSeg`], so it
60- /// can be used with the various curve algorithms `kurbo` provides (e.g.
61- /// evaluation, arc length).
62- pub fn to_path_seg ( & self ) -> PathSeg {
63- match self . rest {
64- CubicSegment :: Line ( end) => PathSeg :: Line ( Line :: new ( self . start , end) ) ,
58+ impl From < CubicSegmentFull > for PathSeg {
59+ fn from ( seg : CubicSegmentFull ) -> Self {
60+ match seg. rest {
61+ CubicSegment :: Line ( end) => PathSeg :: Line ( Line :: new ( seg. start , end) ) ,
6562 CubicSegment :: Curve ( c1, c2, end) => {
66- PathSeg :: Cubic ( CubicBez :: new ( self . start , c1, c2, end) )
63+ PathSeg :: Cubic ( CubicBez :: new ( seg . start , c1, c2, end) )
6764 }
6865 }
6966 }
@@ -116,10 +113,7 @@ impl CubicBezier {
116113 /// Evaluates the point at parameter `t` (in `[0, 1]`) on the given
117114 /// segment.
118115 pub fn point_at ( & self , segment : usize , t : f64 ) -> Point2D {
119- self . segment ( segment)
120- . expect ( "segment index out of bounds" )
121- . to_path_seg ( )
122- . eval ( t)
116+ PathSeg :: from ( self . segment ( segment) . expect ( "segment index out of bounds" ) ) . eval ( t)
123117 }
124118
125119 pub fn reversed ( & self ) -> Self {
0 commit comments