diff --git a/src/app/MetaBrush/Document/Draw.hs b/src/app/MetaBrush/Document/Draw.hs index cd4b4af..b4afd6d 100644 --- a/src/app/MetaBrush/Document/Draw.hs +++ b/src/app/MetaBrush/Document/Draw.hs @@ -213,7 +213,7 @@ addToAnchor anchor newSpline = over ( field' @"documentContent" . field' @"strok AnchorAtStart _ -> let setBrushData :: PointData () -> PointData brushData - setBrushData = set ( field @"brushParams" ) ( brushParams ( splineStart prevSpline ) ) + setBrushData = set ( field @"brushParams" ) ( brushParams ( splineStart prevSpline ) ) in fmap setBrushData ( reverseSpline newSpline ) <> prevSpline AnchorAtEnd _ -> let diff --git a/src/lib/Math/Bezier/Spline.hs b/src/lib/Math/Bezier/Spline.hs index dc47c26..8aee20c 100644 --- a/src/lib/Math/Bezier/Spline.hs +++ b/src/lib/Math/Bezier/Spline.hs @@ -276,12 +276,12 @@ reverseSpline spline@( Spline { splineStart = p0, splineCurves = OpenCurves curv prev :|> lst -> Spline { splineStart = openCurveEnd lst, splineCurves = OpenCurves ( go prev lst ) } where go :: Seq ( Curve Open crvData ptData ) -> Curve Open crvData ptData -> Seq ( Curve Open crvData ptData ) - go Empty ( LineTo _ dat ) = Empty :|> LineTo ( NextPoint p0 ) dat - go Empty ( Bezier2To p1 _ dat ) = Empty :|> Bezier2To p0 ( NextPoint p1 ) dat - go Empty ( Bezier3To p1 p2 _ dat ) = Empty :|> Bezier3To p0 p1 ( NextPoint p2 ) dat - go ( crvs :|> crv ) ( LineTo _ dat ) = go crvs crv :|> LineTo ( curveEnd crv ) dat - go ( crvs :|> crv ) ( Bezier2To p1 _ dat ) = go crvs crv :|> Bezier2To ( openCurveEnd crv ) ( NextPoint p1 ) dat - go ( crvs :|> crv ) ( Bezier3To p1 p2 _ dat ) = go crvs crv :|> Bezier3To ( openCurveEnd crv ) p1 ( NextPoint p2 ) dat + go Empty ( LineTo _ dat ) = LineTo ( NextPoint p0 ) dat :<| Empty + go Empty ( Bezier2To p1 _ dat ) = Bezier2To p1 ( NextPoint p0 ) dat :<| Empty + go Empty ( Bezier3To p1 p2 _ dat ) = Bezier3To p2 p1 ( NextPoint p0 ) dat :<| Empty + go ( crvs :|> crv ) ( LineTo _ dat ) = LineTo ( curveEnd crv ) dat :<| go crvs crv + go ( crvs :|> crv ) ( Bezier2To p1 _ dat ) = Bezier2To p1 ( NextPoint $ openCurveEnd crv ) dat :<| go crvs crv + go ( crvs :|> crv ) ( Bezier3To p1 p2 _ dat ) = Bezier3To p2 p1 ( NextPoint $ openCurveEnd crv ) dat :<| go crvs crv splineEnd :: Spline Open crvData ptData -> ptData splineEnd ( Spline { splineStart, splineCurves = OpenCurves curves } ) = case curves of