{-# LANGUAGE TemplateHaskell #-}
--------------------------------------------------------------------------------
-- |
-- Module      :  Ipe.Path
-- Copyright   :  (C) Frank Staals
-- License     :  see the LICENSE file
-- Maintainer  :  Frank Staals
--
-- Defines an Ipe Path.
--
--------------------------------------------------------------------------------
module Ipe.Path(
    Path(Path), pathSegments
  , PathSegment(..)

  , _PolyLineSegment
  , _PolygonPath
  , _CubicBezierSegment
  , _QuadraticBezierSegment
  , _EllipseSegment
  , _ArcSegment
  , _SplineSegment
  , _ClosedSplineSegment

  , Orientation(..)
  , Operation(..)
  , _MoveTo
  , _LineTo
  , _CurveTo
  , _QCurveTo
  , _Ellipse
  , _ArcTo
  , _Spline
  , _ClosedSpline
  , _ClosePath
  ) where

import           Control.Lens hiding (rmap, elements)
import qualified Data.Sequence as Seq
import           Data.Traversable
import           GHC.Generics (Generic)
import           HGeometry.BezierSpline
import           HGeometry.Ellipse (Ellipse)
import           HGeometry.Matrix
import           HGeometry.Point
import           HGeometry.PolyLine
import           HGeometry.Polygon.Simple
import           HGeometry.Properties
import           HGeometry.Transformation

--------------------------------------------------------------------------------
-- | Paths

-- | Polygons in ipe may be given in CCW order, or in CW order. Since simple polygon
-- normalizes the order, we actually store the original orientation.
data Orientation = AsIs | Reversed
  deriving (Int -> Orientation -> ShowS
[Orientation] -> ShowS
Orientation -> String
(Int -> Orientation -> ShowS)
-> (Orientation -> String)
-> ([Orientation] -> ShowS)
-> Show Orientation
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Orientation -> ShowS
showsPrec :: Int -> Orientation -> ShowS
$cshow :: Orientation -> String
show :: Orientation -> String
$cshowList :: [Orientation] -> ShowS
showList :: [Orientation] -> ShowS
Show,Orientation -> Orientation -> Bool
(Orientation -> Orientation -> Bool)
-> (Orientation -> Orientation -> Bool) -> Eq Orientation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Orientation -> Orientation -> Bool
== :: Orientation -> Orientation -> Bool
$c/= :: Orientation -> Orientation -> Bool
/= :: Orientation -> Orientation -> Bool
Eq,Eq Orientation
Eq Orientation =>
(Orientation -> Orientation -> Ordering)
-> (Orientation -> Orientation -> Bool)
-> (Orientation -> Orientation -> Bool)
-> (Orientation -> Orientation -> Bool)
-> (Orientation -> Orientation -> Bool)
-> (Orientation -> Orientation -> Orientation)
-> (Orientation -> Orientation -> Orientation)
-> Ord Orientation
Orientation -> Orientation -> Bool
Orientation -> Orientation -> Ordering
Orientation -> Orientation -> Orientation
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: Orientation -> Orientation -> Ordering
compare :: Orientation -> Orientation -> Ordering
$c< :: Orientation -> Orientation -> Bool
< :: Orientation -> Orientation -> Bool
$c<= :: Orientation -> Orientation -> Bool
<= :: Orientation -> Orientation -> Bool
$c> :: Orientation -> Orientation -> Bool
> :: Orientation -> Orientation -> Bool
$c>= :: Orientation -> Orientation -> Bool
>= :: Orientation -> Orientation -> Bool
$cmax :: Orientation -> Orientation -> Orientation
max :: Orientation -> Orientation -> Orientation
$cmin :: Orientation -> Orientation -> Orientation
min :: Orientation -> Orientation -> Orientation
Ord)

-- | Paths consist of Path Segments. PathSegments come in the following forms:
data PathSegment r = PolyLineSegment        (PolyLine (Point 2 r))
                   | PolygonPath            {-# UNPACK #-}!Orientation
                                            (SimplePolygon (Point 2 r))
                   | CubicBezierSegment     (CubicBezier (Point 2 r))
                   | QuadraticBezierSegment (QuadraticBezier (Point 2 r))
                   | EllipseSegment         (Ellipse r)
                     -- TODO
                   | ArcSegment
                   | SplineSegment          -- (Spline 2 r)
                   | ClosedSplineSegment    -- (ClosedSpline 2 r)
                   deriving (Int -> PathSegment r -> ShowS
[PathSegment r] -> ShowS
PathSegment r -> String
(Int -> PathSegment r -> ShowS)
-> (PathSegment r -> String)
-> ([PathSegment r] -> ShowS)
-> Show (PathSegment r)
forall r. Show r => Int -> PathSegment r -> ShowS
forall r. Show r => [PathSegment r] -> ShowS
forall r. Show r => PathSegment r -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall r. Show r => Int -> PathSegment r -> ShowS
showsPrec :: Int -> PathSegment r -> ShowS
$cshow :: forall r. Show r => PathSegment r -> String
show :: PathSegment r -> String
$cshowList :: forall r. Show r => [PathSegment r] -> ShowS
showList :: [PathSegment r] -> ShowS
Show,PathSegment r -> PathSegment r -> Bool
(PathSegment r -> PathSegment r -> Bool)
-> (PathSegment r -> PathSegment r -> Bool) -> Eq (PathSegment r)
forall r. Eq r => PathSegment r -> PathSegment r -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall r. Eq r => PathSegment r -> PathSegment r -> Bool
== :: PathSegment r -> PathSegment r -> Bool
$c/= :: forall r. Eq r => PathSegment r -> PathSegment r -> Bool
/= :: PathSegment r -> PathSegment r -> Bool
Eq)
makePrisms ''PathSegment

type instance NumType   (PathSegment r) = r
type instance Dimension (PathSegment r) = 2

instance Functor PathSegment where
  fmap :: forall a b. (a -> b) -> PathSegment a -> PathSegment b
fmap = (a -> b) -> PathSegment a -> PathSegment b
forall (t :: * -> *) a b. Traversable t => (a -> b) -> t a -> t b
fmapDefault
instance Foldable PathSegment where
  foldMap :: forall m a. Monoid m => (a -> m) -> PathSegment a -> m
foldMap = (a -> m) -> PathSegment a -> m
forall (t :: * -> *) m a.
(Traversable t, Monoid m) =>
(a -> m) -> t a -> m
foldMapDefault
instance Traversable PathSegment where
  traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> PathSegment a -> f (PathSegment b)
traverse a -> f b
f = \case
      PolyLineSegment PolyLine (Point 2 a)
p        -> PolyLine (Point 2 b) -> PathSegment b
forall r. PolyLine (Point 2 r) -> PathSegment r
PolyLineSegment
                                  (PolyLine (Point 2 b) -> PathSegment b)
-> f (PolyLine (Point 2 b)) -> f (PathSegment b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> LensLike f (PolyLine (Point 2 a)) (PolyLine (Point 2 b)) a b
-> LensLike f (PolyLine (Point 2 a)) (PolyLine (Point 2 b)) a b
forall (f :: * -> *) s t a b.
LensLike f s t a b -> LensLike f s t a b
traverseOf (ATraversal (PolyLine (Point 2 a)) (PolyLine (Point 2 b)) a b
-> Traversal (PolyLine (Point 2 a)) (PolyLine (Point 2 b)) a b
forall s t a b. ATraversal s t a b -> Traversal s t a b
cloneTraversal (ATraversal (PolyLine (Point 2 a)) (PolyLine (Point 2 b)) a b
 -> Traversal (PolyLine (Point 2 a)) (PolyLine (Point 2 b)) a b)
-> ATraversal (PolyLine (Point 2 a)) (PolyLine (Point 2 b)) a b
-> Traversal (PolyLine (Point 2 a)) (PolyLine (Point 2 b)) a b
forall a b. (a -> b) -> a -> b
$ (Vertex (PolyLine (Point 2 a))
 -> Bazaar (->) a b (Vertex (PolyLine (Point 2 b))))
-> PolyLine (Point 2 a) -> Bazaar (->) a b (PolyLine (Point 2 b))
(Point 2 a -> Bazaar (->) a b (Point 2 b))
-> PolyLine (Point 2 a) -> Bazaar (->) a b (PolyLine (Point 2 b))
forall graph graph'.
HasVertices graph graph' =>
IndexedTraversal1
  (VertexIx graph) graph graph' (Vertex graph) (Vertex graph')
IndexedTraversal1
  (VertexIx (PolyLine (Point 2 a)))
  (PolyLine (Point 2 a))
  (PolyLine (Point 2 b))
  (Vertex (PolyLine (Point 2 a)))
  (Vertex (PolyLine (Point 2 b)))
vertices((Point 2 a -> Bazaar (->) a b (Point 2 b))
 -> PolyLine (Point 2 a) -> Bazaar (->) a b (PolyLine (Point 2 b)))
-> ((a -> Bazaar (->) a b b)
    -> Point 2 a -> Bazaar (->) a b (Point 2 b))
-> ATraversal (PolyLine (Point 2 a)) (PolyLine (Point 2 b)) a b
forall b c a. (b -> c) -> (a -> b) -> a -> c
.(a -> Bazaar (->) a b b)
-> Point 2 a -> Bazaar (->) a b (Point 2 b)
(NumType (Point 2 a) -> Bazaar (->) a b (NumType (Point 2 b)))
-> Point 2 a -> Bazaar (->) a b (Point 2 b)
forall point point'.
HasCoordinates point point' =>
IndexedTraversal1 Int point point' (NumType point) (NumType point')
IndexedTraversal1
  Int
  (Point 2 a)
  (Point 2 b)
  (NumType (Point 2 a))
  (NumType (Point 2 b))
coordinates) a -> f b
f PolyLine (Point 2 a)
p
      PolygonPath Orientation
o SimplePolygon (Point 2 a)
p          -> Orientation -> SimplePolygon (Point 2 b) -> PathSegment b
forall r. Orientation -> SimplePolygon (Point 2 r) -> PathSegment r
PolygonPath Orientation
o
                                  (SimplePolygon (Point 2 b) -> PathSegment b)
-> f (SimplePolygon (Point 2 b)) -> f (PathSegment b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> LensLike
  f (SimplePolygon (Point 2 a)) (SimplePolygon (Point 2 b)) a b
-> LensLike
     f (SimplePolygon (Point 2 a)) (SimplePolygon (Point 2 b)) a b
forall (f :: * -> *) s t a b.
LensLike f s t a b -> LensLike f s t a b
traverseOf (ATraversal
  (SimplePolygon (Point 2 a)) (SimplePolygon (Point 2 b)) a b
-> Traversal
     (SimplePolygon (Point 2 a)) (SimplePolygon (Point 2 b)) a b
forall s t a b. ATraversal s t a b -> Traversal s t a b
cloneTraversal (ATraversal
   (SimplePolygon (Point 2 a)) (SimplePolygon (Point 2 b)) a b
 -> Traversal
      (SimplePolygon (Point 2 a)) (SimplePolygon (Point 2 b)) a b)
-> ATraversal
     (SimplePolygon (Point 2 a)) (SimplePolygon (Point 2 b)) a b
-> Traversal
     (SimplePolygon (Point 2 a)) (SimplePolygon (Point 2 b)) a b
forall a b. (a -> b) -> a -> b
$ (Vertex (SimplePolygon (Point 2 a))
 -> Bazaar (->) a b (Vertex (SimplePolygon (Point 2 b))))
-> SimplePolygon (Point 2 a)
-> Bazaar (->) a b (SimplePolygon (Point 2 b))
(Point 2 a -> Bazaar (->) a b (Point 2 b))
-> SimplePolygon (Point 2 a)
-> Bazaar (->) a b (SimplePolygon (Point 2 b))
forall graph graph'.
HasVertices graph graph' =>
IndexedTraversal1
  (VertexIx graph) graph graph' (Vertex graph) (Vertex graph')
IndexedTraversal1
  (VertexIx (SimplePolygon (Point 2 a)))
  (SimplePolygon (Point 2 a))
  (SimplePolygon (Point 2 b))
  (Vertex (SimplePolygon (Point 2 a)))
  (Vertex (SimplePolygon (Point 2 b)))
vertices((Point 2 a -> Bazaar (->) a b (Point 2 b))
 -> SimplePolygon (Point 2 a)
 -> Bazaar (->) a b (SimplePolygon (Point 2 b)))
-> ((a -> Bazaar (->) a b b)
    -> Point 2 a -> Bazaar (->) a b (Point 2 b))
-> ATraversal
     (SimplePolygon (Point 2 a)) (SimplePolygon (Point 2 b)) a b
forall b c a. (b -> c) -> (a -> b) -> a -> c
.(a -> Bazaar (->) a b b)
-> Point 2 a -> Bazaar (->) a b (Point 2 b)
(NumType (Point 2 a) -> Bazaar (->) a b (NumType (Point 2 b)))
-> Point 2 a -> Bazaar (->) a b (Point 2 b)
forall point point'.
HasCoordinates point point' =>
IndexedTraversal1 Int point point' (NumType point) (NumType point')
IndexedTraversal1
  Int
  (Point 2 a)
  (Point 2 b)
  (NumType (Point 2 a))
  (NumType (Point 2 b))
coordinates) a -> f b
f SimplePolygon (Point 2 a)
p
      CubicBezierSegment CubicBezier (Point 2 a)
b     -> CubicBezier (Point 2 b) -> PathSegment b
forall r. CubicBezier (Point 2 r) -> PathSegment r
CubicBezierSegment
                                  (CubicBezier (Point 2 b) -> PathSegment b)
-> f (CubicBezier (Point 2 b)) -> f (PathSegment b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> LensLike f (CubicBezier (Point 2 a)) (CubicBezier (Point 2 b)) a b
-> LensLike
     f (CubicBezier (Point 2 a)) (CubicBezier (Point 2 b)) a b
forall (f :: * -> *) s t a b.
LensLike f s t a b -> LensLike f s t a b
traverseOf (ATraversal (CubicBezier (Point 2 a)) (CubicBezier (Point 2 b)) a b
-> Traversal
     (CubicBezier (Point 2 a)) (CubicBezier (Point 2 b)) a b
forall s t a b. ATraversal s t a b -> Traversal s t a b
cloneTraversal (ATraversal (CubicBezier (Point 2 a)) (CubicBezier (Point 2 b)) a b
 -> Traversal
      (CubicBezier (Point 2 a)) (CubicBezier (Point 2 b)) a b)
-> ATraversal
     (CubicBezier (Point 2 a)) (CubicBezier (Point 2 b)) a b
-> Traversal
     (CubicBezier (Point 2 a)) (CubicBezier (Point 2 b)) a b
forall a b. (a -> b) -> a -> b
$ (Vertex (CubicBezier (Point 2 a))
 -> Bazaar (->) a b (Vertex (CubicBezier (Point 2 b))))
-> CubicBezier (Point 2 a)
-> Bazaar (->) a b (CubicBezier (Point 2 b))
(Point 2 a -> Bazaar (->) a b (Point 2 b))
-> CubicBezier (Point 2 a)
-> Bazaar (->) a b (CubicBezier (Point 2 b))
forall graph graph'.
HasVertices graph graph' =>
IndexedTraversal1
  (VertexIx graph) graph graph' (Vertex graph) (Vertex graph')
IndexedTraversal1
  (VertexIx (CubicBezier (Point 2 a)))
  (CubicBezier (Point 2 a))
  (CubicBezier (Point 2 b))
  (Vertex (CubicBezier (Point 2 a)))
  (Vertex (CubicBezier (Point 2 b)))
vertices((Point 2 a -> Bazaar (->) a b (Point 2 b))
 -> CubicBezier (Point 2 a)
 -> Bazaar (->) a b (CubicBezier (Point 2 b)))
-> ((a -> Bazaar (->) a b b)
    -> Point 2 a -> Bazaar (->) a b (Point 2 b))
-> ATraversal
     (CubicBezier (Point 2 a)) (CubicBezier (Point 2 b)) a b
forall b c a. (b -> c) -> (a -> b) -> a -> c
.(a -> Bazaar (->) a b b)
-> Point 2 a -> Bazaar (->) a b (Point 2 b)
(NumType (Point 2 a) -> Bazaar (->) a b (NumType (Point 2 b)))
-> Point 2 a -> Bazaar (->) a b (Point 2 b)
forall point point'.
HasCoordinates point point' =>
IndexedTraversal1 Int point point' (NumType point) (NumType point')
IndexedTraversal1
  Int
  (Point 2 a)
  (Point 2 b)
  (NumType (Point 2 a))
  (NumType (Point 2 b))
coordinates) a -> f b
f CubicBezier (Point 2 a)
b
      QuadraticBezierSegment QuadraticBezier (Point 2 a)
b -> QuadraticBezier (Point 2 b) -> PathSegment b
forall r. QuadraticBezier (Point 2 r) -> PathSegment r
QuadraticBezierSegment
                                  (QuadraticBezier (Point 2 b) -> PathSegment b)
-> f (QuadraticBezier (Point 2 b)) -> f (PathSegment b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> LensLike
  f (QuadraticBezier (Point 2 a)) (QuadraticBezier (Point 2 b)) a b
-> LensLike
     f (QuadraticBezier (Point 2 a)) (QuadraticBezier (Point 2 b)) a b
forall (f :: * -> *) s t a b.
LensLike f s t a b -> LensLike f s t a b
traverseOf (ATraversal
  (QuadraticBezier (Point 2 a)) (QuadraticBezier (Point 2 b)) a b
-> Traversal
     (QuadraticBezier (Point 2 a)) (QuadraticBezier (Point 2 b)) a b
forall s t a b. ATraversal s t a b -> Traversal s t a b
cloneTraversal (ATraversal
   (QuadraticBezier (Point 2 a)) (QuadraticBezier (Point 2 b)) a b
 -> Traversal
      (QuadraticBezier (Point 2 a)) (QuadraticBezier (Point 2 b)) a b)
-> ATraversal
     (QuadraticBezier (Point 2 a)) (QuadraticBezier (Point 2 b)) a b
-> Traversal
     (QuadraticBezier (Point 2 a)) (QuadraticBezier (Point 2 b)) a b
forall a b. (a -> b) -> a -> b
$ (Vertex (QuadraticBezier (Point 2 a))
 -> Bazaar (->) a b (Vertex (QuadraticBezier (Point 2 b))))
-> QuadraticBezier (Point 2 a)
-> Bazaar (->) a b (QuadraticBezier (Point 2 b))
(Point 2 a -> Bazaar (->) a b (Point 2 b))
-> QuadraticBezier (Point 2 a)
-> Bazaar (->) a b (QuadraticBezier (Point 2 b))
forall graph graph'.
HasVertices graph graph' =>
IndexedTraversal1
  (VertexIx graph) graph graph' (Vertex graph) (Vertex graph')
IndexedTraversal1
  (VertexIx (QuadraticBezier (Point 2 a)))
  (QuadraticBezier (Point 2 a))
  (QuadraticBezier (Point 2 b))
  (Vertex (QuadraticBezier (Point 2 a)))
  (Vertex (QuadraticBezier (Point 2 b)))
vertices((Point 2 a -> Bazaar (->) a b (Point 2 b))
 -> QuadraticBezier (Point 2 a)
 -> Bazaar (->) a b (QuadraticBezier (Point 2 b)))
-> ((a -> Bazaar (->) a b b)
    -> Point 2 a -> Bazaar (->) a b (Point 2 b))
-> ATraversal
     (QuadraticBezier (Point 2 a)) (QuadraticBezier (Point 2 b)) a b
forall b c a. (b -> c) -> (a -> b) -> a -> c
.(a -> Bazaar (->) a b b)
-> Point 2 a -> Bazaar (->) a b (Point 2 b)
(NumType (Point 2 a) -> Bazaar (->) a b (NumType (Point 2 b)))
-> Point 2 a -> Bazaar (->) a b (Point 2 b)
forall point point'.
HasCoordinates point point' =>
IndexedTraversal1 Int point point' (NumType point) (NumType point')
IndexedTraversal1
  Int
  (Point 2 a)
  (Point 2 b)
  (NumType (Point 2 a))
  (NumType (Point 2 b))
coordinates) a -> f b
f QuadraticBezier (Point 2 a)
b
      EllipseSegment Ellipse a
e         -> Ellipse b -> PathSegment b
forall r. Ellipse r -> PathSegment r
EllipseSegment (Ellipse b -> PathSegment b) -> f (Ellipse b) -> f (PathSegment b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (a -> f b) -> Ellipse a -> f (Ellipse b)
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Ellipse a -> f (Ellipse b)
traverse a -> f b
f Ellipse a
e
      PathSegment a
ArcSegment               -> PathSegment b -> f (PathSegment b)
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure PathSegment b
forall r. PathSegment r
ArcSegment
      PathSegment a
SplineSegment            -> PathSegment b -> f (PathSegment b)
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure PathSegment b
forall r. PathSegment r
SplineSegment
      PathSegment a
ClosedSplineSegment      -> PathSegment b -> f (PathSegment b)
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure PathSegment b
forall r. PathSegment r
ClosedSplineSegment


instance (Fractional r, Eq r) => IsTransformable (PathSegment r) where
  transformBy :: Transformation
  (Dimension (PathSegment r)) (NumType (PathSegment r))
-> PathSegment r -> PathSegment r
transformBy Transformation
  (Dimension (PathSegment r)) (NumType (PathSegment r))
t = \case
    PolyLineSegment PolyLine (Point 2 r)
p        -> PolyLine (Point 2 r) -> PathSegment r
forall r. PolyLine (Point 2 r) -> PathSegment r
PolyLineSegment (PolyLine (Point 2 r) -> PathSegment r)
-> PolyLine (Point 2 r) -> PathSegment r
forall a b. (a -> b) -> a -> b
$ Transformation
  (Dimension (PolyLine (Point 2 r))) (NumType (PolyLine (Point 2 r)))
-> PolyLine (Point 2 r) -> PolyLine (Point 2 r)
forall g.
IsTransformable g =>
Transformation (Dimension g) (NumType g) -> g -> g
transformBy Transformation
  (Dimension (PolyLine (Point 2 r))) (NumType (PolyLine (Point 2 r)))
Transformation
  (Dimension (PathSegment r)) (NumType (PathSegment r))
t PolyLine (Point 2 r)
p
    PolygonPath Orientation
o SimplePolygon (Point 2 r)
p          -> Orientation -> SimplePolygon (Point 2 r) -> PathSegment r
forall r. Orientation -> SimplePolygon (Point 2 r) -> PathSegment r
PolygonPath Orientation
o (Transformation
  (Dimension (SimplePolygon (Point 2 r)))
  (NumType (SimplePolygon (Point 2 r)))
-> SimplePolygon (Point 2 r) -> SimplePolygon (Point 2 r)
forall g.
IsTransformable g =>
Transformation (Dimension g) (NumType g) -> g -> g
transformBy Transformation
  (Dimension (SimplePolygon (Point 2 r)))
  (NumType (SimplePolygon (Point 2 r)))
Transformation
  (Dimension (PathSegment r)) (NumType (PathSegment r))
t SimplePolygon (Point 2 r)
p)
    CubicBezierSegment CubicBezier (Point 2 r)
b     -> CubicBezier (Point 2 r) -> PathSegment r
forall r. CubicBezier (Point 2 r) -> PathSegment r
CubicBezierSegment (CubicBezier (Point 2 r) -> PathSegment r)
-> CubicBezier (Point 2 r) -> PathSegment r
forall a b. (a -> b) -> a -> b
$ Transformation
  (Dimension (CubicBezier (Point 2 r)))
  (NumType (CubicBezier (Point 2 r)))
-> CubicBezier (Point 2 r) -> CubicBezier (Point 2 r)
forall g.
IsTransformable g =>
Transformation (Dimension g) (NumType g) -> g -> g
transformBy Transformation
  (Dimension (CubicBezier (Point 2 r)))
  (NumType (CubicBezier (Point 2 r)))
Transformation
  (Dimension (PathSegment r)) (NumType (PathSegment r))
t CubicBezier (Point 2 r)
b
    QuadraticBezierSegment QuadraticBezier (Point 2 r)
b -> QuadraticBezier (Point 2 r) -> PathSegment r
forall r. QuadraticBezier (Point 2 r) -> PathSegment r
QuadraticBezierSegment (QuadraticBezier (Point 2 r) -> PathSegment r)
-> QuadraticBezier (Point 2 r) -> PathSegment r
forall a b. (a -> b) -> a -> b
$ Transformation
  (Dimension (QuadraticBezier (Point 2 r)))
  (NumType (QuadraticBezier (Point 2 r)))
-> QuadraticBezier (Point 2 r) -> QuadraticBezier (Point 2 r)
forall g.
IsTransformable g =>
Transformation (Dimension g) (NumType g) -> g -> g
transformBy Transformation
  (Dimension (QuadraticBezier (Point 2 r)))
  (NumType (QuadraticBezier (Point 2 r)))
Transformation
  (Dimension (PathSegment r)) (NumType (PathSegment r))
t QuadraticBezier (Point 2 r)
b
    EllipseSegment Ellipse r
e         -> Ellipse r -> PathSegment r
forall r. Ellipse r -> PathSegment r
EllipseSegment (Ellipse r -> PathSegment r) -> Ellipse r -> PathSegment r
forall a b. (a -> b) -> a -> b
$ Transformation (Dimension (Ellipse r)) (NumType (Ellipse r))
-> Ellipse r -> Ellipse r
forall g.
IsTransformable g =>
Transformation (Dimension g) (NumType g) -> g -> g
transformBy Transformation (Dimension (Ellipse r)) (NumType (Ellipse r))
Transformation
  (Dimension (PathSegment r)) (NumType (PathSegment r))
t Ellipse r
e
    -- TODO:
    PathSegment r
ArcSegment               -> PathSegment r
forall r. PathSegment r
ArcSegment
    PathSegment r
SplineSegment            -> PathSegment r
forall r. PathSegment r
SplineSegment
    PathSegment r
ClosedSplineSegment      -> PathSegment r
forall r. PathSegment r
ClosedSplineSegment


-- | A path is a non-empty sequence of PathSegments.
newtype Path r = Path { forall r. Path r -> Seq (PathSegment r)
_pathSegments :: Seq.Seq (PathSegment r) }
                 deriving (Int -> Path r -> ShowS
[Path r] -> ShowS
Path r -> String
(Int -> Path r -> ShowS)
-> (Path r -> String) -> ([Path r] -> ShowS) -> Show (Path r)
forall r. Show r => Int -> Path r -> ShowS
forall r. Show r => [Path r] -> ShowS
forall r. Show r => Path r -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall r. Show r => Int -> Path r -> ShowS
showsPrec :: Int -> Path r -> ShowS
$cshow :: forall r. Show r => Path r -> String
show :: Path r -> String
$cshowList :: forall r. Show r => [Path r] -> ShowS
showList :: [Path r] -> ShowS
Show,Path r -> Path r -> Bool
(Path r -> Path r -> Bool)
-> (Path r -> Path r -> Bool) -> Eq (Path r)
forall r. Eq r => Path r -> Path r -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall r. Eq r => Path r -> Path r -> Bool
== :: Path r -> Path r -> Bool
$c/= :: forall r. Eq r => Path r -> Path r -> Bool
/= :: Path r -> Path r -> Bool
Eq,(forall a b. (a -> b) -> Path a -> Path b)
-> (forall a b. a -> Path b -> Path a) -> Functor Path
forall a b. a -> Path b -> Path a
forall a b. (a -> b) -> Path a -> Path b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
$cfmap :: forall a b. (a -> b) -> Path a -> Path b
fmap :: forall a b. (a -> b) -> Path a -> Path b
$c<$ :: forall a b. a -> Path b -> Path a
<$ :: forall a b. a -> Path b -> Path a
Functor,(forall m. Monoid m => Path m -> m)
-> (forall m a. Monoid m => (a -> m) -> Path a -> m)
-> (forall m a. Monoid m => (a -> m) -> Path a -> m)
-> (forall a b. (a -> b -> b) -> b -> Path a -> b)
-> (forall a b. (a -> b -> b) -> b -> Path a -> b)
-> (forall b a. (b -> a -> b) -> b -> Path a -> b)
-> (forall b a. (b -> a -> b) -> b -> Path a -> b)
-> (forall a. (a -> a -> a) -> Path a -> a)
-> (forall a. (a -> a -> a) -> Path a -> a)
-> (forall a. Path a -> [a])
-> (forall a. Path a -> Bool)
-> (forall a. Path a -> Int)
-> (forall a. Eq a => a -> Path a -> Bool)
-> (forall a. Ord a => Path a -> a)
-> (forall a. Ord a => Path a -> a)
-> (forall a. Num a => Path a -> a)
-> (forall a. Num a => Path a -> a)
-> Foldable Path
forall a. Eq a => a -> Path a -> Bool
forall a. Num a => Path a -> a
forall a. Ord a => Path a -> a
forall m. Monoid m => Path m -> m
forall a. Path a -> Bool
forall a. Path a -> Int
forall a. Path a -> [a]
forall a. (a -> a -> a) -> Path a -> a
forall m a. Monoid m => (a -> m) -> Path a -> m
forall b a. (b -> a -> b) -> b -> Path a -> b
forall a b. (a -> b -> b) -> b -> Path a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
$cfold :: forall m. Monoid m => Path m -> m
fold :: forall m. Monoid m => Path m -> m
$cfoldMap :: forall m a. Monoid m => (a -> m) -> Path a -> m
foldMap :: forall m a. Monoid m => (a -> m) -> Path a -> m
$cfoldMap' :: forall m a. Monoid m => (a -> m) -> Path a -> m
foldMap' :: forall m a. Monoid m => (a -> m) -> Path a -> m
$cfoldr :: forall a b. (a -> b -> b) -> b -> Path a -> b
foldr :: forall a b. (a -> b -> b) -> b -> Path a -> b
$cfoldr' :: forall a b. (a -> b -> b) -> b -> Path a -> b
foldr' :: forall a b. (a -> b -> b) -> b -> Path a -> b
$cfoldl :: forall b a. (b -> a -> b) -> b -> Path a -> b
foldl :: forall b a. (b -> a -> b) -> b -> Path a -> b
$cfoldl' :: forall b a. (b -> a -> b) -> b -> Path a -> b
foldl' :: forall b a. (b -> a -> b) -> b -> Path a -> b
$cfoldr1 :: forall a. (a -> a -> a) -> Path a -> a
foldr1 :: forall a. (a -> a -> a) -> Path a -> a
$cfoldl1 :: forall a. (a -> a -> a) -> Path a -> a
foldl1 :: forall a. (a -> a -> a) -> Path a -> a
$ctoList :: forall a. Path a -> [a]
toList :: forall a. Path a -> [a]
$cnull :: forall a. Path a -> Bool
null :: forall a. Path a -> Bool
$clength :: forall a. Path a -> Int
length :: forall a. Path a -> Int
$celem :: forall a. Eq a => a -> Path a -> Bool
elem :: forall a. Eq a => a -> Path a -> Bool
$cmaximum :: forall a. Ord a => Path a -> a
maximum :: forall a. Ord a => Path a -> a
$cminimum :: forall a. Ord a => Path a -> a
minimum :: forall a. Ord a => Path a -> a
$csum :: forall a. Num a => Path a -> a
sum :: forall a. Num a => Path a -> a
$cproduct :: forall a. Num a => Path a -> a
product :: forall a. Num a => Path a -> a
Foldable,Functor Path
Foldable Path
(Functor Path, Foldable Path) =>
(forall (f :: * -> *) a b.
 Applicative f =>
 (a -> f b) -> Path a -> f (Path b))
-> (forall (f :: * -> *) a.
    Applicative f =>
    Path (f a) -> f (Path a))
-> (forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> Path a -> m (Path b))
-> (forall (m :: * -> *) a. Monad m => Path (m a) -> m (Path a))
-> Traversable Path
forall (t :: * -> *).
(Functor t, Foldable t) =>
(forall (f :: * -> *) a b.
 Applicative f =>
 (a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall (m :: * -> *) a. Monad m => Path (m a) -> m (Path a)
forall (f :: * -> *) a. Applicative f => Path (f a) -> f (Path a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Path a -> m (Path b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Path a -> f (Path b)
$ctraverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Path a -> f (Path b)
traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Path a -> f (Path b)
$csequenceA :: forall (f :: * -> *) a. Applicative f => Path (f a) -> f (Path a)
sequenceA :: forall (f :: * -> *) a. Applicative f => Path (f a) -> f (Path a)
$cmapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Path a -> m (Path b)
mapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Path a -> m (Path b)
$csequence :: forall (m :: * -> *) a. Monad m => Path (m a) -> m (Path a)
sequence :: forall (m :: * -> *) a. Monad m => Path (m a) -> m (Path a)
Traversable,(forall x. Path r -> Rep (Path r) x)
-> (forall x. Rep (Path r) x -> Path r) -> Generic (Path r)
forall x. Rep (Path r) x -> Path r
forall x. Path r -> Rep (Path r) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall r x. Rep (Path r) x -> Path r
forall r x. Path r -> Rep (Path r) x
$cfrom :: forall r x. Path r -> Rep (Path r) x
from :: forall x. Path r -> Rep (Path r) x
$cto :: forall r x. Rep (Path r) x -> Path r
to :: forall x. Rep (Path r) x -> Path r
Generic)
                 deriving newtype (NonEmpty (Path r) -> Path r
Path r -> Path r -> Path r
(Path r -> Path r -> Path r)
-> (NonEmpty (Path r) -> Path r)
-> (forall b. Integral b => b -> Path r -> Path r)
-> Semigroup (Path r)
forall b. Integral b => b -> Path r -> Path r
forall r. NonEmpty (Path r) -> Path r
forall r. Path r -> Path r -> Path r
forall a.
(a -> a -> a)
-> (NonEmpty a -> a)
-> (forall b. Integral b => b -> a -> a)
-> Semigroup a
forall r b. Integral b => b -> Path r -> Path r
$c<> :: forall r. Path r -> Path r -> Path r
<> :: Path r -> Path r -> Path r
$csconcat :: forall r. NonEmpty (Path r) -> Path r
sconcat :: NonEmpty (Path r) -> Path r
$cstimes :: forall r b. Integral b => b -> Path r -> Path r
stimes :: forall b. Integral b => b -> Path r -> Path r
Semigroup)

-- | Lens/Iso to access the sequcne of segments of the path
pathSegments :: Iso (Path r) (Path r') (Seq.Seq (PathSegment r)) (Seq.Seq (PathSegment r'))
pathSegments :: forall r r' (p :: * -> * -> *) (f :: * -> *).
(Profunctor p, Functor f) =>
p (Seq (PathSegment r)) (f (Seq (PathSegment r')))
-> p (Path r) (f (Path r'))
pathSegments = p (Seq (PathSegment r)) (f (Seq (PathSegment r')))
-> p (Path r) (f (Path r'))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Iso (Path r) (Path r') (Seq (PathSegment r)) (Seq (PathSegment r'))
coerced

type instance NumType   (Path r) = r
type instance Dimension (Path r) = 2

instance (Fractional r, Eq r) => IsTransformable (Path r) where
  transformBy :: Transformation (Dimension (Path r)) (NumType (Path r))
-> Path r -> Path r
transformBy Transformation (Dimension (Path r)) (NumType (Path r))
t (Path Seq (PathSegment r)
s) = Seq (PathSegment r) -> Path r
forall r. Seq (PathSegment r) -> Path r
Path (Seq (PathSegment r) -> Path r) -> Seq (PathSegment r) -> Path r
forall a b. (a -> b) -> a -> b
$ (PathSegment r -> PathSegment r)
-> Seq (PathSegment r) -> Seq (PathSegment r)
forall a b. (a -> b) -> Seq a -> Seq b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Transformation
  (Dimension (PathSegment r)) (NumType (PathSegment r))
-> PathSegment r -> PathSegment r
forall g.
IsTransformable g =>
Transformation (Dimension g) (NumType g) -> g -> g
transformBy Transformation
  (Dimension (PathSegment r)) (NumType (PathSegment r))
Transformation (Dimension (Path r)) (NumType (Path r))
t) Seq (PathSegment r)
s

--------------------------------------------------------------------------------

-- | type that represents a path in ipe.
data Operation r = MoveTo (Point 2 r)
                 | LineTo (Point 2 r)
                 | Ellipse (Matrix 3 3 r)
                 | ArcTo (Matrix 3 3 r) (Point 2 r)
                 | Spline [Point 2 r]
                 | ClosedSpline [Point 2 r]
                 | ClosePath
                 -- these should be deprecated
                 | CurveTo (Point 2 r) (Point 2 r) (Point 2 r)
                 | QCurveTo (Point 2 r) (Point 2 r)
                 deriving (Operation r -> Operation r -> Bool
(Operation r -> Operation r -> Bool)
-> (Operation r -> Operation r -> Bool) -> Eq (Operation r)
forall r. Eq r => Operation r -> Operation r -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall r. Eq r => Operation r -> Operation r -> Bool
== :: Operation r -> Operation r -> Bool
$c/= :: forall r. Eq r => Operation r -> Operation r -> Bool
/= :: Operation r -> Operation r -> Bool
Eq,Int -> Operation r -> ShowS
[Operation r] -> ShowS
Operation r -> String
(Int -> Operation r -> ShowS)
-> (Operation r -> String)
-> ([Operation r] -> ShowS)
-> Show (Operation r)
forall r. Show r => Int -> Operation r -> ShowS
forall r. Show r => [Operation r] -> ShowS
forall r. Show r => Operation r -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall r. Show r => Int -> Operation r -> ShowS
showsPrec :: Int -> Operation r -> ShowS
$cshow :: forall r. Show r => Operation r -> String
show :: Operation r -> String
$cshowList :: forall r. Show r => [Operation r] -> ShowS
showList :: [Operation r] -> ShowS
Show)
makePrisms ''Operation

instance Functor Operation where
  fmap :: forall a b. (a -> b) -> Operation a -> Operation b
fmap = (a -> b) -> Operation a -> Operation b
forall (t :: * -> *) a b. Traversable t => (a -> b) -> t a -> t b
fmapDefault
instance Foldable Operation where
  foldMap :: forall m a. Monoid m => (a -> m) -> Operation a -> m
foldMap = (a -> m) -> Operation a -> m
forall (t :: * -> *) m a.
(Traversable t, Monoid m) =>
(a -> m) -> t a -> m
foldMapDefault
instance Traversable Operation where
  traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Operation a -> f (Operation b)
traverse a -> f b
f = let coordinates' :: (NumType (Point 2 a) -> f (NumType (Point 2 b)))
-> Point 2 a -> f (Point 2 b)
coordinates' = ATraversal
  (Point 2 a) (Point 2 b) (NumType (Point 2 a)) (NumType (Point 2 b))
-> Traversal
     (Point 2 a) (Point 2 b) (NumType (Point 2 a)) (NumType (Point 2 b))
forall s t a b. ATraversal s t a b -> Traversal s t a b
cloneTraversal ATraversal
  (Point 2 a) (Point 2 b) (NumType (Point 2 a)) (NumType (Point 2 b))
forall point point'.
HasCoordinates point point' =>
IndexedTraversal1 Int point point' (NumType point) (NumType point')
IndexedTraversal1
  Int
  (Point 2 a)
  (Point 2 b)
  (NumType (Point 2 a))
  (NumType (Point 2 b))
coordinates
                   elements' :: (NumType (Matrix 3 3 a) -> f (NumType (Matrix 3 3 b)))
-> Matrix 3 3 a -> f (Matrix 3 3 b)
elements'    = ATraversal
  (Matrix 3 3 a)
  (Matrix 3 3 b)
  (NumType (Matrix 3 3 a))
  (NumType (Matrix 3 3 b))
-> Traversal
     (Matrix 3 3 a)
     (Matrix 3 3 b)
     (NumType (Matrix 3 3 a))
     (NumType (Matrix 3 3 b))
forall s t a b. ATraversal s t a b -> Traversal s t a b
cloneTraversal ATraversal
  (Matrix 3 3 a)
  (Matrix 3 3 b)
  (NumType (Matrix 3 3 a))
  (NumType (Matrix 3 3 b))
forall matrix matrix'.
HasElements matrix matrix' =>
IndexedTraversal1
  (Int, Int) matrix matrix' (NumType matrix) (NumType matrix')
IndexedTraversal1
  (Int, Int)
  (Matrix 3 3 a)
  (Matrix 3 3 b)
  (NumType (Matrix 3 3 a))
  (NumType (Matrix 3 3 b))
elements
               in \case
    MoveTo Point 2 a
p         -> Point 2 b -> Operation b
forall r. Point 2 r -> Operation r
MoveTo (Point 2 b -> Operation b) -> f (Point 2 b) -> f (Operation b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (NumType (Point 2 a) -> f (NumType (Point 2 b)))
-> Point 2 a -> f (Point 2 b)
coordinates' a -> f b
NumType (Point 2 a) -> f (NumType (Point 2 b))
f Point 2 a
p
    LineTo Point 2 a
p         -> Point 2 b -> Operation b
forall r. Point 2 r -> Operation r
LineTo (Point 2 b -> Operation b) -> f (Point 2 b) -> f (Operation b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (NumType (Point 2 a) -> f (NumType (Point 2 b)))
-> Point 2 a -> f (Point 2 b)
coordinates' a -> f b
NumType (Point 2 a) -> f (NumType (Point 2 b))
f Point 2 a
p
    Ellipse Matrix 3 3 a
m        -> Matrix 3 3 b -> Operation b
forall r. Matrix 3 3 r -> Operation r
Ellipse (Matrix 3 3 b -> Operation b)
-> f (Matrix 3 3 b) -> f (Operation b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (NumType (Matrix 3 3 a) -> f (NumType (Matrix 3 3 b)))
-> Matrix 3 3 a -> f (Matrix 3 3 b)
elements' a -> f b
NumType (Matrix 3 3 a) -> f (NumType (Matrix 3 3 b))
f Matrix 3 3 a
m
    ArcTo Matrix 3 3 a
m Point 2 a
p        -> Matrix 3 3 b -> Point 2 b -> Operation b
forall r. Matrix 3 3 r -> Point 2 r -> Operation r
ArcTo   (Matrix 3 3 b -> Point 2 b -> Operation b)
-> f (Matrix 3 3 b) -> f (Point 2 b -> Operation b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (NumType (Matrix 3 3 a) -> f (NumType (Matrix 3 3 b)))
-> Matrix 3 3 a -> f (Matrix 3 3 b)
elements' a -> f b
NumType (Matrix 3 3 a) -> f (NumType (Matrix 3 3 b))
f Matrix 3 3 a
m f (Point 2 b -> Operation b) -> f (Point 2 b) -> f (Operation b)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (NumType (Point 2 a) -> f (NumType (Point 2 b)))
-> Point 2 a -> f (Point 2 b)
coordinates' a -> f b
NumType (Point 2 a) -> f (NumType (Point 2 b))
f Point 2 a
p
    Spline [Point 2 a]
pts       -> [Point 2 b] -> Operation b
forall r. [Point 2 r] -> Operation r
Spline ([Point 2 b] -> Operation b) -> f [Point 2 b] -> f (Operation b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Point 2 a -> f (Point 2 b)) -> [Point 2 a] -> f [Point 2 b]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse ((NumType (Point 2 a) -> f (NumType (Point 2 b)))
-> Point 2 a -> f (Point 2 b)
coordinates' a -> f b
NumType (Point 2 a) -> f (NumType (Point 2 b))
f) [Point 2 a]
pts
    ClosedSpline [Point 2 a]
pts -> [Point 2 b] -> Operation b
forall r. [Point 2 r] -> Operation r
ClosedSpline  ([Point 2 b] -> Operation b) -> f [Point 2 b] -> f (Operation b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Point 2 a -> f (Point 2 b)) -> [Point 2 a] -> f [Point 2 b]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse ((NumType (Point 2 a) -> f (NumType (Point 2 b)))
-> Point 2 a -> f (Point 2 b)
coordinates' a -> f b
NumType (Point 2 a) -> f (NumType (Point 2 b))
f) [Point 2 a]
pts
    Operation a
ClosePath        -> Operation b -> f (Operation b)
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Operation b
forall r. Operation r
ClosePath
    CurveTo Point 2 a
p Point 2 a
q Point 2 a
r    -> Point 2 b -> Point 2 b -> Point 2 b -> Operation b
forall r. Point 2 r -> Point 2 r -> Point 2 r -> Operation r
CurveTo  (Point 2 b -> Point 2 b -> Point 2 b -> Operation b)
-> f (Point 2 b) -> f (Point 2 b -> Point 2 b -> Operation b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (NumType (Point 2 a) -> f (NumType (Point 2 b)))
-> Point 2 a -> f (Point 2 b)
coordinates' a -> f b
NumType (Point 2 a) -> f (NumType (Point 2 b))
f Point 2 a
p f (Point 2 b -> Point 2 b -> Operation b)
-> f (Point 2 b) -> f (Point 2 b -> Operation b)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (NumType (Point 2 a) -> f (NumType (Point 2 b)))
-> Point 2 a -> f (Point 2 b)
coordinates' a -> f b
NumType (Point 2 a) -> f (NumType (Point 2 b))
f Point 2 a
q f (Point 2 b -> Operation b) -> f (Point 2 b) -> f (Operation b)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (NumType (Point 2 a) -> f (NumType (Point 2 b)))
-> Point 2 a -> f (Point 2 b)
coordinates' a -> f b
NumType (Point 2 a) -> f (NumType (Point 2 b))
f Point 2 a
r
    QCurveTo Point 2 a
p Point 2 a
q     -> Point 2 b -> Point 2 b -> Operation b
forall r. Point 2 r -> Point 2 r -> Operation r
QCurveTo (Point 2 b -> Point 2 b -> Operation b)
-> f (Point 2 b) -> f (Point 2 b -> Operation b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (NumType (Point 2 a) -> f (NumType (Point 2 b)))
-> Point 2 a -> f (Point 2 b)
coordinates' a -> f b
NumType (Point 2 a) -> f (NumType (Point 2 b))
f Point 2 a
p f (Point 2 b -> Operation b) -> f (Point 2 b) -> f (Operation b)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (NumType (Point 2 a) -> f (NumType (Point 2 b)))
-> Point 2 a -> f (Point 2 b)
coordinates' a -> f b
NumType (Point 2 a) -> f (NumType (Point 2 b))
f Point 2 a
q