fix bug in reverseSpline

This commit is contained in:
sheaf 2021-02-25 14:04:54 +01:00
parent 46275514ff
commit c6694e4e2f
2 changed files with 7 additions and 7 deletions

View file

@ -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

View file

@ -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