cubicbezier-0.6.0.6: Efficient manipulating of 2D cubic bezier curves.

Geom2D.CubicBezier.Basic

Synopsis

# Documentation

data CubicBezier a Source #

A cubic bezier curve.

Constructors

 CubicBezier FieldscubicC0 :: !(Point a) cubicC1 :: !(Point a) cubicC2 :: !(Point a) cubicC3 :: !(Point a)
Instances
 Source # Instance detailsDefined in Geom2D.CubicBezier.Basic Methodsfmap :: (a -> b) -> CubicBezier a -> CubicBezier b #(<$) :: a -> CubicBezier b -> CubicBezier a # Source # Instance detailsDefined in Geom2D.CubicBezier.Basic Methodsfold :: Monoid m => CubicBezier m -> m #foldMap :: Monoid m => (a -> m) -> CubicBezier a -> m #foldr :: (a -> b -> b) -> b -> CubicBezier a -> b #foldr' :: (a -> b -> b) -> b -> CubicBezier a -> b #foldl :: (b -> a -> b) -> b -> CubicBezier a -> b #foldl' :: (b -> a -> b) -> b -> CubicBezier a -> b #foldr1 :: (a -> a -> a) -> CubicBezier a -> a #foldl1 :: (a -> a -> a) -> CubicBezier a -> a #toList :: CubicBezier a -> [a] #null :: CubicBezier a -> Bool #length :: CubicBezier a -> Int #elem :: Eq a => a -> CubicBezier a -> Bool #maximum :: Ord a => CubicBezier a -> a #minimum :: Ord a => CubicBezier a -> a #sum :: Num a => CubicBezier a -> a #product :: Num a => CubicBezier a -> a # Source # Instance detailsDefined in Geom2D.CubicBezier.Basic Methodstraverse :: Applicative f => (a -> f b) -> CubicBezier a -> f (CubicBezier b) #sequenceA :: Applicative f => CubicBezier (f a) -> f (CubicBezier a) #mapM :: Monad m => (a -> m b) -> CubicBezier a -> m (CubicBezier b) #sequence :: Monad m => CubicBezier (m a) -> m (CubicBezier a) # Source # Instance detailsDefined in Geom2D.CubicBezier.Basic Methodsdegree :: Unbox a => CubicBezier a -> Int Source #toVector :: Unbox a => CubicBezier a -> Vector (a, a) Source #unsafeFromVector :: Unbox a => Vector (a, a) -> CubicBezier a Source # Eq a => Eq (CubicBezier a) Source # Instance detailsDefined in Geom2D.CubicBezier.Basic Methods(==) :: CubicBezier a -> CubicBezier a -> Bool #(/=) :: CubicBezier a -> CubicBezier a -> Bool # Show a => Show (CubicBezier a) Source # Instance detailsDefined in Geom2D.CubicBezier.Basic MethodsshowsPrec :: Int -> CubicBezier a -> ShowS #show :: CubicBezier a -> String #showList :: [CubicBezier a] -> ShowS # Num a => AffineTransform (CubicBezier a) a Source # Instance detailsDefined in Geom2D.CubicBezier.Basic Methods data QuadBezier a Source # A quadratic bezier curve. Constructors  QuadBezier FieldsquadC0 :: !(Point a) quadC1 :: !(Point a) quadC2 :: !(Point a) Instances  Source # Instance detailsDefined in Geom2D.CubicBezier.Basic Methodsfmap :: (a -> b) -> QuadBezier a -> QuadBezier b #(<$) :: a -> QuadBezier b -> QuadBezier a # Source # Instance detailsDefined in Geom2D.CubicBezier.Basic Methodsfold :: Monoid m => QuadBezier m -> m #foldMap :: Monoid m => (a -> m) -> QuadBezier a -> m #foldr :: (a -> b -> b) -> b -> QuadBezier a -> b #foldr' :: (a -> b -> b) -> b -> QuadBezier a -> b #foldl :: (b -> a -> b) -> b -> QuadBezier a -> b #foldl' :: (b -> a -> b) -> b -> QuadBezier a -> b #foldr1 :: (a -> a -> a) -> QuadBezier a -> a #foldl1 :: (a -> a -> a) -> QuadBezier a -> a #toList :: QuadBezier a -> [a] #null :: QuadBezier a -> Bool #length :: QuadBezier a -> Int #elem :: Eq a => a -> QuadBezier a -> Bool #maximum :: Ord a => QuadBezier a -> a #minimum :: Ord a => QuadBezier a -> a #sum :: Num a => QuadBezier a -> a #product :: Num a => QuadBezier a -> a # Source # Instance detailsDefined in Geom2D.CubicBezier.Basic Methodstraverse :: Applicative f => (a -> f b) -> QuadBezier a -> f (QuadBezier b) #sequenceA :: Applicative f => QuadBezier (f a) -> f (QuadBezier a) #mapM :: Monad m => (a -> m b) -> QuadBezier a -> m (QuadBezier b) #sequence :: Monad m => QuadBezier (m a) -> m (QuadBezier a) # Source # Instance detailsDefined in Geom2D.CubicBezier.Basic Methodsdegree :: Unbox a => QuadBezier a -> Int Source #toVector :: Unbox a => QuadBezier a -> Vector (a, a) Source #unsafeFromVector :: Unbox a => Vector (a, a) -> QuadBezier a Source # Eq a => Eq (QuadBezier a) Source # Instance detailsDefined in Geom2D.CubicBezier.Basic Methods(==) :: QuadBezier a -> QuadBezier a -> Bool #(/=) :: QuadBezier a -> QuadBezier a -> Bool # Show a => Show (QuadBezier a) Source # Instance detailsDefined in Geom2D.CubicBezier.Basic MethodsshowsPrec :: Int -> QuadBezier a -> ShowS #show :: QuadBezier a -> String #showList :: [QuadBezier a] -> ShowS # Num a => AffineTransform (QuadBezier a) a Source # Instance detailsDefined in Geom2D.CubicBezier.Basic Methods

data AnyBezier a Source #

A bezier curve of any degree.

Constructors

 AnyBezier (Vector (a, a))
Instances
 Source # Instance detailsDefined in Geom2D.CubicBezier.Basic Methodsdegree :: Unbox a => AnyBezier a -> Int Source #toVector :: Unbox a => AnyBezier a -> Vector (a, a) Source #unsafeFromVector :: Unbox a => Vector (a, a) -> AnyBezier a Source #

class GenericBezier b where Source #

Methods

degree :: Unbox a => b a -> Int Source #

toVector :: Unbox a => b a -> Vector (a, a) Source #

unsafeFromVector :: Unbox a => Vector (a, a) -> b a Source #

Instances
 Source # Instance detailsDefined in Geom2D.CubicBezier.Basic Methodsdegree :: Unbox a => AnyBezier a -> Int Source #toVector :: Unbox a => AnyBezier a -> Vector (a, a) Source #unsafeFromVector :: Unbox a => Vector (a, a) -> AnyBezier a Source # Source # Instance detailsDefined in Geom2D.CubicBezier.Basic Methodsdegree :: Unbox a => QuadBezier a -> Int Source #toVector :: Unbox a => QuadBezier a -> Vector (a, a) Source #unsafeFromVector :: Unbox a => Vector (a, a) -> QuadBezier a Source # Source # Instance detailsDefined in Geom2D.CubicBezier.Basic Methodsdegree :: Unbox a => CubicBezier a -> Int Source #toVector :: Unbox a => CubicBezier a -> Vector (a, a) Source #unsafeFromVector :: Unbox a => Vector (a, a) -> CubicBezier a Source #

data PathJoin a Source #

Constructors

 JoinLine JoinCurve (Point a) (Point a)
Instances
 Source # Instance detailsDefined in Geom2D.CubicBezier.Basic Methodsfmap :: (a -> b) -> PathJoin a -> PathJoin b #(<$) :: a -> PathJoin b -> PathJoin a # Source # Instance detailsDefined in Geom2D.CubicBezier.Basic Methodsfold :: Monoid m => PathJoin m -> m #foldMap :: Monoid m => (a -> m) -> PathJoin a -> m #foldr :: (a -> b -> b) -> b -> PathJoin a -> b #foldr' :: (a -> b -> b) -> b -> PathJoin a -> b #foldl :: (b -> a -> b) -> b -> PathJoin a -> b #foldl' :: (b -> a -> b) -> b -> PathJoin a -> b #foldr1 :: (a -> a -> a) -> PathJoin a -> a #foldl1 :: (a -> a -> a) -> PathJoin a -> a #toList :: PathJoin a -> [a] #null :: PathJoin a -> Bool #length :: PathJoin a -> Int #elem :: Eq a => a -> PathJoin a -> Bool #maximum :: Ord a => PathJoin a -> a #minimum :: Ord a => PathJoin a -> a #sum :: Num a => PathJoin a -> a #product :: Num a => PathJoin a -> a # Source # Instance detailsDefined in Geom2D.CubicBezier.Basic Methodstraverse :: Applicative f => (a -> f b) -> PathJoin a -> f (PathJoin b) #sequenceA :: Applicative f => PathJoin (f a) -> f (PathJoin a) #mapM :: Monad m => (a -> m b) -> PathJoin a -> m (PathJoin b) #sequence :: Monad m => PathJoin (m a) -> m (PathJoin a) # Show a => Show (PathJoin a) Source # Instance detailsDefined in Geom2D.CubicBezier.Basic MethodsshowsPrec :: Int -> PathJoin a -> ShowS #show :: PathJoin a -> String #showList :: [PathJoin a] -> ShowS # Num a => AffineTransform (PathJoin a) a Source # Instance detailsDefined in Geom2D.CubicBezier.Basic Methodstransform :: Transform a -> PathJoin a -> PathJoin a Source # data ClosedPath a Source # Constructors  ClosedPath [(Point a, PathJoin a)] Instances  Source # Instance detailsDefined in Geom2D.CubicBezier.Basic Methodsfmap :: (a -> b) -> ClosedPath a -> ClosedPath b #(<$) :: a -> ClosedPath b -> ClosedPath a # Source # Instance detailsDefined in Geom2D.CubicBezier.Basic Methodsfold :: Monoid m => ClosedPath m -> m #foldMap :: Monoid m => (a -> m) -> ClosedPath a -> m #foldr :: (a -> b -> b) -> b -> ClosedPath a -> b #foldr' :: (a -> b -> b) -> b -> ClosedPath a -> b #foldl :: (b -> a -> b) -> b -> ClosedPath a -> b #foldl' :: (b -> a -> b) -> b -> ClosedPath a -> b #foldr1 :: (a -> a -> a) -> ClosedPath a -> a #foldl1 :: (a -> a -> a) -> ClosedPath a -> a #toList :: ClosedPath a -> [a] #null :: ClosedPath a -> Bool #length :: ClosedPath a -> Int #elem :: Eq a => a -> ClosedPath a -> Bool #maximum :: Ord a => ClosedPath a -> a #minimum :: Ord a => ClosedPath a -> a #sum :: Num a => ClosedPath a -> a #product :: Num a => ClosedPath a -> a # Source # Instance detailsDefined in Geom2D.CubicBezier.Basic Methodstraverse :: Applicative f => (a -> f b) -> ClosedPath a -> f (ClosedPath b) #sequenceA :: Applicative f => ClosedPath (f a) -> f (ClosedPath a) #mapM :: Monad m => (a -> m b) -> ClosedPath a -> m (ClosedPath b) #sequence :: Monad m => ClosedPath (m a) -> m (ClosedPath a) # Show a => Show (ClosedPath a) Source # Instance detailsDefined in Geom2D.CubicBezier.Basic MethodsshowsPrec :: Int -> ClosedPath a -> ShowS #show :: ClosedPath a -> String #showList :: [ClosedPath a] -> ShowS # Num a => AffineTransform (ClosedPath a) a Source # Instance detailsDefined in Geom2D.CubicBezier.Basic Methods

data OpenPath a Source #

Constructors

 OpenPath [(Point a, PathJoin a)] (Point a)
Instances
 Source # Instance detailsDefined in Geom2D.CubicBezier.Basic Methodsfmap :: (a -> b) -> OpenPath a -> OpenPath b #(<\$) :: a -> OpenPath b -> OpenPath a # Source # Instance detailsDefined in Geom2D.CubicBezier.Basic Methodsfold :: Monoid m => OpenPath m -> m #foldMap :: Monoid m => (a -> m) -> OpenPath a -> m #foldr :: (a -> b -> b) -> b -> OpenPath a -> b #foldr' :: (a -> b -> b) -> b -> OpenPath a -> b #foldl :: (b -> a -> b) -> b -> OpenPath a -> b #foldl' :: (b -> a -> b) -> b -> OpenPath a -> b #foldr1 :: (a -> a -> a) -> OpenPath a -> a #foldl1 :: (a -> a -> a) -> OpenPath a -> a #toList :: OpenPath a -> [a] #null :: OpenPath a -> Bool #length :: OpenPath a -> Int #elem :: Eq a => a -> OpenPath a -> Bool #maximum :: Ord a => OpenPath a -> a #minimum :: Ord a => OpenPath a -> a #sum :: Num a => OpenPath a -> a #product :: Num a => OpenPath a -> a # Source # Instance detailsDefined in Geom2D.CubicBezier.Basic Methodstraverse :: Applicative f => (a -> f b) -> OpenPath a -> f (OpenPath b) #sequenceA :: Applicative f => OpenPath (f a) -> f (OpenPath a) #mapM :: Monad m => (a -> m b) -> OpenPath a -> m (OpenPath b) #sequence :: Monad m => OpenPath (m a) -> m (OpenPath a) # Show a => Show (OpenPath a) Source # Instance detailsDefined in Geom2D.CubicBezier.Basic MethodsshowsPrec :: Int -> OpenPath a -> ShowS #show :: OpenPath a -> String #showList :: [OpenPath a] -> ShowS # Source # Instance detailsDefined in Geom2D.CubicBezier.Basic Methods(<>) :: OpenPath a -> OpenPath a -> OpenPath a #sconcat :: NonEmpty (OpenPath a) -> OpenPath a #stimes :: Integral b => b -> OpenPath a -> OpenPath a # Source # Instance detailsDefined in Geom2D.CubicBezier.Basic Methodsmappend :: OpenPath a -> OpenPath a -> OpenPath a #mconcat :: [OpenPath a] -> OpenPath a # Num a => AffineTransform (OpenPath a) a Source # Instance detailsDefined in Geom2D.CubicBezier.Basic Methodstransform :: Transform a -> OpenPath a -> OpenPath a Source #

class AffineTransform a b | a -> b where Source #

Methods

transform :: Transform b -> a -> a Source #

Instances
 Num a => AffineTransform (Polygon a) a Source # Instance detailsDefined in Geom2D Methodstransform :: Transform a -> Polygon a -> Polygon a Source # Num a => AffineTransform (Transform a) a Source # Instance detailsDefined in Geom2D Methodstransform :: Transform a -> Transform a -> Transform a Source # Num a => AffineTransform (Point a) a Source # Instance detailsDefined in Geom2D Methodstransform :: Transform a -> Point a -> Point a Source # Num a => AffineTransform (ClosedPath a) a Source # Instance detailsDefined in Geom2D.CubicBezier.Basic Methods Num a => AffineTransform (OpenPath a) a Source # Instance detailsDefined in Geom2D.CubicBezier.Basic Methodstransform :: Transform a -> OpenPath a -> OpenPath a Source # Num a => AffineTransform (PathJoin a) a Source # Instance detailsDefined in Geom2D.CubicBezier.Basic Methodstransform :: Transform a -> PathJoin a -> PathJoin a Source # Num a => AffineTransform (QuadBezier a) a Source # Instance detailsDefined in Geom2D.CubicBezier.Basic Methods Num a => AffineTransform (CubicBezier a) a Source # Instance detailsDefined in Geom2D.CubicBezier.Basic Methods (Floating a, Eq a) => AffineTransform (Pen a) a Source # Instance detailsDefined in Geom2D.CubicBezier.Stroke Methodstransform :: Transform a -> Pen a -> Pen a Source #

anyToCubic :: Unbox a => AnyBezier a -> Maybe (CubicBezier a) Source #

safely convert from AnyBezier to CubicBezier

anyToQuad :: Unbox a => AnyBezier a -> Maybe (QuadBezier a) Source #

safely convert from AnyBezier to QuadBezier

openPathCurves :: Fractional a => OpenPath a -> [CubicBezier a] Source #

Return the open path as a list of curves.

closedPathCurves :: Fractional a => ClosedPath a -> [CubicBezier a] Source #

Return the closed path as a list of curves

curvesToOpen :: [CubicBezier a] -> OpenPath a Source #

Make an open path from a list of curves. The last control point of each curve except the last is ignored.

Make an open path from a list of curves. The last control point of each curve is ignored.

consOpenPath :: Point a -> PathJoin a -> OpenPath a -> OpenPath a Source #

construct an open path

consClosedPath :: Point a -> PathJoin a -> ClosedPath a -> ClosedPath a Source #

construct a closed path

open a closed path

close an open path, discarding the last point

bezierParam :: (Ord a, Num a) => a -> Bool Source #

Return True if the param lies on the curve, iff it's in the interval [0, 1].

Convert a tolerance from the codomain to the domain of the bezier curve, by dividing by the maximum velocity on the curve. The estimate is conservative, but holds for any value on the curve.

reorient :: (GenericBezier b, Unbox a) => b a -> b a Source #

Reorient to the curve B(1-t).

bezierToBernstein :: (GenericBezier b, Unbox a) => b a -> (BernsteinPoly a, BernsteinPoly a) Source #

Give the bernstein polynomial for each coordinate.

evalBezierDerivs :: (GenericBezier b, Unbox a, Fractional a) => b a -> a -> [Point a] Source #

Evaluate the bezier and all its derivatives using the modified horner algorithm.

evalBezier :: (GenericBezier b, Unbox a, Fractional a) => b a -> a -> Point a Source #

Calculate a value on the bezier curve.

evalBezierDeriv :: (Unbox a, Fractional a) => GenericBezier b => b a -> a -> (Point a, Point a) Source #

Calculate a value and the first derivative on the curve.

findBezierTangent p b finds the parameters where the tangent of the bezier curve b has the same direction as vector p.

Convert a quadratic bezier to a cubic bezier.

Find the parameter where the bezier curve is horizontal.

Find the parameter where the bezier curve is vertical.

Find inflection points on the curve. Use the formula B_x''(t) * B_y'(t) - B_y''(t) * B_x'(t) = 0 with B_x'(t) the x value of the first derivative at t, B_y''(t) the y value of the second derivative at t

Find the cusps of a bezier.

bezierArc startAngle endAngle approximates an arc on the unit circle with a single cubic béziér curve. Maximum deviation is <0.03% for arcs 90° degrees or less.

@arcLength c t tol finds the arclength of the bezier c at t, within given tolerance tol.

arcLengthParam c len tol finds the parameter where the curve c has the arclength len, within tolerance tol.

splitBezier :: (Unbox a, Fractional a) => GenericBezier b => b a -> a -> (b a, b a) Source #

Split a bezier curve into two curves.

bezierSubsegment :: (Ord a, Unbox a, Fractional a) => GenericBezier b => b a -> a -> a -> b a Source #

Return the subsegment between the two parameters.

splitBezierN :: (Ord a, Unbox a, Fractional a) => GenericBezier b => b a -> [a] -> [b a] Source #

Split a bezier curve into a list of beziers The parameters should be in ascending order or the result is unpredictable.

Return False if some points fall outside a line with a thickness of the given tolerance.

Find the closest value on the bezier to the given point, within tolerance. Return the first value found.

Find the x value of the cubic bezier. The bezier must be monotonically increasing in the X coordinate.