-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/

-- | Embedded domain-specific language for declarative graphics
--   
--   Diagrams is a flexible, extensible EDSL for creating graphics of many
--   types. Graphics can be created in arbitrary vector spaces and rendered
--   with multiple backends. diagrams-lib provides a standard library of
--   primitives and operations for creating diagrams. To get started using
--   it, see the Diagrams module, and refer to the tutorials and
--   documentation on the diagrams website,
--   http://projects.haskell.org/diagrams.
@package diagrams-lib
@version 1.3.0.8

-- | Diagrams may have attributes which affect the way they are
--   rendered. This module defines some common attributes relevant in 3D;
--   particular backends may also define more backend-specific attributes.
--   
--   Every attribute type must have a semigroup structure, that is,
--   an associative binary operation for combining two attributes into one.
--   Unless otherwise noted, all the attributes defined here use the
--   Last structure, that is, combining two attributes simply keeps
--   the second one and throws away the first. This means that child
--   attributes always override parent attributes.
module Diagrams.ThreeD.Attributes

-- | SurfaceColor is the inherent pigment of an object, assumed to
--   be opaque.
newtype SurfaceColor
SurfaceColor :: (Last (Colour Double)) -> SurfaceColor
_SurfaceColor :: Iso' SurfaceColor (Colour Double)

-- | Set the surface color.
sc :: HasStyle d => Colour Double -> d -> d

-- | Lens onto the surface colour of a style.
_sc :: Lens' (Style v n) (Maybe (Colour Double))

-- | Diffuse is the fraction of incident light reflected
--   diffusely, that is, in all directions. The actual light reflected is
--   the product of this value, the incident light, and the
--   SurfaceColor Attribute. For physical reasonableness,
--   Diffuse should have a value between 0 and 1; this is not
--   checked.
newtype Diffuse
Diffuse :: (Last Double) -> Diffuse

-- | Isomorphism between Diffuse and Double
_Diffuse :: Iso' Diffuse Double

-- | Set the diffuse reflectance.
diffuse :: HasStyle d => Double -> d -> d

-- | Lens onto the possible diffuse reflectance in a style.
_diffuse :: Lens' (Style v n) (Maybe Double)

-- | Ambient is an ad-hoc representation of indirect lighting. The
--   product of Ambient and SurfaceColor is added to the
--   light leaving an object due to diffuse and specular terms.
--   Ambient can be set per-object, and can be loosely thought of
--   as the product of indirect lighting incident on that object and the
--   diffuse reflectance.
newtype Ambient
Ambient :: (Last Double) -> Ambient
_Ambient :: Iso' Ambient Double

-- | Set the emittance due to ambient light.
ambient :: HasStyle d => Double -> d -> d

-- | Lens onto the possible ambience in a style.
_ambient :: Lens' (Style v n) (Maybe Double)

-- | A specular highlight has two terms, the intensity, between 0 and 1,
--   and the size. The highlight size is assumed to be the exponent in a
--   Phong shading model (though Backends are free to use a different
--   shading model). In this model, reasonable values are between 1 and 50
--   or so, with higher values for shinier objects. Physically, the
--   intensity and the value of Diffuse must add up to less than
--   1; this is not enforced.
data Specular
Specular :: Double -> Double -> Specular
[_specularIntensity] :: Specular -> Double
[_specularSize] :: Specular -> Double
specularSize :: Lens' Specular Double
specularIntensity :: Lens' Specular Double
newtype Highlight
Highlight :: (Last Specular) -> Highlight
_Highlight :: Iso' Highlight Specular

-- | Set the specular highlight.
highlight :: HasStyle d => Specular -> d -> d

-- | Lens onto the possible specular highlight in a style
_highlight :: Lens' (Style v n) (Maybe Specular)

-- | Traversal over the highlight intensity of a style. If the style has no
--   Specular, setting this will do nothing.
highlightIntensity :: Traversal' (Style v n) Double

-- | Traversal over the highlight size in a style. If the style has no
--   Specular, setting this will do nothing.
highlightSize :: Traversal' (Style v n) Double
instance Data.Semigroup.Semigroup Diagrams.ThreeD.Attributes.Highlight
instance Diagrams.Core.Style.AttributeClass Diagrams.ThreeD.Attributes.Highlight
instance Data.Semigroup.Semigroup Diagrams.ThreeD.Attributes.Ambient
instance Data.Semigroup.Semigroup Diagrams.ThreeD.Attributes.Diffuse
instance Data.Semigroup.Semigroup Diagrams.ThreeD.Attributes.SurfaceColor
instance Diagrams.Core.Style.AttributeClass Diagrams.ThreeD.Attributes.SurfaceColor
instance Diagrams.Core.Style.AttributeClass Diagrams.ThreeD.Attributes.Diffuse
instance Diagrams.Core.Style.AttributeClass Diagrams.ThreeD.Attributes.Ambient

-- | A cubic spline is a smooth, connected sequence of cubic curves
--   passing through a given sequence of points. This module implements a
--   straightforward spline generation algorithm based on solving
--   tridiagonal systems of linear equations.
module Diagrams.CubicSpline.Internal

-- | Use the tri-diagonal solver with the appropriate parameters for an
--   open cubic spline.
solveCubicSplineDerivatives :: Fractional a => [a] -> [a]

-- | Use the cyclic-tri-diagonal solver with the appropriate parameters for
--   a closed cubic spline.
solveCubicSplineDerivativesClosed :: Fractional a => [a] -> [a]

-- | Use the cyclic-tri-diagonal solver with the appropriate parameters for
--   a closed cubic spline.
solveCubicSplineCoefficients :: Fractional a => Bool -> [a] -> [[a]]

-- | XXX
module Diagrams.Attributes.Compile
class (AttributeClass (AttrType code), Typeable (PrimType code)) => SplitAttribute code where type family AttrType code :: * type family PrimType code :: *
primOK :: SplitAttribute code => code -> PrimType code -> Bool

-- | Push certain attributes down until they are at the roots of trees
--   containing only "safe" nodes. In particular this is used to push fill
--   attributes down until they are over only loops; see
--   splitFills.
splitAttr :: SplitAttribute code => code -> RTree b v n a -> RTree b v n a

-- | Some miscellaneous utilities provided by the diagrams-lib package.
module Diagrams.Util

-- | Several functions exported by the diagrams library take a number of
--   arguments giving the user control to "tweak" various aspects of their
--   behavior. Rather than give such functions a long list of arguments,
--   and to make it possible for the user to selectively override only
--   certain arguments and use default values for others, such sets of
--   arguments are collected into a record with named fields (see
--   PolygonOpts in Diagrams.TwoD.Shapes for an example).
--   Such record types are made instances of the Default class,
--   which provides a single record structure (def) collecting the
--   "default" arguments to the function. with is a synonym for
--   def, which provides nice-looking syntax for simulating
--   optional, named arguments in Haskell. For example,
--   
--   
--   polygon with {sides = 7, edgeSkip = 2}
--   
--   
--   
--   calls the polygon function with a single argument (note that
--   record update binds more tightly than function application!), namely,
--   with (the record of default arguments) where the sides
--   and edgeSkip fields have been updated.
with :: Default d => d

-- | applyAll takes a list of functions and applies them all to a
--   value, in sequence from the last function in the list to the first.
--   For example, applyAll [f1, f2, f3] a == f1 . f2 . f3 $ a.
applyAll :: [a -> a] -> a -> a

-- | Postfix function application, for conveniently applying attributes.
--   Unlike ($), (#) has a high precedence (8), so d
--   # foo # bar can be combined with other things using operators
--   like (|||) or (<>) without needing
--   parentheses.
(#) :: a -> (a -> b) -> b

-- | A replacement for lenses' # operator.
(##) :: AReview t b -> b -> t

-- | iterateN n f x returns the list of the first n
--   iterates of f starting at x, that is, the list
--   [x, f x, f (f x), ...] of length n. (Note that the
--   last element of the list will be f applied to x
--   (n-1) times.)
iterateN :: Int -> (a -> a) -> a -> [a]

-- | The circle constant, the ratio of a circle's circumference to its
--   radius. Note that pi = tau/2.
--   
--   For more information and a well-reasoned argument why we should all be
--   using tau instead of pi, see The Tau Manifesto,
--   http://tauday.com/.
--   
--   To hear what it sounds like (and to easily memorize the first 30
--   digits or so), try http://youtu.be/3174T-3-59Q.
tau :: Floating a => a

-- | Given some file (no extension or otherwise) try to find a haskell
--   source file.
findHsFile :: FilePath -> IO (Maybe FilePath)

-- | Search for a sandbox in the following order:
--   
--   
--   
- Test given FilePaths if they point directly to a database or
--   contain a cabal config file (or any parent directory containing a
--   config file).
--   
- Same test for DIAGRAMS_SANDBOX environment value
--   
- Environment values of GHC_PACKAGE_PATH, HSENV
--   and PACKAGE_DB_FOR_GHC that point to a database.
--   
- Test for config file (cabal.sandbox.config) in the current
--   directory and its parents.
--   
findSandbox :: [FilePath] -> IO (Maybe FilePath)

-- | Find ghc's global package database. Throws an error if it isn't found.
globalPackage :: IO FilePath

-- | Given an associative binary operation and a default value to use in
--   the case of an empty list, perform a balanced fold over a list.
--   For example,
--   
--   
--   foldB (+) z [a,b,c,d,e,f] == ((a+b) + (c+d)) + (e+f)
--   
--   
foldB :: (a -> a -> a) -> a -> [a] -> a

-- | Points in space. For more tools for working with points and vectors,
--   see Linear.Affine.
module Diagrams.Points

-- | A handy wrapper to help distinguish points from vectors at the type
--   level
newtype Point (f :: * -> *) a :: (* -> *) -> * -> *
P :: f a -> Point a

-- | Vector spaces have origins.
origin :: (Additive f, Num a) => Point f a

-- | Scale a point by a scalar. Specialized version of '(*^)'.
(*.) :: (Functor v, Num n) => n -> Point v n -> Point v n

-- | The centroid of a set of n points is their sum divided by
--   n.
centroid :: (Additive v, Fractional n) => [Point v n] -> Point v n

-- | Create a "point diagram", which has no content, no trace, an empty
--   query, and a point envelope.
pointDiagram :: (Metric v, Fractional n) => Point v n -> QDiagram b v n m
_Point :: (Profunctor p, Functor f) => p (f a) (f (f a)) -> p (Point f a) (f (Point f a))
lensP :: Functor f => (g a -> f (g a)) -> Point g a -> f (Point g a)

-- | Type for representing angles.
module Diagrams.Angle

-- | Angles can be expressed in a variety of units. Internally, they are
--   represented in radians.
data Angle n

-- | 30 @@ deg is an Angle of the given measure and units.
--   
--   
--   >>> pi @@ rad
--   3.141592653589793 @@ rad
--   
--   
--   
--   >>> 1 @@ turn
--   6.283185307179586 @@ rad
--   
--   
--   
--   >>> 30 @@ deg
--   0.5235987755982988 @@ rad
--   
--   
--   For Iso's, (@@) reverses the Iso' on its right,
--   and applies the Iso' to the value on the left. Angles
--   are the motivating example where this order improves readability.
--   
--   This is the same as a flipped review.
--   
--   
--   (@@) :: a -> Iso'      s a -> s
--   (@@) :: a -> Prism'    s a -> s
--   (@@) :: a -> Review    s a -> s
--   (@@) :: a -> Equality' s a -> s
--   
(@@) :: b -> AReview a b -> a

-- | The radian measure of an Angle a can be accessed as
--   a ^. rad. A new Angle can be defined in radians
--   as pi @@ rad.
rad :: Iso' (Angle n) n

-- | The measure of an Angle a in full circles can be
--   accessed as a ^. turn. A new Angle of one-half
--   circle can be defined in as 1/2 @@ turn.
turn :: Floating n => Iso' (Angle n) n

-- | The degree measure of an Angle a can be accessed as
--   a ^. deg. A new Angle can be defined in degrees
--   as 180 @@ deg.
deg :: Floating n => Iso' (Angle n) n

-- | An angle representing one full turn.
fullTurn :: Floating v => Angle v

-- | An angle representing a half turn.
halfTurn :: Floating v => Angle v

-- | An angle representing a quarter turn.
quarterTurn :: Floating v => Angle v

-- | The sine of the given Angle.
sinA :: Floating n => Angle n -> n

-- | The cosine of the given Angle.
cosA :: Floating n => Angle n -> n

-- | The tangent function of the given Angle.
tanA :: Floating n => Angle n -> n

-- | The Angle with the given sine.
asinA :: Floating n => n -> Angle n

-- | The Angle with the given cosine.
acosA :: Floating n => n -> Angle n

-- | The Angle with the given tangent.
atanA :: Floating n => n -> Angle n

-- | atan2A y x is the angle between the positive x-axis and the
--   vector given by the coordinates (x, y). The Angle returned is
--   in the [-pi,pi] range.
atan2A :: RealFloat n => n -> n -> Angle n

-- | Similar to atan2A but without the RealFloat constraint.
--   This means it doesn't handle negative zero cases. However, for most
--   geometric purposes, the outcome will be the same.
atan2A' :: OrderedField n => n -> n -> Angle n

-- | Compute the positive angle between the two vectors in their common
--   plane. Returns NaN if either of the vectors are zero.
angleBetween :: (Metric v, Floating n) => v n -> v n -> Angle n

-- | Calculate ratio between two angles.
angleRatio :: Floating n => Angle n -> Angle n -> n

-- | Normalize an angle so that it lies in the [0,tau) range.
normalizeAngle :: (Floating n, Real n) => Angle n -> Angle n

-- | The class of types with at least one angle coordinate, called
--   _theta.
class HasTheta t
_theta :: (HasTheta t, RealFloat n) => Lens' (t n) (Angle n)

-- | The class of types with at least two angle coordinates, the second
--   called _phi. _phi is the positive angle measured from
--   the z axis.
class HasTheta t => HasPhi t
_phi :: (HasPhi t, RealFloat n) => Lens' (t n) (Angle n)
instance GHC.Base.Functor Diagrams.Angle.Angle
instance GHC.Enum.Enum n => GHC.Enum.Enum (Diagrams.Angle.Angle n)
instance GHC.Classes.Ord n => GHC.Classes.Ord (Diagrams.Angle.Angle n)
instance GHC.Classes.Eq n => GHC.Classes.Eq (Diagrams.Angle.Angle n)
instance GHC.Show.Show n => GHC.Show.Show (Diagrams.Angle.Angle n)
instance GHC.Read.Read n => GHC.Read.Read (Diagrams.Angle.Angle n)
instance GHC.Base.Applicative Diagrams.Angle.Angle
instance Linear.Vector.Additive Diagrams.Angle.Angle
instance GHC.Num.Num n => Data.Semigroup.Semigroup (Diagrams.Angle.Angle n)
instance GHC.Num.Num n => GHC.Base.Monoid (Diagrams.Angle.Angle n)
instance Diagrams.Angle.HasTheta v => Diagrams.Angle.HasTheta (Linear.Affine.Point v)
instance Diagrams.Angle.HasPhi v => Diagrams.Angle.HasPhi (Linear.Affine.Point v)

-- | Type for representing directions, polymorphic in vector space
module Diagrams.Direction

-- | A vector is described by a Direction and a magnitude. So we
--   can think of a Direction as a vector that has forgotten its
--   magnitude. Directions can be used with fromDirection
--   and the lenses provided by its instances.
data Direction v n

-- | _Dir is provided to allow efficient implementations of functions in
--   particular vector-spaces, but should be used with care as it exposes
--   too much information.
_Dir :: Iso' (Direction v n) (v n)

-- | direction v is the direction in which v points.
--   Returns an unspecified value when given the zero vector as input.
direction :: v n -> Direction v n

-- | Synonym for direction.
dir :: v n -> Direction v n

-- | fromDirection d is the unit vector in the direction
--   d.
fromDirection :: (Metric v, Floating n) => Direction v n -> v n

-- | Synonym for fromDirection.
fromDir :: (Metric v, Floating n) => Direction v n -> v n

-- | compute the positive angle between the two directions in their common
--   plane
angleBetweenDirs :: (Metric v, Floating n) => Direction v n -> Direction v n -> Angle n

-- | dirBetween p q returns the directions from p to
--   q
dirBetween :: (Additive v, Num n) => Point v n -> Point v n -> Direction v n
instance GHC.Base.Functor v => GHC.Base.Functor (Diagrams.Direction.Direction v)
instance GHC.Classes.Ord (v n) => GHC.Classes.Ord (Diagrams.Direction.Direction v n)
instance GHC.Classes.Eq (v n) => GHC.Classes.Eq (Diagrams.Direction.Direction v n)
instance GHC.Show.Show (v n) => GHC.Show.Show (Diagrams.Direction.Direction v n)
instance GHC.Read.Read (v n) => GHC.Read.Read (Diagrams.Direction.Direction v n)
instance (Diagrams.Core.V.V (v n) ~ v, Diagrams.Core.V.N (v n) ~ n, Diagrams.Core.Transform.Transformable (v n)) => Diagrams.Core.Transform.Transformable (Diagrams.Direction.Direction v n)
instance Diagrams.Angle.HasTheta v => Diagrams.Angle.HasTheta (Diagrams.Direction.Direction v)
instance Diagrams.Angle.HasPhi v => Diagrams.Angle.HasPhi (Diagrams.Direction.Direction v)

-- | Nice syntax for constructing and pattern-matching on literal points
--   and vectors.
module Diagrams.Coordinates

-- | A pair of values, with a convenient infix (left-associative) data
--   constructor.
data (:&) a b
(:&) :: a -> b -> (:&) a b

-- | Types which are instances of the Coordinates class can be
--   constructed using ^& (for example, a three-dimensional
--   vector could be constructed by 1 ^& 6 ^& 3), and
--   deconstructed using coords. A common pattern is to use
--   coords in conjunction with the ViewPatterns extension,
--   like so:
--   
--   
--   foo :: Vector3 -> ...
--   foo (coords -> x :& y :& z) = ...
--   
class Coordinates c where type family FinalCoord c :: * type family PrevDim c :: * type family Decomposition c :: * pr = (^&)

-- | Construct a value of type c by providing something of one
--   less dimension (which is perhaps itself recursively constructed using
--   (^&)) and a final coordinate. For example,
--   
--   
--   2 ^& 3 :: P2
--   3 ^& 5 ^& 6 :: V3
--   
--   
--   Note that ^& is left-associative.
(^&) :: Coordinates c => PrevDim c -> FinalCoord c -> c

-- | Prefix synonym for ^&. pr stands for pair of
--   PrevDim, FinalCoord
pr :: Coordinates c => PrevDim c -> FinalCoord c -> c

-- | Decompose a value of type c into its constituent coordinates,
--   stored in a nested (:&) structure.
coords :: Coordinates c => c -> Decomposition c
instance (GHC.Show.Show a, GHC.Show.Show b) => GHC.Show.Show (a Diagrams.Coordinates.:& b)
instance (GHC.Classes.Ord a, GHC.Classes.Ord b) => GHC.Classes.Ord (a Diagrams.Coordinates.:& b)
instance (GHC.Classes.Eq a, GHC.Classes.Eq b) => GHC.Classes.Eq (a Diagrams.Coordinates.:& b)
instance Diagrams.Coordinates.Coordinates (a Diagrams.Coordinates.:& b)
instance Diagrams.Coordinates.Coordinates (a, b)
instance Diagrams.Coordinates.Coordinates (a, b, c)
instance Diagrams.Coordinates.Coordinates (a, b, c, d)
instance Diagrams.Coordinates.Coordinates (v n) => Diagrams.Coordinates.Coordinates (Linear.Affine.Point v n)
instance Diagrams.Coordinates.Coordinates (Linear.V2.V2 n)
instance Diagrams.Coordinates.Coordinates (Linear.V3.V3 n)
instance Diagrams.Coordinates.Coordinates (Linear.V4.V4 n)

-- | Basic types for two-dimensional Euclidean space.
module Diagrams.TwoD.Types

-- | A 2-dimensional vector
--   
--   
--   >>> pure 1 :: V2 Int
--   V2 1 1
--   
--   
--   
--   >>> V2 1 2 + V2 3 4
--   V2 4 6
--   
--   
--   
--   >>> V2 1 2 * V2 3 4
--   V2 3 8
--   
--   
--   
--   >>> sum (V2 1 2)
--   3
--   
data V2 a :: * -> *
V2 :: SrictNotUnpackeda -> SrictNotUnpackeda -> V2 a

-- | A space that has at least 1 basis vector _x.
class R1 (t :: * -> *)

-- | 
--   >>> V1 2 ^._x
--   2
--   
--   
--   
--   >>> V1 2 & _x .~ 3
--   V1 3
--   
_x :: (R1 t, Functor f) => (a -> f a) -> t a -> f (t a)

-- | A space that distinguishes 2 orthogonal basis vectors _x and
--   _y, but may have more.
class R1 t => R2 (t :: * -> *)

-- | 
--   >>> V2 1 2 ^._y
--   2
--   
--   
--   
--   >>> V2 1 2 & _y .~ 3
--   V2 1 3
--   
_y :: (R2 t, Functor f) => (a -> f a) -> t a -> f (t a)
_xy :: (R2 t, Functor f) => (V2 a -> f (V2 a)) -> t a -> f (t a)
type P2 = Point V2
type T2 = Transformation V2

-- | Construct a 2D vector from a pair of components. See also
--   &.
r2 :: (n, n) -> V2 n

-- | Convert a 2D vector back into a pair of components. See also
--   coords.
unr2 :: V2 n -> (n, n)

-- | Curried form of r2.
mkR2 :: n -> n -> V2 n
r2Iso :: Iso' (V2 n) (n, n)

-- | Construct a 2D point from a pair of coordinates. See also
--   ^&.
p2 :: (n, n) -> P2 n

-- | Curried form of p2.
mkP2 :: n -> n -> P2 n

-- | Convert a 2D point back into a pair of coordinates. See also
--   coords.
unp2 :: P2 n -> (n, n)
p2Iso :: Iso' (Point V2 n) (n, n)
r2PolarIso :: RealFloat n => Iso' (V2 n) (n, Angle n)

-- | A space which has magnitude _r that can be calculated
--   numerically.
class HasR t
_r :: (HasR t, RealFloat n) => Lens' (t n) n
instance Diagrams.Core.Transform.Transformable (Linear.V2.V2 n)
instance Diagrams.TwoD.Types.HasR v => Diagrams.TwoD.Types.HasR (Linear.Affine.Point v)
instance Diagrams.TwoD.Types.HasR Linear.V2.V2
instance Diagrams.Angle.HasTheta Linear.V2.V2

-- | Two-dimensional vectors.
module Diagrams.TwoD.Vector

-- | The unit vector in the positive X direction.
unitX :: (R1 v, Additive v, Num n) => v n

-- | The unit vector in the positive Y direction.
unitY :: (R2 v, Additive v, Num n) => v n

-- | The unit vector in the negative X direction.
unit_X :: (R1 v, Additive v, Num n) => v n

-- | The unit vector in the negative Y direction.
unit_Y :: (R2 v, Additive v, Num n) => v n

-- | A Direction pointing in the X direction.
xDir :: (R1 v, Additive v, Num n) => Direction v n

-- | A Direction pointing in the Y direction.
yDir :: (R2 v, Additive v, Num n) => Direction v n

-- | A unit vector at a specified angle counter-clockwise from the positive
--   x-axis
angleV :: Floating n => Angle n -> V2 n

-- | A direction at a specified angle counter-clockwise from the
--   xDir.
angleDir :: Floating n => Angle n -> Direction V2 n

-- | A unit vector at a specified angle counter-clockwise from the positive
--   X axis.
e :: Floating n => Angle n -> V2 n
signedAngleBetween :: RealFloat n => V2 n -> V2 n -> Angle n
signedAngleBetweenDirs :: RealFloat n => Direction V2 n -> Direction V2 n -> Angle n

-- | the counter-clockwise perpendicular vector
--   
--   
--   >>> perp $ V2 10 20
--   V2 (-20) 10
--   
perp :: Num a => V2 a -> V2 a

-- | leftTurn v1 v2 tests whether the direction of v2 is
--   a left turn from v1 (that is, if the direction of v2
--   can be obtained from that of v1 by adding an angle 0 <=
--   theta <= tau/2).
leftTurn :: (Num n, Ord n) => V2 n -> V2 n -> Bool

-- | Cross product on vectors in R2.
cross2 :: Num n => V2 n -> V2 n -> n

-- | Special functions for points in R2.
module Diagrams.TwoD.Points

-- | Find the convex hull of a list of points using Andrew's monotone chain
--   algorithm O(n log n).
--   
--   Returns clockwise list of points starting from the left-most point.
convexHull2D :: OrderedField n => [P2 n] -> [P2 n]

-- | Find the convex hull of a set of points already sorted in the x
--   direction. The first list of the tuple is the upper hull going
--   clockwise from left-most to right-most point. The second is the lower
--   hull from right-most to left-most in the anti-clockwise direction.
sortedConvexHull :: OrderedField n => [P2 n] -> ([P2 n], [P2 n])

-- | Basic types for three-dimensional Euclidean space.
module Diagrams.ThreeD.Types

-- | Construct a 3D vector from a triple of components.
r3 :: (n, n, n) -> V3 n

-- | Convert a 3D vector back into a triple of components.
unr3 :: V3 n -> (n, n, n)

-- | Curried version of r3.
mkR3 :: n -> n -> n -> V3 n

-- | Construct a 3D point from a triple of coordinates.
p3 :: (n, n, n) -> P3 n

-- | Convert a 3D point back into a triple of coordinates.
unp3 :: P3 n -> (n, n, n)

-- | Curried version of r3.
mkP3 :: n -> n -> n -> P3 n
r3Iso :: Iso' (V3 n) (n, n, n)
p3Iso :: Iso' (P3 n) (n, n, n)

-- | project u v computes the projection of v onto
--   u.
project :: (Metric v, Fractional a) => v a -> v a -> v a
r3SphericalIso :: RealFloat n => Iso' (V3 n) (n, Angle n, Angle n)
r3CylindricalIso :: RealFloat n => Iso' (V3 n) (n, Angle n, n)

-- | A 3-dimensional vector
data V3 a :: * -> *
V3 :: SrictNotUnpackeda -> SrictNotUnpackeda -> SrictNotUnpackeda -> V3 a
type P3 = Point V3
type T3 = Transformation V3

-- | A space that has at least 1 basis vector _x.
class R1 (t :: * -> *)

-- | 
--   >>> V1 2 ^._x
--   2
--   
--   
--   
--   >>> V1 2 & _x .~ 3
--   V1 3
--   
_x :: (R1 t, Functor f) => (a -> f a) -> t a -> f (t a)

-- | A space that distinguishes 2 orthogonal basis vectors _x and
--   _y, but may have more.
class R1 t => R2 (t :: * -> *)

-- | 
--   >>> V2 1 2 ^._y
--   2
--   
--   
--   
--   >>> V2 1 2 & _y .~ 3
--   V2 1 3
--   
_y :: (R2 t, Functor f) => (a -> f a) -> t a -> f (t a)
_xy :: (R2 t, Functor f) => (V2 a -> f (V2 a)) -> t a -> f (t a)

-- | A space that distinguishes 3 orthogonal basis vectors: _x,
--   _y, and _z. (It may have more)
class R2 t => R3 (t :: * -> *)

-- | 
--   >>> V3 1 2 3 ^. _z
--   3
--   
_z :: (R3 t, Functor f) => (a -> f a) -> t a -> f (t a)
_xyz :: (R3 t, Functor f) => (V3 a -> f (V3 a)) -> t a -> f (t a)
instance Diagrams.Core.Transform.Transformable (Linear.V3.V3 n)
instance Diagrams.TwoD.Types.HasR Linear.V3.V3
instance Diagrams.Angle.HasTheta Linear.V3.V3
instance Diagrams.Angle.HasPhi Linear.V3.V3

-- | Types to specify lighting for 3D rendering.
module Diagrams.ThreeD.Light

-- | A PointLight radiates uniformly in all directions from a
--   given point.
data PointLight n
PointLight :: (Point V3 n) -> (Colour Double) -> PointLight n

-- | A ParallelLight casts parallel rays in the specified
--   direction, from some distant location outside the scene.
data ParallelLight n
ParallelLight :: (V3 n) -> (Colour Double) -> ParallelLight n

-- | Construct a Diagram with a single PointLight at the origin, which
--   takes up no space.
pointLight :: (Typeable n, Num n, Ord n, Renderable (PointLight n) b) => Colour Double -> QDiagram b V3 n Any

-- | Construct a Diagram with a single ParallelLight, which takes up no
--   space.
parallelLight :: (Typeable n, OrderedField n, Renderable (ParallelLight n) b) => Direction V3 n -> Colour Double -> QDiagram b V3 n Any
instance GHC.Real.Fractional n => Diagrams.Core.Transform.Transformable (Diagrams.ThreeD.Light.PointLight n)
instance GHC.Real.Fractional n => Diagrams.Core.Transform.Transformable (Diagrams.ThreeD.Light.ParallelLight n)

-- | Three-dimensional vectors.
module Diagrams.ThreeD.Vector

-- | The unit vector in the positive X direction.
unitX :: (R1 v, Additive v, Num n) => v n

-- | The unit vector in the positive Y direction.
unitY :: (R2 v, Additive v, Num n) => v n

-- | The unit vector in the positive Y direction.
unitZ :: (R3 v, Additive v, Num n) => v n

-- | The unit vector in the negative X direction.
unit_X :: (R1 v, Additive v, Num n) => v n

-- | The unit vector in the negative Y direction.
unit_Y :: (R2 v, Additive v, Num n) => v n

-- | The unit vector in the negative X direction.
unit_Z :: (R3 v, Additive v, Num n) => v n

-- | A Direction pointing in the X direction.
xDir :: (R1 v, Additive v, Num n) => Direction v n

-- | A Direction pointing in the Y direction.
yDir :: (R2 v, Additive v, Num n) => Direction v n

-- | A Direction pointing in the Z direction.
zDir :: (R3 v, Additive v, Num n) => Direction v n

-- | Various three-dimensional shapes.
module Diagrams.ThreeD.Shapes
data Ellipsoid n
Ellipsoid :: (Transformation V3 n) -> Ellipsoid n

-- | A sphere of radius 1 with its center at the origin.
sphere :: (Typeable n, OrderedField n, Renderable (Ellipsoid n) b) => QDiagram b V3 n Any
data Box n
Box :: (Transformation V3 n) -> Box n

-- | A cube with side length 1, in the positive octant, with one vertex at
--   the origin.
cube :: (Typeable n, OrderedField n, Renderable (Box n) b) => QDiagram b V3 n Any
data Frustum n
Frustum :: n -> n -> (Transformation V3 n) -> Frustum n

-- | A frustum of a right circular cone. It has height 1 oriented along the
--   positive z axis, and radii r0 and r1 at Z=0 and Z=1. cone and
--   cylinder are special cases.
frustum :: (TypeableFloat n, Renderable (Frustum n) b) => n -> n -> QDiagram b V3 n Any

-- | A cone with its base centered on the origin, with radius 1 at the
--   base, height 1, and it's apex on the positive Z axis.
cone :: (TypeableFloat n, Renderable (Frustum n) b) => QDiagram b V3 n Any

-- | A circular cylinder of radius 1 with one end cap centered on the
--   origin, and extending to Z=1.
cylinder :: (TypeableFloat n, Renderable (Frustum n) b) => QDiagram b V3 n Any
instance GHC.Real.Fractional n => Diagrams.Core.Transform.Transformable (Diagrams.ThreeD.Shapes.Ellipsoid n)
instance GHC.Real.Fractional n => Diagrams.Core.Types.Renderable (Diagrams.ThreeD.Shapes.Ellipsoid n) Diagrams.Core.Types.NullBackend
instance GHC.Real.Fractional n => Diagrams.Core.Transform.Transformable (Diagrams.ThreeD.Shapes.Box n)
instance GHC.Real.Fractional n => Diagrams.Core.Types.Renderable (Diagrams.ThreeD.Shapes.Box n) Diagrams.Core.Types.NullBackend
instance GHC.Real.Fractional n => Diagrams.Core.Transform.Transformable (Diagrams.ThreeD.Shapes.Frustum n)
instance GHC.Real.Fractional n => Diagrams.Core.Types.Renderable (Diagrams.ThreeD.Shapes.Frustum n) Diagrams.Core.Types.NullBackend

-- | Types to specify viewpoint for 3D rendering.
module Diagrams.ThreeD.Camera
data Camera l n

-- | A perspective projection
data PerspectiveLens n
PerspectiveLens :: Angle n -> Angle n -> PerspectiveLens n

-- | Horizontal field of view.
[_horizontalFieldOfView] :: PerspectiveLens n -> Angle n

-- | Vertical field of view.
[_verticalFieldOfView] :: PerspectiveLens n -> Angle n

-- | An orthographic projection
data OrthoLens n
OrthoLens :: n -> n -> OrthoLens n

-- | Width
[_orthoWidth] :: OrthoLens n -> n

-- | Height
[_orthoHeight] :: OrthoLens n -> n
horizontalFieldOfView :: Lens' (PerspectiveLens n_aVw8) (Angle n_aVw8)
verticalFieldOfView :: Lens' (PerspectiveLens n_aVw8) (Angle n_aVw8)
orthoWidth :: Lens' (OrthoLens n_aVyc) n_aVyc
orthoHeight :: Lens' (OrthoLens n_aVyc) n_aVyc
camLoc :: Camera l n -> Point V3 n
camForward :: Fractional n => Camera l n -> Direction V3 n
camUp :: Fractional n => Camera l n -> Direction V3 n
camRight :: Fractional n => Camera l n -> Direction V3 n
camLens :: Camera l n -> l n

-- | 'facing_ZCamera l' is a camera at the origin facing along the negative
--   Z axis, with its up-axis coincident with the positive Y axis, with the
--   projection defined by l.
facing_ZCamera :: (Floating n, Ord n, Typeable n, CameraLens l, Renderable (Camera l n) b) => l n -> QDiagram b V3 n Any

-- | A camera at the origin facing along the negative Z axis, with its
--   up-axis coincident with the positive Y axis. The field of view is
--   chosen to match a 50mm camera on 35mm film. Note that Cameras take up
--   no space in the Diagram.
mm50Camera :: (Typeable n, Floating n, Ord n, Renderable (Camera PerspectiveLens n) b) => QDiagram b V3 n Any

-- | mm50 has the field of view of a 50mm lens on standard 35mm film, hence
--   an aspect ratio of 3:2.
mm50 :: Floating n => PerspectiveLens n

-- | mm50blWide has the same vertical field of view as mm50, but an aspect
--   ratio of 1.6, suitable for wide screen computer monitors.
mm50Wide :: Floating n => PerspectiveLens n

-- | mm50Narrow has the same vertical field of view as mm50, but an aspect
--   ratio of 4:3, for VGA and similar computer resolutions.
mm50Narrow :: Floating n => PerspectiveLens n

-- | The natural aspect ratio of the projection.
aspect :: (CameraLens l, Floating n) => l n -> n
camAspect :: (Floating n, CameraLens l) => Camera l n -> n
instance Diagrams.ThreeD.Camera.CameraLens Diagrams.ThreeD.Camera.OrthoLens
instance GHC.Num.Num n => Diagrams.Core.Transform.Transformable (Diagrams.ThreeD.Camera.Camera l n)
instance GHC.Num.Num n => Diagrams.Core.Types.Renderable (Diagrams.ThreeD.Camera.Camera l n) Diagrams.Core.Types.NullBackend
instance Diagrams.ThreeD.Camera.CameraLens Diagrams.ThreeD.Camera.PerspectiveLens

-- | Functions for converting between Transformations and matricies.
module Diagrams.Transform.Matrix

-- | Build a matrix from a Transformation, ignoring the translation.
mkMat :: (HasBasis v, Num n) => Transformation v n -> v (v n)

-- | Build a 3D transformation matrix in homogeneous coordinates from a
--   'Transformation V3'.
mkMatHomo :: Num n => Transformation V3 n -> M44 n

-- | Make a 2D transformation from a 2x2 transform matrix and a translation
--   vector. Does not check if the matrix is not invertible (in which case
--   the T2 will be invalid).
fromMat22 :: Floating n => M22 n -> V2 n -> T2 n

-- | Make a 3D transformation from a 3x3 transform matrix and a translation
--   vector. Does not check if the matrix is not invertible (in which case
--   the T3 will be invalid).
fromMat33 :: Floating n => M33 n -> V3 n -> T3 n

-- | Build a transform with a maxtrix along with its inverse.
fromMatWithInv :: (Additive v, Distributive v, Foldable v, Num n) => v (v n) -> v (v n) -> v n -> Transformation v n

-- | Prism onto a 2D transformation from a 2x2 transform matrix and
--   translation vector. Does not check if the matrix is invertible (in
--   which case the T2 will be invalid).
mat22 :: Floating n => Iso' (M22 n, V2 n) (T2 n)

-- | Prism onto a 2D transformation from a 2x2 transform matrix and
--   translation vector (in which case the T3 will be invalid).
mat33 :: Floating n => Iso' (M33 n, V3 n) (T3 n)

-- | A query is a function that maps points in a vector space to values in
--   some monoid. Queries naturally form a monoid, with two queries being
--   combined pointwise.
module Diagrams.Query

-- | A query is a function that maps points in a vector space to values in
--   some monoid. Queries naturally form a monoid, with two queries being
--   combined pointwise.
--   
--   The idea for annotating diagrams with monoidal queries came from the
--   graphics-drawingcombinators package,
--   http://hackage.haskell.org/package/graphics-drawingcombinators.
newtype Query (v :: * -> *) n m :: (* -> *) -> * -> * -> *
Query :: (Point v n -> m) -> Query n m
[runQuery] :: Query n m -> Point v n -> m

-- | Get the query function associated with a diagram.
query :: Monoid m => QDiagram b v n m -> Query v n m

-- | Sample a diagram's query function at a given point.
sample :: Monoid m => QDiagram b v n m -> Point v n -> m

-- | Set the query value for True points in a diagram (i.e.
--   points "inside" the diagram); False points will be set to
--   mempty.
value :: Monoid m => m -> QDiagram b v n Any -> QDiagram b v n m

-- | Reset the query values of a diagram to True/False:
--   any values equal to mempty are set to False; any other
--   values are set to True.
resetValue :: (Eq m, Monoid m) => QDiagram b v n m -> QDiagram b v n Any

-- | Set all the query values of a diagram to False.
clearValue :: QDiagram b v n m -> QDiagram b v n Any

-- | Names can be given to subdiagrams, and subdiagrams can later be
--   queried by name. This module exports types for representing names and
--   subdiagrams, and various functions for working with them.
module Diagrams.Names

-- | Atomic names. AName is just an existential wrapper around
--   things which are Typeable, Ord and Show.
data AName :: *

-- | A (qualified) name is a (possibly empty) sequence of atomic names.
data Name :: *

-- | Class for those types which can be used as names. They must support
--   Typeable (to facilitate extracting them from existential
--   wrappers), Ord (for comparison and efficient storage) and
--   Show.
--   
--   To make an instance of IsName, you need not define any methods,
--   just declare it.
--   
--   WARNING: it is not recommended to use
--   GeneralizedNewtypeDeriving in conjunction with
--   IsName, since in that case the underlying type and the
--   newtype will be considered equivalent when comparing names.
--   For example:
--   
--   
--   newtype WordN = WordN Int deriving (Show, Ord, Eq, Typeable, IsName)
--   
--   
--   
--   is unlikely to work as intended, since (1 :: Int) and
--   (WordN 1) will be considered equal as names. Instead, use
--   
--   
--   newtype WordN = WordN Int deriving (Show, Ord, Eq, Typeable, IsName)
--   instance IsName WordN
--   
--   
class (Typeable * a, Ord a, Show a) => IsName a
toName :: IsName a => a -> Name

-- | Convenient operator for writing qualified names with atomic components
--   of different types. Instead of writing toName a1 <> toName
--   a2 <> toName a3 you can just write a1 .> a2 .>
--   a3.
(.>) :: (IsName a1, IsName a2) => a1 -> a2 -> Name

-- | Instances of Qualifiable are things which can be qualified by
--   prefixing them with a name.
class Qualifiable q

-- | Qualify with the given name.
(.>>) :: (Qualifiable q, IsName a) => a -> q -> q

-- | A Subdiagram represents a diagram embedded within the context
--   of a larger diagram. Essentially, it consists of a diagram paired with
--   any accumulated information from the larger context (transformations,
--   attributes, etc.).
data Subdiagram b (v :: * -> *) n m :: * -> (* -> *) -> * -> * -> *

-- | Turn a diagram into a subdiagram with no accumulated context.
mkSubdiagram :: QDiagram b v n m -> Subdiagram b v n m

-- | Create a "point subdiagram", that is, a pointDiagram (with no
--   content and a point envelope) treated as a subdiagram with local
--   origin at the given point. Note this is not the same as
--   mkSubdiagram . pointDiagram, which would result in a
--   subdiagram with local origin at the parent origin, rather than at the
--   given point.
subPoint :: (Metric v, OrderedField n, Semigroup m) => Point v n -> Subdiagram b v n m

-- | Turn a subdiagram into a normal diagram, including the enclosing
--   context. Concretely, a subdiagram is a pair of (1) a diagram and (2) a
--   "context" consisting of an extra transformation and attributes.
--   getSub simply applies the transformation and attributes to
--   the diagram to get the corresponding "top-level" diagram.
getSub :: (Metric v, OrderedField n, Semigroup m) => Subdiagram b v n m -> QDiagram b v n m

-- | Extract the "raw" content of a subdiagram, by throwing away the
--   context.
rawSub :: Subdiagram b v n m -> QDiagram b v n m

-- | Get the location of a subdiagram; that is, the location of its local
--   origin with respect to the vector space of its parent diagram.
--   In other words, the point where its local origin "ended up".
location :: (Additive v, Num n) => Subdiagram b v n m -> Point v n

-- | A SubMap is a map associating names to subdiagrams. There can
--   be multiple associations for any given name.
data SubMap b (v :: * -> *) n m :: * -> (* -> *) -> * -> * -> *

-- | Construct a SubMap from a list of associations between names
--   and subdiagrams.
fromNames :: IsName a => [(a, Subdiagram b v n m)] -> SubMap b v n m

-- | Add a name/diagram association to a submap.
rememberAs :: IsName a => a -> QDiagram b v n m -> SubMap b v n m -> SubMap b v n m

-- | Look for the given name in a name map, returning a list of subdiagrams
--   associated with that name. If no names match the given name exactly,
--   return all the subdiagrams associated with names of which the given
--   name is a suffix.
lookupSub :: IsName nm => nm -> SubMap b v n m -> Maybe [Subdiagram b v n m]

-- | Attach an atomic name to a diagram.
named :: (IsName nm, Metric v, OrderedField n, Semigroup m) => nm -> QDiagram b v n m -> QDiagram b v n m

-- | Attach an atomic name to a certain subdiagram, computed from the given
--   diagram /with the mapping from name to subdiagram included/. The
--   upshot of this knot-tying is that if d' = d # named x, then
--   lookupName x d' == Just d' (instead of Just d).
nameSub :: (IsName nm, Metric v, OrderedField n, Semigroup m) => (QDiagram b v n m -> Subdiagram b v n m) -> nm -> QDiagram b v n m -> QDiagram b v n m

-- | Attach an atomic name to a certain point (which may be computed from
--   the given diagram), treated as a subdiagram with no content and a
--   point envelope.
namePoint :: (IsName nm, Metric v, OrderedField n, Semigroup m) => (QDiagram b v n m -> Point v n) -> nm -> QDiagram b v n m -> QDiagram b v n m

-- | "Localize" a diagram by hiding all the names, so they are no longer
--   visible to the outside.
localize :: (Metric v, OrderedField n, Semigroup m) => QDiagram b v n m -> QDiagram b v n m

-- | Get a list of names of subdiagrams and their locations.
names :: (Metric v, Semigroup m, OrderedField n) => QDiagram b v n m -> [(Name, [Point v n])]

-- | Lookup the most recent diagram associated with (some qualification of)
--   the given name.
lookupName :: (IsName nm, Metric v, Semigroup m, OrderedField n) => nm -> QDiagram b v n m -> Maybe (Subdiagram b v n m)

-- | Given a name and a diagram transformation indexed by a subdiagram,
--   perform the transformation using the most recent subdiagram associated
--   with (some qualification of) the name, or perform the identity
--   transformation if the name does not exist.
withName :: (IsName nm, Metric v, Semigroup m, OrderedField n) => nm -> (Subdiagram b v n m -> QDiagram b v n m -> QDiagram b v n m) -> QDiagram b v n m -> QDiagram b v n m

-- | Given a name and a diagram transformation indexed by a list of
--   subdiagrams, perform the transformation using the collection of all
--   such subdiagrams associated with (some qualification of) the given
--   name.
withNameAll :: (IsName nm, Metric v, Semigroup m, OrderedField n) => nm -> ([Subdiagram b v n m] -> QDiagram b v n m -> QDiagram b v n m) -> QDiagram b v n m -> QDiagram b v n m

-- | Given a list of names and a diagram transformation indexed by a list
--   of subdiagrams, perform the transformation using the list of most
--   recent subdiagrams associated with (some qualification of) each name.
--   Do nothing (the identity transformation) if any of the names do not
--   exist.
withNames :: (IsName nm, Metric v, Semigroup m, OrderedField n) => [nm] -> ([Subdiagram b v n m] -> QDiagram b v n m -> QDiagram b v n m) -> QDiagram b v n m -> QDiagram b v n m

-- | Affine transformations, parameterized by any vector space. For
--   transformations on particular vector spaces, see e.g.
--   Diagrams.TwoD.Transform.
module Diagrams.Transform

-- | General (affine) transformations, represented by an invertible linear
--   map, its transpose, and a vector representing a translation
--   component.
--   
--   By the transpose of a linear map we mean simply the linear map
--   corresponding to the transpose of the map's matrix representation. For
--   example, any scale is its own transpose, since scales are represented
--   by matrices with zeros everywhere except the diagonal. The transpose
--   of a rotation is the same as its inverse.
--   
--   The reason we need to keep track of transposes is because it turns out
--   that when transforming a shape according to some linear map L, the
--   shape's normal vectors transform according to L's inverse
--   transpose. (For a more detailed explanation and proof, see
--   https://wiki.haskell.org/Diagrams/Dev/Transformations.) This is
--   exactly what we need when transforming bounding functions, which are
--   defined in terms of perpendicular (i.e. normal) hyperplanes.
--   
--   For more general, non-invertible transformations, see
--   Diagrams.Deform (in diagrams-lib).
data Transformation (v :: * -> *) n :: (* -> *) -> * -> *

-- | Invert a transformation.
inv :: (Functor v, Num n) => Transformation v n -> Transformation v n

-- | Get the translational component of a transformation.
transl :: Transformation v n -> v n

-- | Apply a transformation to a vector. Note that any translational
--   component of the transformation will not affect the vector, since
--   vectors are invariant under translation.
apply :: Transformation v n -> v n -> v n

-- | Apply a transformation to a point.
papply :: (Additive v, Num n) => Transformation v n -> Point v n -> Point v n

-- | Type class for things t which can be transformed.
class Transformable t

-- | Apply a transformation to an object.
transform :: Transformable t => Transformation (V t) (N t) -> t -> t

-- | Create a translation.
translation :: v n -> Transformation v n

-- | Translate by a vector.
translate :: (Num (N t), Transformable t) => Vn t -> t -> t

-- | Translate the object by the translation that sends the origin to the
--   given point. Note that this is dual to moveOriginTo, i.e. we
--   should have
--   
--   
--   moveTo (origin .^+ v) === moveOriginTo (origin .^- v)
--   
--   
--   
--   For types which are also Transformable, this is essentially
--   the same as translate, i.e.
--   
--   
--   moveTo (origin .^+ v) === translate v
--   
--   
moveTo :: (InSpace v n t, HasOrigin t) => Point v n -> t -> t

-- | A flipped variant of moveTo, provided for convenience. Useful
--   when writing a function which takes a point as an argument, such as
--   when using withName and friends.
place :: (InSpace v n t, HasOrigin t) => t -> Point v n -> t

-- | Create a uniform scaling transformation.
scaling :: (Additive v, Fractional n) => n -> Transformation v n

-- | Scale uniformly in every dimension by the given scalar.
scale :: (InSpace v n a, Eq n, Fractional n, Transformable a) => n -> a -> a

-- | Conjugate one transformation by another. conjugate t1 t2 is
--   the transformation which performs first t1, then t2,
--   then the inverse of t1.
conjugate :: (Additive v, Num n, Functor v) => Transformation v n -> Transformation v n -> Transformation v n

-- | Carry out some transformation "under" another one: f
--   `<a>underT</a>` t first applies t, then f, then
--   the inverse of t. For example, scaleX 2
--   `<a>underT</a>` rotation (-1/8 @@ Turn) is the
--   transformation which scales by a factor of 2 along the diagonal line y
--   = x.
--   
--   Note that
--   
--   
--   (transform t2) underT t1 == transform (conjugate t1 t2)
--   
--   
--   for all transformations t1 and t2.
--   
--   See also the isomorphisms like transformed, movedTo,
--   movedFrom, and translated.
underT :: (InSpace v n a, SameSpace a b, Transformable a, Transformable b) => (a -> b) -> Transformation v n -> a -> b

-- | Use a Transformation to make an Iso between an object
--   transformed and untransformed. This is useful for carrying out
--   functions under another transform:
--   
--   
--   under (transformed t) f               == transform (inv t) . f . transform t
--   under (transformed t1) (transform t2) == transform (conjugate t1 t2)
--   transformed t ## a                    == transform t a
--   a ^. transformed t                    == transform (inv t) a
--   
transformed :: (InSpace v n a, SameSpace a b, Transformable a, Transformable b) => Transformation v n -> Iso a b a b

-- | Use a vector to make an Iso between an object translated and
--   untranslated.
--   
--   
--   under (translated v) f == translate (-v) . f . translate v
--   translated v ## a      == translate v a
--   a ^. translated v      == translate (-v) a
--   over (translated v) f  == translate v . f . translate (-v)
--   
translated :: (InSpace v n a, SameSpace a b, Transformable a, Transformable b) => v n -> Iso a b a b

-- | Use a Point to make an Iso between an object moved to
--   and from that point:
--   
--   
--   under (movedTo p) f == moveTo (-p) . f . moveTo p
--   over (movedTo p) f  == moveTo p . f . moveTo (-p)
--   movedTo p           == from (movedFrom p)
--   movedTo p ## a      == moveTo p a
--   a ^. movedTo p      == moveOriginTo p a
--   
movedTo :: (InSpace v n a, SameSpace a b, HasOrigin a, HasOrigin b) => Point v n -> Iso a b a b

-- | Use a Transformation to make an Iso between an object
--   transformed and untransformed. We have
--   
--   
--   under (movedFrom p) f == moveTo p . f . moveTo (-p)
--   movedFrom p           == from (movedTo p)
--   movedFrom p ## a      == moveOriginTo p a
--   a ^. movedFrom p      == moveTo p a
--   over (movedFrom p) f  == moveTo (-p) . f . moveTo p
--   
movedFrom :: (InSpace v n a, SameSpace a b, HasOrigin a, HasOrigin b) => Point v n -> Iso a b a b

-- | Class of types which have an intrinsic notion of a "local origin",
--   i.e. things which are not invariant under translation, and which allow
--   the origin to be moved.
--   
--   One might wonder why not just use Transformable instead of
--   having a separate class for HasOrigin; indeed, for types which
--   are instances of both we should have the identity
--   
--   
--   moveOriginTo (origin .^+ v) === translate (negated v)
--   
--   
--   
--   The reason is that some things (e.g. vectors, Trails) are
--   transformable but are translationally invariant, i.e. have no origin.
class HasOrigin t

-- | Move the local origin to another point.
--   
--   Note that this function is in some sense dual to translate
--   (for types which are also Transformable); moving the origin
--   itself while leaving the object "fixed" is dual to fixing the origin
--   and translating the diagram.
moveOriginTo :: HasOrigin t => Point (V t) (N t) -> t -> t

-- | Move the local origin by a relative vector.
moveOriginBy :: ((~) (* -> *) (V t) v, (~) * (N t) n, Num n, HasOrigin t) => v n -> t -> t

-- | Transformations specific to two dimensions, with a few generic
--   transformations (uniform scaling, translation) also re-exported for
--   convenience.
module Diagrams.TwoD.Transform
type T2 = Transformation V2

-- | Create a transformation which performs a rotation about the local
--   origin by the given angle. See also rotate.
rotation :: Floating n => Angle n -> T2 n

-- | Rotate about the local origin by the given angle. Positive angles
--   correspond to counterclockwise rotation, negative to clockwise. The
--   angle can be expressed using any of the Isos on Angle.
--   For example, rotate (1/4 @@ turn), rotate (tau/4
--   @@ rad), and rotate (90 @@ deg) all represent the same
--   transformation, namely, a counterclockwise rotation by a right angle.
--   To rotate about some point other than the local origin, see
--   rotateAbout.
--   
--   Note that writing rotate (1/4), with no Angle
--   constructor, will yield an error since GHC cannot figure out which
--   sort of angle you want to use. In this common situation you can use
--   rotateBy, which interprets its argument as a number of turns.
rotate :: (InSpace V2 n t, Transformable t, Floating n) => Angle n -> t -> t

-- | A synonym for rotate, interpreting its argument in units of
--   turns; it can be more convenient to write rotateBy (1/4) than
--   rotate (1/4 @@ turn).
rotateBy :: (InSpace V2 n t, Transformable t, Floating n) => n -> t -> t

-- | Use an Angle to make an Iso between an object rotated
--   and unrotated. This us useful for performing actions under a
--   rotation:
--   
--   
--   under (rotated t) f = rotate (negated t) . f . rotate t
--   rotated t ## a      = rotate t a
--   a ^. rotated t      = rotate (-t) a
--   over (rotated t) f  = rotate t . f . rotate (negated t)
--   
rotated :: (InSpace V2 n a, Floating n, SameSpace a b, Transformable a, Transformable b) => Angle n -> Iso a b a b

-- | rotationAbout p is a rotation about the point p
--   (instead of around the local origin).
rotationAround :: Floating n => P2 n -> Angle n -> T2 n

-- | rotateAbout p is like rotate, except it rotates around
--   the point p instead of around the local origin.
rotateAround :: (InSpace V2 n t, Transformable t, Floating n) => P2 n -> Angle n -> t -> t

-- | The rotation that aligns the x-axis with the given direction.
rotationTo :: OrderedField n => Direction V2 n -> T2 n

-- | Rotate around the local origin such that the x axis aligns with the
--   given direction.
rotateTo :: (InSpace V2 n t, OrderedField n, Transformable t) => Direction V2 n -> t -> t

-- | Construct a transformation which scales by the given factor in the x
--   (horizontal) direction.
scalingX :: (Additive v, R1 v, Fractional n) => n -> Transformation v n

-- | Scale a diagram by the given factor in the x (horizontal) direction.
--   To scale uniformly, use scale.
scaleX :: (InSpace v n t, R2 v, Fractional n, Transformable t) => n -> t -> t

-- | Construct a transformation which scales by the given factor in the y
--   (vertical) direction.
scalingY :: (Additive v, R2 v, Fractional n) => n -> Transformation v n

-- | Scale a diagram by the given factor in the y (vertical) direction. To
--   scale uniformly, use scale.
scaleY :: (InSpace v n t, R2 v, Fractional n, Transformable t) => n -> t -> t

-- | Create a uniform scaling transformation.
scaling :: (Additive v, Fractional n) => n -> Transformation v n

-- | Scale uniformly in every dimension by the given scalar.
scale :: (InSpace v n a, Eq n, Fractional n, Transformable a) => n -> a -> a

-- | scaleToX w scales a diagram in the x (horizontal) direction
--   by whatever factor required to make its width w.
--   scaleToX should not be applied to diagrams with a width of 0,
--   such as vrule.
scaleToX :: (InSpace v n t, R2 v, Enveloped t, Transformable t) => n -> t -> t

-- | scaleToY h scales a diagram in the y (vertical) direction by
--   whatever factor required to make its height h.
--   scaleToY should not be applied to diagrams with a height of
--   0, such as hrule.
scaleToY :: (InSpace v n t, R2 v, Enveloped t, Transformable t) => n -> t -> t

-- | scaleUToX w scales a diagram uniformly by whatever
--   factor required to make its width w. scaleUToX
--   should not be applied to diagrams with a width of 0, such as
--   vrule.
scaleUToX :: (InSpace v n t, R1 v, Enveloped t, Transformable t) => n -> t -> t

-- | scaleUToY h scales a diagram uniformly by whatever
--   factor required to make its height h. scaleUToY
--   should not be applied to diagrams with a height of 0, such as
--   hrule.
scaleUToY :: (InSpace v n t, R2 v, Enveloped t, Transformable t) => n -> t -> t

-- | Construct a transformation which translates by the given distance in
--   the x (horizontal) direction.
translationX :: (Additive v, R1 v, Num n) => n -> Transformation v n

-- | Translate a diagram by the given distance in the x (horizontal)
--   direction.
translateX :: (InSpace v n t, R1 v, Transformable t) => n -> t -> t

-- | Construct a transformation which translates by the given distance in
--   the y (vertical) direction.
translationY :: (Additive v, R2 v, Num n) => n -> Transformation v n

-- | Translate a diagram by the given distance in the y (vertical)
--   direction.
translateY :: (InSpace v n t, R2 v, Transformable t) => n -> t -> t

-- | Create a translation.
translation :: v n -> Transformation v n

-- | Translate by a vector.
translate :: (Num (N t), Transformable t) => Vn t -> t -> t

-- | Construct a transformation which flips a diagram from left to right,
--   i.e. sends the point (x,y) to (-x,y).
reflectionX :: (Additive v, R1 v, Num n) => Transformation v n

-- | Flip a diagram from left to right, i.e. send the point (x,y) to
--   (-x,y).
reflectX :: (InSpace v n t, R1 v, Transformable t) => t -> t

-- | Construct a transformation which flips a diagram from top to bottom,
--   i.e. sends the point (x,y) to (x,-y).
reflectionY :: (Additive v, R2 v, Num n) => Transformation v n

-- | Flip a diagram from top to bottom, i.e. send the point (x,y) to
--   (x,-y).
reflectY :: (InSpace v n t, R2 v, Transformable t) => t -> t

-- | reflectionAbout p d is a reflection in the line determined by
--   the point p and direction d.
reflectionAbout :: OrderedField n => P2 n -> Direction V2 n -> T2 n

-- | reflectAbout p d reflects a diagram in the line determined by
--   the point p and direction d.
reflectAbout :: (InSpace V2 n t, OrderedField n, Transformable t) => P2 n -> Direction V2 n -> t -> t

-- | shearingX d is the linear transformation which is the
--   identity on y coordinates and sends (0,1) to (d,1).
shearingX :: Num n => n -> T2 n

-- | shearX d performs a shear in the x-direction which sends
--   (0,1) to (d,1).
shearX :: (InSpace V2 n t, Transformable t) => n -> t -> t

-- | shearingY d is the linear transformation which is the
--   identity on x coordinates and sends (1,0) to (1,d).
shearingY :: Num n => n -> T2 n

-- | shearY d performs a shear in the y-direction which sends
--   (1,0) to (1,d).
shearY :: (InSpace V2 n t, Transformable t) => n -> t -> t

-- | Transformations specific to three dimensions, with a few generic
--   transformations (uniform scaling, translation) also re-exported for
--   convenience.
module Diagrams.ThreeD.Transform
type T3 = Transformation V3

-- | Like aboutZ, but rotates about the X axis, bringing positive
--   y-values towards the positive z-axis.
aboutX :: Floating n => Angle n -> Transformation V3 n

-- | Like aboutZ, but rotates about the Y axis, bringing postive
--   x-values towards the negative z-axis.
aboutY :: Floating n => Angle n -> Transformation V3 n

-- | Create a transformation which rotates by the given angle about a line
--   parallel the Z axis passing through the local origin. A positive angle
--   brings positive x-values towards the positive-y axis.
--   
--   The angle can be expressed using any type which is an instance of
--   Angle. For example, aboutZ (1/4 @@ turn),
--   aboutZ (tau/4 @@ rad), and aboutZ (90 @@
--   deg) all represent the same transformation, namely, a
--   counterclockwise rotation by a right angle. For more general
--   rotations, see rotationAbout.
--   
--   Note that writing aboutZ (1/4), with no type annotation, will
--   yield an error since GHC cannot figure out which sort of angle you
--   want to use.
aboutZ :: Floating n => Angle n -> Transformation V3 n

-- | rotationAbout p d a is a rotation about a line parallel to
--   d passing through p.
rotationAbout :: Floating n => Point V3 n -> Direction V3 n -> Angle n -> Transformation V3 n

-- | rotationAbout p d a is a rotation about a line parallel to
--   d passing through p.
rotateAbout :: (InSpace V3 n t, Floating n, Transformable t) => Point V3 n -> Direction V3 n -> Angle n -> t -> t

-- | pointAt about initial final produces a rotation which brings
--   the direction initial to point in the direction
--   final by first panning around about, then tilting
--   about the axis perpendicular to about and final. In
--   particular, if this can be accomplished without tilting, it will be,
--   otherwise if only tilting is necessary, no panning will occur. The
--   tilt will always be between ± 1/4 turn.
pointAt :: Floating n => Direction V3 n -> Direction V3 n -> Direction V3 n -> Transformation V3 n

-- | pointAt' has the same behavior as pointAt, but takes vectors
--   instead of directions.
pointAt' :: Floating n => V3 n -> V3 n -> V3 n -> Transformation V3 n

-- | Construct a transformation which scales by the given factor in the x
--   (horizontal) direction.
scalingX :: (Additive v, R1 v, Fractional n) => n -> Transformation v n

-- | Construct a transformation which scales by the given factor in the y
--   (vertical) direction.
scalingY :: (Additive v, R2 v, Fractional n) => n -> Transformation v n

-- | Construct a transformation which scales by the given factor in the z
--   direction.
scalingZ :: (Additive v, R3 v, Fractional n) => n -> Transformation v n

-- | Scale a diagram by the given factor in the x (horizontal) direction.
--   To scale uniformly, use scale.
scaleX :: (InSpace v n t, R2 v, Fractional n, Transformable t) => n -> t -> t

-- | Scale a diagram by the given factor in the y (vertical) direction. To
--   scale uniformly, use scale.
scaleY :: (InSpace v n t, R2 v, Fractional n, Transformable t) => n -> t -> t

-- | Scale a diagram by the given factor in the z direction. To scale
--   uniformly, use scale.
scaleZ :: (InSpace v n t, R3 v, Fractional n, Transformable t) => n -> t -> t

-- | Create a uniform scaling transformation.
scaling :: (Additive v, Fractional n) => n -> Transformation v n

-- | Scale uniformly in every dimension by the given scalar.
scale :: (InSpace v n a, Eq n, Fractional n, Transformable a) => n -> a -> a

-- | Construct a transformation which translates by the given distance in
--   the x (horizontal) direction.
translationX :: (Additive v, R1 v, Num n) => n -> Transformation v n

-- | Translate a diagram by the given distance in the x (horizontal)
--   direction.
translateX :: (InSpace v n t, R1 v, Transformable t) => n -> t -> t

-- | Construct a transformation which translates by the given distance in
--   the y (vertical) direction.
translationY :: (Additive v, R2 v, Num n) => n -> Transformation v n

-- | Translate a diagram by the given distance in the y (vertical)
--   direction.
translateY :: (InSpace v n t, R2 v, Transformable t) => n -> t -> t

-- | Construct a transformation which translates by the given distance in
--   the z direction.
translationZ :: (Additive v, R3 v, Num n) => n -> Transformation v n

-- | Translate a diagram by the given distance in the y direction.
translateZ :: (InSpace v n t, R3 v, Transformable t) => n -> t -> t

-- | Create a translation.
translation :: v n -> Transformation v n

-- | Translate by a vector.
translate :: (Num (N t), Transformable t) => Vn t -> t -> t

-- | Construct a transformation which flips a diagram from left to right,
--   i.e. sends the point (x,y) to (-x,y).
reflectionX :: (Additive v, R1 v, Num n) => Transformation v n

-- | Flip a diagram from left to right, i.e. send the point (x,y) to
--   (-x,y).
reflectX :: (InSpace v n t, R1 v, Transformable t) => t -> t

-- | Construct a transformation which flips a diagram from top to bottom,
--   i.e. sends the point (x,y) to (x,-y).
reflectionY :: (Additive v, R2 v, Num n) => Transformation v n

-- | Flip a diagram from top to bottom, i.e. send the point (x,y) to
--   (x,-y).
reflectY :: (InSpace v n t, R2 v, Transformable t) => t -> t

-- | Construct a transformation which flips a diagram across z=0, i.e.
--   sends the point (x,y,z) to (x,y,-z).
reflectionZ :: (Additive v, R3 v, Num n) => Transformation v n

-- | Flip a diagram across z=0, i.e. send the point (x,y,z) to (x,y,-z).
reflectZ :: (InSpace v n t, R3 v, Transformable t) => t -> t

-- | reflectionAcross p v is a reflection across the plane through
--   the point p and normal to vector v. This also works
--   as a 2D transform where v is the normal to the line passing
--   through point p.
reflectionAcross :: (Metric v, Fractional n) => Point v n -> v n -> Transformation v n

-- | reflectAcross p v reflects a diagram across the plane though
--   the point p and the vector v. This also works as a
--   2D transform where v is the normal to the line passing
--   through point p.
reflectAcross :: (InSpace v n t, Metric v, Fractional n, Transformable t) => Point v n -> v n -> t -> t

-- | Wrapper for creating scale-invariant objects in two dimensions.
module Diagrams.Transform.ScaleInv

-- | The ScaleInv wrapper creates two-dimensional
--   scale-invariant objects. Intuitively, a scale-invariant object
--   is affected by transformations like translations and rotations, but
--   not by scales.
--   
--   However, this is problematic when it comes to non-uniform
--   scales (e.g. scaleX 2 . scaleY 3) since they can
--   introduce a perceived rotational component. The prototypical example
--   is an arrowhead on the end of a path, which should be scale-invariant.
--   However, applying a non-uniform scale to the path but not the
--   arrowhead would leave the arrowhead pointing in the wrong direction.
--   
--   Moreover, for objects whose local origin is not at the local origin of
--   the parent diagram, any scale can result in a translational component
--   as well.
--   
--   The solution is to also store a point (indicating the location,
--   i.e. the local origin) and a unit vector (indicating the
--   direction) along with a scale-invariant object. A
--   transformation to be applied is decomposed into rotational and
--   translational components as follows:
--   
--   
--   
- The transformation is applied to the direction vector, and the
--   difference in angle between the original direction vector and its
--   image under the transformation determines the rotational component.
--   The rotation is applied with respect to the stored location, rather
--   than the global origin.
--   
- The vector from the location to the image of the location under
--   the transformation determines the translational component.
--   
data ScaleInv t
ScaleInv :: t -> Vn t -> Point (V t) (N t) -> ScaleInv t
[_scaleInvObj] :: ScaleInv t -> t
[_scaleInvDir] :: ScaleInv t -> Vn t
[_scaleInvLoc] :: ScaleInv t -> Point (V t) (N t)
scaleInvObj :: Lens' (ScaleInv t_a17xW) t_a17xW
scaleInvDir :: Lens' (ScaleInv t_a17xW) (Vn t_a17xW)
scaleInvLoc :: Lens' (ScaleInv t_a17xW) (Point (V t_a17xW) (N t_a17xW))

-- | Create a scale-invariant object pointing in the given direction,
--   located at the origin.
scaleInv :: (V t ~ v, N t ~ n, Additive v, Num n) => t -> v n -> ScaleInv t

-- | Create a diagram from a single scale-invariant primitive. The vector
--   argument specifies the direction in which the primitive is "pointing"
--   (for the purpose of keeping it rotated correctly under non-uniform
--   scaling). The primitive is assumed to be "located" at the origin (for
--   the purpose of translating it correctly under scaling).
--   
--   Note that the resulting diagram will have an empty envelope,
--   trace, and query. The reason is that the envelope, trace, and query
--   cannot be cached---applying a transformation would cause the cached
--   envelope, etc. to get "out of sync" with the scale-invariant object.
--   The intention, at any rate, is that scale-invariant things will be
--   used only as "decorations" (e.g. arrowheads) which should not
--   affect the envelope, trace, and query.
scaleInvPrim :: (V t ~ V2, N t ~ n, RealFloat n, Transformable t, Typeable t, Renderable t b, Monoid m) => t -> V2 n -> QDiagram b (V t) (N t) m
instance (Diagrams.Core.V.V t ~ v, Diagrams.Core.V.N t ~ n, Linear.Vector.Additive v, GHC.Num.Num n, Diagrams.Core.HasOrigin.HasOrigin t) => Diagrams.Core.HasOrigin.HasOrigin (Diagrams.Transform.ScaleInv.ScaleInv t)
instance (Diagrams.Core.V.V t ~ Linear.V2.V2, Diagrams.Core.V.N t ~ n, GHC.Float.RealFloat n, Diagrams.Core.Transform.Transformable t) => Diagrams.Core.Transform.Transformable (Diagrams.Transform.ScaleInv.ScaleInv t)
instance (Diagrams.Core.V.V t ~ Linear.V2.V2, Diagrams.Core.V.N t ~ n, GHC.Float.RealFloat n, Diagrams.Core.Types.Renderable t b) => Diagrams.Core.Types.Renderable (Diagrams.Transform.ScaleInv.ScaleInv t) b
instance (GHC.Show.Show t, GHC.Show.Show (Diagrams.Core.V.Vn t)) => GHC.Show.Show (Diagrams.Transform.ScaleInv.ScaleInv t)

-- | Type classes for things which are parameterized in some way,
--   e.g. segments and trails.
module Diagrams.Parametric

-- | The standard tolerance used by std... functions (like
--   stdArcLength and stdArcLengthToParam, currently set at
--   1e-6.
stdTolerance :: Fractional a => a

-- | Codomain of parametric classes. This is usually either (V p),
--   for relative vector results, or (Point (V p)), for functions
--   with absolute coordinates.

-- | Type class for parametric functions.
class Parametric p

-- | atParam yields a parameterized view of an object as a
--   continuous function. It is designed to be used infix, like path
--   `<a>atParam</a>` 0.5.
atParam :: Parametric p => p -> N p -> Codomain p (N p)

-- | Type class for parametric functions with a bounded domain. The default
--   bounds are [0,1].
--   
--   Note that this domain indicates the main "interesting" portion of the
--   function. It must be defined within this range, but for some instances
--   may still have sensible values outside.
class DomainBounds p where domainLower = const 0 domainUpper = const 1

-- | domainLower defaults to being constantly 0 (for vector spaces
--   with numeric scalars).
domainLower :: DomainBounds p => p -> N p

-- | domainUpper defaults to being constantly 1 (for vector spaces
--   with numeric scalars).
domainUpper :: DomainBounds p => p -> N p

-- | Return the lower and upper bounds of a parametric domain together as a
--   pair.
domainBounds :: DomainBounds p => p -> (N p, N p)

-- | Type class for querying the values of a parametric object at the ends
--   of its domain.
class (Parametric p, DomainBounds p) => EndValues p where atStart x = x `atParam` domainLower x atEnd x = x `atParam` domainUpper x

-- | atStart is the value at the start of the domain. That is,
--   
--   
--   atStart x = x `atParam` domainLower x
--   
--   
--   This is the default implementation, but some representations will have
--   a more efficient and/or precise implementation.
atStart :: EndValues p => p -> Codomain p (N p)

-- | atEnd is the value at the end of the domain. That is,
--   
--   
--   atEnd x = x `atParam` domainUpper x
--   
--   
--   This is the default implementation, but some representations will have
--   a more efficient and/or precise implementation.
atEnd :: EndValues p => p -> Codomain p (N p)

-- | Type class for parametric objects which can be split into subobjects.
--   
--   Minimal definition: Either splitAtParam or section, plus
--   reverseDomain.
class DomainBounds p => Sectionable p where splitAtParam x t = (section x (domainLower x) t, section x t (domainUpper x)) section x t1 t2 = snd (splitAtParam (fst (splitAtParam x t2)) (t1 / t2))

-- | splitAtParam splits an object p into two new objects
--   (l,r) at the parameter t, where l
--   corresponds to the portion of p for parameter values from
--   0 to t and r for to that from t to
--   1. The following property should hold:
--   
--   
--   prop_splitAtParam f t u =
--     | u < t     = atParam f u == atParam l (u / t)
--     | otherwise = atParam f u == atParam f t ??? atParam l ((u - t) / (domainUpper f - t))
--     where (l,r) = splitAtParam f t
--   
--   
--   where (???) = (^+^) if the codomain is a vector type, or
--   const flip if the codomain is a point type. Stated more
--   intuitively, all this is to say that the parameterization scales
--   linearly with splitting.
--   
--   splitAtParam can also be used with parameters outside the range
--   of the domain. For example, using the parameter 2 with a path
--   (where the domain is the default [0,1]) gives two result
--   paths where the first is the original path extended to the parameter
--   2, and the second result path travels backwards from the end of
--   the first to the end of the original path.
splitAtParam :: Sectionable p => p -> N p -> (p, p)

-- | Extract a particular section of the domain, linearly reparameterized
--   to the same domain as the original. Should satisfy the property:
--   
--   
--   prop_section x l u t =
--     let s = section x l u
--     in     domainBounds x == domainBounds x
--         && (x `atParam` lerp l u t) == (s `atParam` t)
--   
--   
--   That is, the section should have the same domain as the original, and
--   the reparameterization should be linear.
section :: Sectionable p => p -> N p -> N p -> p

-- | Flip the parameterization on the domain.
reverseDomain :: Sectionable p => p -> p

-- | Type class for parametric things with a notion of arc length.
class Parametric p => HasArcLength p where arcLength eps = midpoint . arcLengthBounded eps stdArcLength = arcLength stdTolerance stdArcLengthToParam = arcLengthToParam stdTolerance

-- | arcLengthBounded eps x approximates the arc length of
--   x. The true arc length is guaranteed to lie within the
--   interval returned, which will have a size of at most eps.
arcLengthBounded :: HasArcLength p => N p -> p -> Interval (N p)

-- | arcLength eps s approximates the arc length of x up
--   to the accuracy eps (plus or minus).
arcLength :: HasArcLength p => N p -> p -> N p

-- | Approximate the arc length up to a standard accuracy of
--   stdTolerance (1e-6).
stdArcLength :: HasArcLength p => p -> N p

-- | arcLengthToParam eps s l converts the absolute arc
--   length l, measured from the start of the domain, to a
--   parameter on the object s. The true arc length at the
--   parameter returned is guaranteed to be within eps of the
--   requested arc length.
--   
--   This should work for any arc length, and may return any
--   parameter value (not just parameters in the domain).
arcLengthToParam :: HasArcLength p => N p -> p -> N p -> N p

-- | A simple interface to convert arc length to a parameter, guaranteed to
--   be accurate within stdTolerance, or 1e-6.
stdArcLengthToParam :: HasArcLength p => p -> N p -> N p

-- | Tools for adjusting the length of parametric objects such as segments
--   and trails.
module Diagrams.Parametric.Adjust

-- | Adjust the length of a parametric object such as a segment or trail.
--   The second parameter is an option record which controls how the
--   adjustment should be performed; see AdjustOpts.
adjust :: (V t ~ v, N t ~ n, DomainBounds t, Sectionable t, HasArcLength t, Fractional n) => t -> AdjustOpts n -> t

-- | How should a segment, trail, or path be adjusted?
data AdjustOpts n

-- | Which method should be used for adjusting?
adjMethod :: Lens' (AdjustOpts n) (AdjustMethod n)

-- | Which end(s) of the object should be adjusted?
adjSide :: Lens' (AdjustOpts n) AdjustSide

-- | Tolerance to use when doing adjustment.
adjEps :: Lens' (AdjustOpts n) n

-- | What method should be used for adjusting a segment, trail, or path?
data AdjustMethod n

-- | Extend by the given parameter value (use a negative parameter to
--   shrink)
ByParam :: n -> AdjustMethod n

-- | Extend by the given arc length (use a negative length to shrink)
ByAbsolute :: n -> AdjustMethod n

-- | Extend or shrink to the given arc length
ToAbsolute :: n -> AdjustMethod n

-- | Which side of a segment, trail, or path should be adjusted?
data AdjustSide

-- | Adjust only the beginning
Start :: AdjustSide

-- | Adjust only the end
End :: AdjustSide

-- | Adjust both sides equally
Both :: AdjustSide
instance GHC.Real.Fractional n => Data.Default.Class.Default (Diagrams.Parametric.Adjust.AdjustMethod n)
instance Data.Default.Class.Default Diagrams.Parametric.Adjust.AdjustSide
instance GHC.Real.Fractional n => Data.Default.Class.Default (Diagrams.Parametric.Adjust.AdjustOpts n)
instance GHC.Enum.Enum Diagrams.Parametric.Adjust.AdjustSide
instance GHC.Enum.Bounded Diagrams.Parametric.Adjust.AdjustSide
instance GHC.Classes.Ord Diagrams.Parametric.Adjust.AdjustSide
instance GHC.Classes.Eq Diagrams.Parametric.Adjust.AdjustSide
instance GHC.Read.Read Diagrams.Parametric.Adjust.AdjustSide
instance GHC.Show.Show Diagrams.Parametric.Adjust.AdjustSide

-- | Bernstein polynomials, used internally by code to find intersections
--   of paths. This module is probably not of any relevance to most users
--   of diagrams.
module Diagrams.TwoD.Segment.Bernstein
data BernsteinPoly n
BernsteinPoly :: Int -> [n] -> BernsteinPoly n
[bernsteinDegree] :: BernsteinPoly n -> Int
[bernsteinCoeffs] :: BernsteinPoly n -> [n]

-- | Create a bernstein polynomial from a list of coëfficients.
listToBernstein :: Fractional n => [n] -> BernsteinPoly n

-- | Evaluate the bernstein polynomial.
evaluateBernstein :: Fractional n => BernsteinPoly n -> n -> n

-- | Degree elevate a bernstein polynomial a number of times.
degreeElevate :: Fractional n => BernsteinPoly n -> Int -> BernsteinPoly n

-- | Find the derivative of a bernstein polynomial.
bernsteinDeriv :: Fractional n => BernsteinPoly n -> BernsteinPoly n

-- | Evaluate the bernstein polynomial and its derivatives.
evaluateBernsteinDerivs :: Fractional n => BernsteinPoly n -> n -> [n]
instance GHC.Base.Functor Diagrams.TwoD.Segment.Bernstein.BernsteinPoly
instance GHC.Show.Show n => GHC.Show.Show (Diagrams.TwoD.Segment.Bernstein.BernsteinPoly n)
instance GHC.Real.Fractional n => Diagrams.Parametric.Parametric (Diagrams.TwoD.Segment.Bernstein.BernsteinPoly n)
instance GHC.Num.Num n => Diagrams.Parametric.DomainBounds (Diagrams.TwoD.Segment.Bernstein.BernsteinPoly n)
instance GHC.Real.Fractional n => Diagrams.Parametric.EndValues (Diagrams.TwoD.Segment.Bernstein.BernsteinPoly n)
instance GHC.Real.Fractional n => Diagrams.Parametric.Sectionable (Diagrams.TwoD.Segment.Bernstein.BernsteinPoly n)
instance GHC.Real.Fractional n => GHC.Num.Num (Diagrams.TwoD.Segment.Bernstein.BernsteinPoly n)

-- | "Located" things, i.e. things with a concrete location:
--   intuitively, Located a ~ (a, Point). Wrapping a
--   translationally invariant thing (e.g. a Segment or
--   Trail) in Located pins it down to a particular
--   location and makes it no longer translationally invariant.
module Diagrams.Located

-- | "Located" things, i.e. things with a concrete location:
--   intuitively, Located a ~ (Point, a). Wrapping a
--   translationally invariant thing (e.g. a Segment or
--   Trail) in Located pins it down to a particular
--   location and makes it no longer translationally invariant.
--   
--   Located is intentionally abstract. To construct
--   Located values, use at. To destruct, use
--   viewLoc, unLoc, or loc. To map, use
--   mapLoc.
--   
--   Much of the utility of having a concrete type for the Located
--   concept lies in the type class instances we can give it. The
--   HasOrigin, Transformable, Enveloped,
--   Traced, and TrailLike instances are particularly
--   useful; see the documented instances below for more information.
data Located a
Loc :: Point (V a) (N a) -> a -> Located a

-- | Project out the location of a Located value.
[loc] :: Located a -> Point (V a) (N a)

-- | Project the value of type a out of a Located a,
--   discarding the location.
[unLoc] :: Located a -> a

-- | Construct a Located a from a value of type a and a
--   location. at is intended to be used infix, like x `at`
--   origin.
at :: a -> Point (V a) (N a) -> Located a

-- | Deconstruct a Located a into a location and a value of type
--   a. viewLoc can be especially useful in conjunction
--   with the ViewPatterns extension.
viewLoc :: Located a -> (Point (V a) (N a), a)

-- | Located is not a Functor, since changing the type
--   could change the type of the associated vector space, in which case
--   the associated location would no longer have the right type.
--   mapLoc has an extra constraint specifying that the vector space
--   must stay the same.
--   
--   (Technically, one can say that for every vector space v,
--   Located is a little-f (endo)functor on the category of types
--   with associated vector space v; but that is not covered by
--   the standard Functor class.)
mapLoc :: SameSpace a b => (a -> b) -> Located a -> Located b

-- | A lens giving access to the object within a Located wrapper.
located :: SameSpace a b => Lens (Located a) (Located b) a b

-- | Lens onto the location of something Located.
_loc :: Lens' (Located a) (Point (V a) (N a))
instance (GHC.Classes.Eq (Diagrams.Core.V.V a (Diagrams.Core.V.N a)), GHC.Classes.Eq a) => GHC.Classes.Eq (Diagrams.Located.Located a)
instance (GHC.Classes.Ord (Diagrams.Core.V.V a (Diagrams.Core.V.N a)), GHC.Classes.Ord a) => GHC.Classes.Ord (Diagrams.Located.Located a)
instance (GHC.Show.Show (Diagrams.Core.V.V a (Diagrams.Core.V.N a)), GHC.Show.Show a) => GHC.Show.Show (Diagrams.Located.Located a)
instance (GHC.Read.Read (Diagrams.Core.V.V a (Diagrams.Core.V.N a)), GHC.Read.Read a) => GHC.Read.Read (Diagrams.Located.Located a)
instance (GHC.Num.Num (Diagrams.Core.V.N a), Linear.Vector.Additive (Diagrams.Core.V.V a)) => Diagrams.Core.HasOrigin.HasOrigin (Diagrams.Located.Located a)
instance (Linear.Vector.Additive (Diagrams.Core.V.V a), GHC.Num.Num (Diagrams.Core.V.N a), Diagrams.Core.Transform.Transformable a) => Diagrams.Core.Transform.Transformable (Diagrams.Located.Located a)
instance Diagrams.Core.Envelope.Enveloped a => Diagrams.Core.Envelope.Enveloped (Diagrams.Located.Located a)
instance Diagrams.Core.Envelope.Enveloped a => Diagrams.Core.Juxtapose.Juxtaposable (Diagrams.Located.Located a)
instance (Diagrams.Core.Trace.Traced a, GHC.Num.Num (Diagrams.Core.V.N a)) => Diagrams.Core.Trace.Traced (Diagrams.Located.Located a)
instance Diagrams.Core.Names.Qualifiable a => Diagrams.Core.Names.Qualifiable (Diagrams.Located.Located a)
instance (Diagrams.Core.V.InSpace v n a, Diagrams.Parametric.Parametric a, Diagrams.Parametric.Codomain a ~ v) => Diagrams.Parametric.Parametric (Diagrams.Located.Located a)
instance Diagrams.Parametric.DomainBounds a => Diagrams.Parametric.DomainBounds (Diagrams.Located.Located a)
instance (Diagrams.Core.V.InSpace v n a, Diagrams.Parametric.EndValues a, Diagrams.Parametric.Codomain a ~ v) => Diagrams.Parametric.EndValues (Diagrams.Located.Located a)
instance (Diagrams.Core.V.InSpace v n a, GHC.Real.Fractional n, Diagrams.Parametric.Parametric a, Diagrams.Parametric.Sectionable a, Diagrams.Parametric.Codomain a ~ v) => Diagrams.Parametric.Sectionable (Diagrams.Located.Located a)
instance (Diagrams.Core.V.InSpace v n a, GHC.Real.Fractional n, Diagrams.Parametric.HasArcLength a, Diagrams.Parametric.Codomain a ~ v) => Diagrams.Parametric.HasArcLength (Diagrams.Located.Located a)

-- | A segment is a translation-invariant, atomic path. Currently,
--   there are two types: linear (i.e. just a straight line to the
--   endpoint) and cubic Bézier curves (i.e. a curve to an endpoint
--   with two control points). This module contains tools for creating and
--   manipulating segments, as well as a definition of segments with a
--   fixed location (useful for backend implementors).
--   
--   Generally speaking, casual users of diagrams should not need this
--   module; the higher-level functionality provided by
--   Diagrams.Trail, Diagrams.TrailLike, and
--   Diagrams.Path should usually suffice. However, directly
--   manipulating segments can occasionally be useful.
module Diagrams.Segment

-- | Type tag for open segments.
data Open

-- | Type tag for closed segments.
data Closed

-- | The offset of a segment is the vector from its starting point
--   to its end. The offset for an open segment is determined by the
--   context, i.e. its endpoint is not fixed. The offset for a
--   closed segment is stored explicitly, i.e. its endpoint
--   is at a fixed offset from its start.
data Offset c v n
OffsetOpen :: Offset Open v n
OffsetClosed :: v n -> Offset Closed v n

-- | Compute the offset from the start of a segment to the end. Note that
--   in the case of a Bézier segment this is not the same as the
--   length of the curve itself; for that, see arcLength.
segOffset :: Segment Closed v n -> v n

-- | The atomic constituents of the concrete representation currently used
--   for trails are segments, currently limited to single straight
--   lines or cubic Bézier curves. Segments are translationally
--   invariant, that is, they have no particular "location" and are
--   unaffected by translations. They are, however, affected by other
--   transformations such as rotations and scales.
data Segment c v n

-- | A linear segment with given offset.
Linear :: !(Offset c v n) -> Segment c v n

-- | A cubic Bézier segment specified by three offsets from the starting
--   point to the first control point, second control point, and ending
--   point, respectively.
Cubic :: !(v n) -> !(v n) -> !(Offset c v n) -> Segment c v n

-- | straight v constructs a translationally invariant
--   linear segment with direction and length given by the vector
--   v.
straight :: v n -> Segment Closed v n

-- | bezier3 c1 c2 x constructs a translationally invariant cubic
--   Bézier curve where the offsets from the first endpoint to the first
--   and second control point and endpoint are respectively given by
--   c1, c2, and x.
bezier3 :: v n -> v n -> v n -> Segment Closed v n

-- | bézier3 is the same as bezier3, but with more
--   snobbery.
bézier3 :: v n -> v n -> v n -> Segment Closed v n

-- | Reverse the direction of a segment.
reverseSegment :: (Num n, Additive v) => Segment Closed v n -> Segment Closed v n

-- | Map over the vectors of each segment.
mapSegmentVectors :: (v n -> v' n') -> Segment c v n -> Segment c v' n'

-- | An open linear segment. This means the trail makes a straight line
--   from the last segment the beginning to form a loop.
openLinear :: Segment Open v n

-- | An open cubic segment. This means the trail makes a cubic bézier with
--   control vectors v1 and v2 to form a loop.
openCubic :: v n -> v n -> Segment Open v n

-- | FixedSegments are like Segments except that they have
--   absolute locations. FixedSegment v is isomorphic to
--   Located (Segment Closed v), as witnessed by mkFixedSeg
--   and fromFixedSeg, but FixedSegment is convenient when
--   one needs the absolute locations of the vertices and control points.
data FixedSegment v n
FLinear :: (Point v n) -> (Point v n) -> FixedSegment v n
FCubic :: (Point v n) -> (Point v n) -> (Point v n) -> (Point v n) -> FixedSegment v n

-- | Create a FixedSegment from a located Segment.
mkFixedSeg :: (Num n, Additive v) => Located (Segment Closed v n) -> FixedSegment v n

-- | Convert a FixedSegment back into a located Segment.
fromFixedSeg :: (Num n, Additive v) => FixedSegment v n -> Located (Segment Closed v n)

-- | Use a FixedSegment to make an Iso between an a fixed
--   segment and a located segment.
fixedSegIso :: (Num n, Additive v) => Iso' (FixedSegment v n) (Located (Segment Closed v n))

-- | A type to track the count of segments in a Trail.
newtype SegCount
SegCount :: (Sum Int) -> SegCount

-- | A type to represent the total arc length of a chain of segments. The
--   first component is a "standard" arc length, computed to within a
--   tolerance of 10e-6. The second component is a generic arc
--   length function taking the tolerance as an argument.
newtype ArcLength n
ArcLength :: (Sum (Interval n), n -> Sum (Interval n)) -> ArcLength n

-- | Project out the cached arc length, stored together with error bounds.
getArcLengthCached :: ArcLength n -> Interval n

-- | Project out the generic arc length function taking the tolerance as an
--   argument.
getArcLengthFun :: ArcLength n -> n -> Interval n

-- | Given a specified tolerance, project out the cached arc length if it
--   is accurate enough; otherwise call the generic arc length function
--   with the given tolerance.
getArcLengthBounded :: (Num n, Ord n) => n -> ArcLength n -> Interval n

-- | A type to represent the total cumulative offset of a chain of
--   segments.
newtype TotalOffset v n
TotalOffset :: (v n) -> TotalOffset v n

-- | A type to represent the offset and envelope of a chain of segments.
--   They have to be paired into one data structure, since combining the
--   envelopes of two consecutive chains needs to take the offset of the
--   first into account.
data OffsetEnvelope v n
OffsetEnvelope :: !(TotalOffset v n) -> Envelope v n -> OffsetEnvelope v n
[_oeOffset] :: OffsetEnvelope v n -> !(TotalOffset v n)
[_oeEnvelope] :: OffsetEnvelope v n -> Envelope v n
oeOffset :: Lens' (OffsetEnvelope v_a1mIU n_a1mIV) (TotalOffset v_a1mIU n_a1mIV)
oeEnvelope :: Lens' (OffsetEnvelope v_a1mIU n_a1mIV) (Envelope v_a1mIU n_a1mIV)

-- | SegMeasure collects up all the measurements over a chain of
--   segments.
type SegMeasure v n = SegCount ::: (ArcLength n ::: (OffsetEnvelope v n ::: ()))
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n) => Data.Semigroup.Semigroup (Diagrams.Segment.OffsetEnvelope v n)
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n) => Data.FingerTree.Measured (Diagrams.Segment.SegMeasure v n) (Diagrams.Segment.SegMeasure v n)
instance (Diagrams.Core.Envelope.OrderedField n, Linear.Metric.Metric v) => Data.FingerTree.Measured (Diagrams.Segment.SegMeasure v n) (Diagrams.Segment.Segment Diagrams.Segment.Closed v n)
instance GHC.Base.Monoid Diagrams.Segment.SegCount
instance Data.Semigroup.Semigroup Diagrams.Segment.SegCount
instance GHC.Show.Show (v n) => GHC.Show.Show (Diagrams.Segment.FixedSegment v n)
instance GHC.Classes.Ord (v n) => GHC.Classes.Ord (Diagrams.Segment.Segment c v n)
instance GHC.Classes.Eq (v n) => GHC.Classes.Eq (Diagrams.Segment.Segment c v n)
instance GHC.Base.Functor v => GHC.Base.Functor (Diagrams.Segment.Segment c v)
instance GHC.Show.Show (v n) => GHC.Show.Show (Diagrams.Segment.Offset c v n)
instance GHC.Classes.Eq (v n) => GHC.Classes.Eq (Diagrams.Segment.Offset c v n)
instance GHC.Classes.Ord (v n) => GHC.Classes.Ord (Diagrams.Segment.Offset c v n)
instance (GHC.Num.Num n, GHC.Classes.Ord n) => Data.Semigroup.Semigroup (Diagrams.Segment.ArcLength n)
instance (GHC.Num.Num n, GHC.Classes.Ord n) => GHC.Base.Monoid (Diagrams.Segment.ArcLength n)
instance GHC.Base.Functor v => GHC.Base.Functor (Diagrams.Segment.Offset c v)
instance Control.Lens.Each.Each (Diagrams.Segment.Offset c v n) (Diagrams.Segment.Offset c v' n') (v n) (v' n')
instance (Linear.Vector.Additive v, GHC.Num.Num n) => Control.Lens.Internal.Iso.Reversing (Diagrams.Segment.Offset c v n)
instance Diagrams.Core.Transform.Transformable (Diagrams.Segment.Offset c v n)
instance GHC.Show.Show (v n) => GHC.Show.Show (Diagrams.Segment.Segment c v n)
instance Control.Lens.Each.Each (Diagrams.Segment.Segment c v n) (Diagrams.Segment.Segment c v' n') (v n) (v' n')
instance (Linear.Vector.Additive v, GHC.Num.Num n) => Control.Lens.Internal.Iso.Reversing (Diagrams.Segment.Segment Diagrams.Segment.Closed v n)
instance Diagrams.Core.Transform.Transformable (Diagrams.Segment.Segment c v n)
instance Diagrams.Core.Types.Renderable (Diagrams.Segment.Segment c v n) Diagrams.Core.Types.NullBackend
instance (Linear.Vector.Additive v, GHC.Num.Num n) => Diagrams.Parametric.Parametric (Diagrams.Segment.Segment Diagrams.Segment.Closed v n)
instance GHC.Num.Num n => Diagrams.Parametric.DomainBounds (Diagrams.Segment.Segment Diagrams.Segment.Closed v n)
instance (Linear.Vector.Additive v, GHC.Num.Num n) => Diagrams.Parametric.EndValues (Diagrams.Segment.Segment Diagrams.Segment.Closed v n)
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n) => Diagrams.Core.Envelope.Enveloped (Diagrams.Segment.Segment Diagrams.Segment.Closed v n)
instance (Linear.Vector.Additive v, GHC.Real.Fractional n) => Diagrams.Parametric.Sectionable (Diagrams.Segment.Segment Diagrams.Segment.Closed v n)
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n) => Diagrams.Parametric.HasArcLength (Diagrams.Segment.Segment Diagrams.Segment.Closed v n)
instance Control.Lens.Each.Each (Diagrams.Segment.FixedSegment v n) (Diagrams.Segment.FixedSegment v' n') (Linear.Affine.Point v n) (Linear.Affine.Point v' n')
instance Control.Lens.Internal.Iso.Reversing (Diagrams.Segment.FixedSegment v n)
instance (Linear.Vector.Additive v, GHC.Num.Num n) => Diagrams.Core.Transform.Transformable (Diagrams.Segment.FixedSegment v n)
instance (Linear.Vector.Additive v, GHC.Num.Num n) => Diagrams.Core.HasOrigin.HasOrigin (Diagrams.Segment.FixedSegment v n)
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n) => Diagrams.Core.Envelope.Enveloped (Diagrams.Segment.FixedSegment v n)
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n) => Diagrams.Parametric.HasArcLength (Diagrams.Segment.FixedSegment v n)
instance (Linear.Vector.Additive v, GHC.Num.Num n) => Diagrams.Parametric.Parametric (Diagrams.Segment.FixedSegment v n)
instance GHC.Num.Num n => Diagrams.Parametric.DomainBounds (Diagrams.Segment.FixedSegment v n)
instance (Linear.Vector.Additive v, GHC.Num.Num n) => Diagrams.Parametric.EndValues (Diagrams.Segment.FixedSegment v n)
instance (Linear.Vector.Additive v, GHC.Real.Fractional n) => Diagrams.Parametric.Sectionable (Diagrams.Segment.FixedSegment v n)
instance Control.Lens.Wrapped.Wrapped Diagrams.Segment.SegCount
instance Control.Lens.Wrapped.Rewrapped Diagrams.Segment.SegCount Diagrams.Segment.SegCount
instance Control.Lens.Wrapped.Wrapped (Diagrams.Segment.ArcLength n)
instance Control.Lens.Wrapped.Rewrapped (Diagrams.Segment.ArcLength n) (Diagrams.Segment.ArcLength n')
instance Control.Lens.Wrapped.Wrapped (Diagrams.Segment.TotalOffset v n)
instance Control.Lens.Wrapped.Rewrapped (Diagrams.Segment.TotalOffset v n) (Diagrams.Segment.TotalOffset v' n')
instance (GHC.Num.Num n, Linear.Vector.Additive v) => Data.Semigroup.Semigroup (Diagrams.Segment.TotalOffset v n)
instance (GHC.Num.Num n, Linear.Vector.Additive v) => GHC.Base.Monoid (Diagrams.Segment.TotalOffset v n)

-- | Computing tangent and normal vectors for segments and trails.
module Diagrams.Tangent

-- | Compute the tangent vector to a segment or trail at a particular
--   parameter.
--   
--   Examples of more specific types this function can have include
--   
--   
--   
- 
Segment Closed V2 -> Double -> V2 Double

--   
- 
Trail' Line V2 -> Double -> V2 Double

--   
- 
Located (Trail V2) -> Double -> V2 Double

--   
--   
--   See the instances listed for the Tangent newtype for more.
tangentAtParam :: Parametric (Tangent t) => t -> N t -> Vn t

-- | Compute the tangent vector at the start of a segment or trail.
tangentAtStart :: EndValues (Tangent t) => t -> Vn t

-- | Compute the tangent vector at the end of a segment or trail.
tangentAtEnd :: EndValues (Tangent t) => t -> Vn t

-- | Compute the (unit) normal vector to a segment or trail at a particular
--   parameter.
--   
--   Examples of more specific types this function can have include
--   
--   
--   
- 
Segment Closed V2 Double -> Double -> V2
--   Double

--   
- 
Trail' Line V2 Double -> Double -> V2 Double

--   
- 
Located (Trail V2 Double) -> Double -> V2
--   Double

--   
--   
--   See the instances listed for the Tangent newtype for more.
normalAtParam :: (InSpace V2 n t, Parametric (Tangent t), Floating n) => t -> n -> V2 n

-- | Compute the normal vector at the start of a segment or trail.
normalAtStart :: (InSpace V2 n t, EndValues (Tangent t), Floating n) => t -> V2 n

-- | Compute the normal vector at the end of a segment or trail.
normalAtEnd :: (InSpace V2 n t, EndValues (Tangent t), Floating n) => t -> V2 n

-- | A newtype wrapper used to give different instances of
--   Parametric and EndValues that compute tangent vectors.
newtype Tangent t
Tangent :: t -> Tangent t
instance Diagrams.Parametric.DomainBounds t => Diagrams.Parametric.DomainBounds (Diagrams.Tangent.Tangent t)
instance Diagrams.Parametric.Parametric (Diagrams.Tangent.Tangent t) => Diagrams.Parametric.Parametric (Diagrams.Tangent.Tangent (Diagrams.Located.Located t))
instance (Diagrams.Parametric.DomainBounds t, Diagrams.Parametric.EndValues (Diagrams.Tangent.Tangent t)) => Diagrams.Parametric.EndValues (Diagrams.Tangent.Tangent (Diagrams.Located.Located t))
instance (Linear.Vector.Additive v, GHC.Num.Num n) => Diagrams.Parametric.Parametric (Diagrams.Tangent.Tangent (Diagrams.Segment.Segment Diagrams.Segment.Closed v n))
instance (Linear.Vector.Additive v, GHC.Num.Num n) => Diagrams.Parametric.EndValues (Diagrams.Tangent.Tangent (Diagrams.Segment.Segment Diagrams.Segment.Closed v n))
instance (Linear.Vector.Additive v, GHC.Num.Num n) => Diagrams.Parametric.Parametric (Diagrams.Tangent.Tangent (Diagrams.Segment.FixedSegment v n))
instance (Linear.Vector.Additive v, GHC.Num.Num n) => Diagrams.Parametric.EndValues (Diagrams.Tangent.Tangent (Diagrams.Segment.FixedSegment v n))

-- | This module defines trails, translationally invariant paths
--   through space. Trails form a central part of the diagrams-lib API, so
--   the documentation for this module merits careful study.
--   
--   Related modules include:
--   
--   
--   
- The TrailLike class (Diagrams.TrailLike) exposes a
--   generic API for building a wide range of things out of trails.
--   
- Paths (Diagrams.Path) are collections of
--   Located (Diagrams.Located) trails.
--   
- Trails are composed of Segments (see
--   Diagrams.Segment), though most users should not need to work
--   with segments directly.
--   
module Diagrams.Trail

-- | Intuitively, a trail is a single, continuous path through space.
--   However, a trail has no fixed starting point; it merely specifies
--   how to move through space, not where. For example, "take
--   three steps forward, then turn right twenty degrees and take two more
--   steps" is an intuitive analog of a trail; these instructions specify a
--   path through space from any given starting location. To be precise,
--   trails are translation-invariant; applying a translation to a
--   trail has no effect.
--   
--   A Located Trail, on the other hand, is a trail paired
--   with some concrete starting location ("start at the big tree on the
--   corner, then take three steps forward, ..."). See the
--   Diagrams.Located module for help working with Located
--   values.
--   
--   Formally, the semantics of a trail is a continuous (though not
--   necessarily differentiable) function from the real interval [0,1] to
--   vectors in some vector space. (In contrast, a Located trail is
--   a continuous function from [0,1] to points in some
--   affine space.)
--   
--   There are two types of trails:
--   
--   
--   
- A "line" (think of the "train", "subway", or "bus" variety, rather
--   than the "straight" variety...) is a trail with two distinct
--   endpoints. Actually, a line can have the same start and end points,
--   but it is still drawn as if it had distinct endpoints: the two
--   endpoints will have the appropriate end caps, and the trail will not
--   be filled. Lines have a Monoid instance where
--   mappend corresponds to concatenation, i.e. chaining
--   one line after the other.
--   
- A "loop" is required to end in the same place it starts (that is,
--   t(0) = t(1)). Loops are filled and are drawn as one continuous loop,
--   with the appropriate join at the start/endpoint rather than end caps.
--   Loops do not have a Monoid instance.
--   
--   
--   To convert between lines and loops, see glueLine,
--   closeLine, and cutLoop.
--   
--   To construct trails, see emptyTrail, trailFromSegments,
--   trailFromVertices, trailFromOffsets, and friends. You
--   can also get any type of trail from any function which returns a
--   TrailLike (e.g. functions in
--   Diagrams.TwoD.Shapes, and many others; see
--   Diagrams.TrailLike).
--   
--   To extract information from trails, see withLine,
--   isLoop, trailSegments, trailOffsets,
--   trailVertices, and friends.
data Trail' l v n
Line :: SegTree v n -> Trail' Line v n
Loop :: SegTree v n -> Segment Open v n -> Trail' Loop v n

-- | Make a line into a loop by "gluing" the endpoint to the starting
--   point. In particular, the offset of the final segment is modified so
--   that it ends at the starting point of the entire trail. Typically, you
--   would first construct a line which you know happens to end where it
--   starts, and then call glueLine to turn it into a loop.
--   
--   
--   
--   glueLineEx = pad 1.1 . hsep 1
--     $ [almostClosed # strokeLine, almostClosed # glueLine # strokeLoop]
--   
--   almostClosed :: Trail' Line V2 Double
--   almostClosed = fromOffsets $ map r2 [(2, -1), (-3, -0.5), (-2, 1), (1, 0.5)]
--   
--   
--   glueLine is left inverse to cutLoop, that is,
--   
--   
--   glueLine . cutLoop === id
--   
--   
glueLine :: (Metric v, OrderedField n) => Trail' Line v n -> Trail' Loop v n

-- | Make a line into a loop by adding a new linear segment from the line's
--   end to its start.
--   
--   closeLine does not have any particularly nice theoretical
--   properties, but can be useful e.g. when you want to make a
--   closed polygon out of a list of points where the initial point is not
--   repeated at the end. To use glueLine, one would first have to
--   duplicate the initial vertex, like
--   
--   
--   glueLine . lineFromVertices $ ps ++ [head ps]
--   
--   
--   Using closeLine, however, one can simply
--   
--   
--   closeLine . lineFromVertices $ ps
--   
--   
--   
--   
--   closeLineEx = pad 1.1 . centerXY . hcat' (with & sep .~ 1)
--     $ [almostClosed # strokeLine, almostClosed # closeLine # strokeLoop]
--   
closeLine :: Trail' Line v n -> Trail' Loop v n

-- | Turn a loop into a line by "cutting" it at the common start/end point,
--   resulting in a line which just happens to start and end at the same
--   place.
--   
--   cutLoop is right inverse to glueLine, that is,
--   
--   
--   glueLine . cutLoop === id
--   
--   
cutLoop :: (Metric v, OrderedField n) => Trail' Loop v n -> Trail' Line v n

-- | Trail is a wrapper around Trail', hiding whether the
--   underlying Trail' is a line or loop (though which it is can
--   be recovered; see e.g. withTrail).
data Trail v n
Trail :: Trail' l v n -> Trail v n

-- | Prism onto a Line.
_Line :: Prism' (Trail v n) (Trail' Line v n)

-- | Prism onto a Loop.
_Loop :: Prism' (Trail v n) (Trail' Loop v n)

-- | Convert a Trail' into a Trail, hiding the type-level
--   distinction between lines and loops.
wrapTrail :: Trail' l v n -> Trail v n

-- | Convert a line into a Trail. This is the same as
--   wrapTrail, but with a more specific type, which can
--   occasionally be convenient for fixing the type of a polymorphic
--   expression.
wrapLine :: Trail' Line v n -> Trail v n

-- | Convert a loop into a Trail. This is the same as
--   wrapTrail, but with a more specific type, which can
--   occasionally be convenient for fixing the type of a polymorphic
--   expression.
wrapLoop :: Trail' Loop v n -> Trail v n

-- | Modify a Trail, specifying two separate transformations for
--   the cases of a line or a loop.
onTrail :: (Trail' Line v n -> Trail' l1 v n) -> (Trail' Loop v n -> Trail' l2 v n) -> Trail v n -> Trail v n

-- | Modify a Trail by specifying a transformation on lines. If
--   the trail is a line, the transformation will be applied directly. If
--   it is a loop, it will first be cut using cutLoop, the
--   transformation applied, and then glued back into a loop with
--   glueLine. That is,
--   
--   
--   onLine f === onTrail f (glueLine . f . cutLoop)
--   
--   
--   
--   Note that there is no corresponding onLoop function, because
--   there is no nice way in general to convert a line into a loop, operate
--   on it, and then convert back.
onLine :: (Metric v, OrderedField n) => (Trail' Line v n -> Trail' Line v n) -> Trail v n -> Trail v n

-- | glueTrail is a variant of glueLine which works on
--   Trails. It performs glueLine on lines and is the
--   identity on loops.
glueTrail :: (Metric v, OrderedField n) => Trail v n -> Trail v n

-- | closeTrail is a variant of closeLine for Trail,
--   which performs closeLine on lines and is the identity on loops.
closeTrail :: Trail v n -> Trail v n

-- | cutTrail is a variant of cutLoop for Trail; it
--   is the is the identity on lines and performs cutLoop on loops.
cutTrail :: (Metric v, OrderedField n) => Trail v n -> Trail v n

-- | The empty line, which is the identity for concatenation of lines.
emptyLine :: (Metric v, OrderedField n) => Trail' Line v n

-- | A wrapped variant of emptyLine.
emptyTrail :: (Metric v, OrderedField n) => Trail v n

-- | Construct a line containing only linear segments from a list of
--   vertices. Note that only the relative offsets between the vertices
--   matters; the information about their absolute position will be
--   discarded. That is, for all vectors v,
--   
--   
--   lineFromVertices === lineFromVertices . translate v
--   
--   
--   If you want to retain the position information, you should instead use
--   the more general fromVertices function to construct, say, a
--   Located (Trail' Line v) or a
--   Located (Trail v).
--   
--   
--   
--   import Diagrams.Coordinates
--   lineFromVerticesEx = pad 1.1 . centerXY . strokeLine
--     $ lineFromVertices [origin, 0 ^& 1, 1 ^& 2, 5 ^& 1]
--   
lineFromVertices :: (Metric v, OrderedField n) => [Point v n] -> Trail' Line v n

-- | trailFromVertices === wrapTrail .
--   lineFromVertices, for conveniently constructing a
--   Trail instead of a Trail' Line.
trailFromVertices :: (Metric v, OrderedField n) => [Point v n] -> Trail v n

-- | Construct a line containing only linear segments from a list of
--   vectors, where each vector represents the offset from one vertex to
--   the next. See also fromOffsets.
--   
--   
--   
--   import Diagrams.Coordinates
--   lineFromOffsetsEx = strokeLine $ lineFromOffsets [ 2 ^& 1, 2 ^& (-1), 2 ^& 0.5 ]
--   
lineFromOffsets :: (Metric v, OrderedField n) => [v n] -> Trail' Line v n

-- | trailFromOffsets === wrapTrail .
--   lineFromOffsets, for conveniently constructing a
--   Trail instead of a Trail' Line.
trailFromOffsets :: (Metric v, OrderedField n) => [v n] -> Trail v n

-- | Construct a line from a list of closed segments.
lineFromSegments :: (Metric v, OrderedField n) => [Segment Closed v n] -> Trail' Line v n

-- | trailFromSegments === wrapTrail .
--   lineFromSegments, for conveniently constructing a
--   Trail instead of a Trail'.
trailFromSegments :: (Metric v, OrderedField n) => [Segment Closed v n] -> Trail v n

-- | Construct a loop from a list of closed segments and an open segment
--   that completes the loop.
loopFromSegments :: (Metric v, OrderedField n) => [Segment Closed v n] -> Segment Open v n -> Trail' Loop v n

-- | A generic eliminator for Trail', taking functions specifying
--   what to do in the case of a line or a loop.
withTrail' :: (Trail' Line v n -> r) -> (Trail' Loop v n -> r) -> Trail' l v n -> r

-- | A generic eliminator for Trail, taking functions specifying
--   what to do in the case of a line or a loop.
withTrail :: (Trail' Line v n -> r) -> (Trail' Loop v n -> r) -> Trail v n -> r

-- | An eliminator for Trail based on eliminating lines: if the
--   trail is a line, the given function is applied; if it is a loop, it is
--   first converted to a line with cutLoop. That is,
--   
--   
--   withLine f === withTrail f (f . cutLoop)
--   
withLine :: (Metric v, OrderedField n) => (Trail' Line v n -> r) -> Trail v n -> r

-- | Test whether a line is empty.
isLineEmpty :: (Metric v, OrderedField n) => Trail' Line v n -> Bool

-- | Test whether a trail is empty. Note that loops are never empty.
isTrailEmpty :: (Metric v, OrderedField n) => Trail v n -> Bool

-- | Determine whether a trail is a line.
isLine :: Trail v n -> Bool

-- | Determine whether a trail is a loop.
isLoop :: Trail v n -> Bool

-- | Extract the segments of a trail. If the trail is a loop it will first
--   have cutLoop applied.
trailSegments :: (Metric v, OrderedField n) => Trail v n -> [Segment Closed v n]

-- | Extract the segments comprising a line.
lineSegments :: Trail' Line v n -> [Segment Closed v n]

-- | Extract the segments comprising a loop: a list of closed segments, and
--   one final open segment.
loopSegments :: Trail' Loop v n -> ([Segment Closed v n], Segment Open v n)

-- | Modify a line by applying a function to its list of segments.
onLineSegments :: (Metric v, OrderedField n) => ([Segment Closed v n] -> [Segment Closed v n]) -> Trail' Line v n -> Trail' Line v n

-- | Extract the offsets of the segments of a trail.
trailOffsets :: (Metric v, OrderedField n) => Trail v n -> [v n]

-- | Compute the offset from the start of a trail to the end. Satisfies
--   
--   
--   trailOffset === sumV . trailOffsets
--   
--   
--   
--   but is more efficient.
--   
--   
--   
--   trailOffsetEx = (strokeLine almostClosed <> showOffset) # centerXY # pad 1.1
--     where showOffset = fromOffsets [trailOffset (wrapLine almostClosed)]
--                      # strokeP # lc red
--   
trailOffset :: (Metric v, OrderedField n) => Trail v n -> v n

-- | Extract the offsets of the segments of a line.
lineOffsets :: (Metric v, OrderedField n) => Trail' Line v n -> [v n]

-- | Compute the offset from the start of a line to the end. (Note, there
--   is no corresponding loopOffset function because by definition
--   it would be constantly zero.)
lineOffset :: (Metric v, OrderedField n) => Trail' Line v n -> v n

-- | Extract the offsets of the segments of a loop.
loopOffsets :: (Metric v, OrderedField n) => Trail' Loop v n -> [v n]

-- | Extract the points of a concretely located trail, i.e. the
--   points where one segment ends and the next begins. Note that for
--   loops, the starting point will not be repeated at the end. If
--   you want this behavior, you can use cutTrail to make the loop
--   into a line first, which happens to repeat the same point at the start
--   and end, e.g. with trailPoints . mapLoc cutTrail.
--   
--   Note that it does not make sense to ask for the points of a
--   Trail by itself; if you want the points of a trail with the
--   first point at, say, the origin, you can use trailPoints . (`at`
--   origin).
--   
--   This function allows you "observe" the fact that trails are
--   implemented as lists of segments, which may be problematic if we want
--   to think of trails as parametric vector functions. This also means
--   that the behavior of this function may not be stable under future
--   changes to the implementation of trails. For an unproblematic version
--   which only yields vertices at which there is a sharp corner, excluding
--   points where the trail is differentiable, see trailVertices.
--   
--   This function is not re-exported from Diagrams.Prelude; to use
--   it, import Diagrams.Trail.
trailPoints :: (Metric v, OrderedField n) => Located (Trail v n) -> [Point v n]

-- | Extract the segment join points of a concretely located line. See
--   trailPoints for more information.
--   
--   This function allows you "observe" the fact that lines are implemented
--   as lists of segments, which may be problematic if we want to think of
--   lines as parametric vector functions. This also means that the
--   behavior of this function may not be stable under future changes to
--   the implementation of trails. For an unproblematic version which only
--   yields vertices at which there is a sharp corner, excluding points
--   where the trail is differentiable, see lineVertices.
--   
--   This function is not re-exported from Diagrams.Prelude; to use
--   it, import Diagrams.Trail.
linePoints :: (Metric v, OrderedField n) => Located (Trail' Line v n) -> [Point v n]

-- | Extract the segment join points of a concretely located loop. Note
--   that the initial vertex is not repeated at the end. See
--   trailPoints for more information.
--   
--   This function allows you "observe" the fact that lines are implemented
--   as lists of segments, which may be problematic if we want to think of
--   lines as parametric vector functions. This also means that the
--   behavior of this function may not be stable under future changes to
--   the implementation of trails. For an unproblematic version which only
--   yields vertices at which there is a sharp corner, excluding points
--   where the trail is differentiable, see lineVertices.
--   
--   This function is not re-exported from Diagrams.Prelude; to use
--   it, import Diagrams.Trail.
loopPoints :: (Metric v, OrderedField n) => Located (Trail' Loop v n) -> [Point v n]

-- | Extract the vertices of a concretely located trail. Here a
--   vertex is defined as a non-differentiable point on the trail,
--   i.e. a sharp corner. (Vertices are thus a subset of the places
--   where segments join; if you want all joins between segments, see
--   trailPoints.) The tolerance determines how close the tangents
--   of two segments must be at their endpoints to consider the transition
--   point to be differentiable.
--   
--   Note that for loops, the starting vertex will not be repeated
--   at the end. If you want this behavior, you can use cutTrail to
--   make the loop into a line first, which happens to repeat the same
--   vertex at the start and end, e.g. with trailVertices .
--   mapLoc cutTrail.
--   
--   It does not make sense to ask for the vertices of a Trail by
--   itself; if you want the vertices of a trail with the first vertex at,
--   say, the origin, you can use trailVertices . (`at` origin).
trailVertices' :: (Metric v, OrderedField n) => n -> Located (Trail v n) -> [Point v n]

-- | Extract the vertices of a concretely located line. See
--   trailVertices for more information.
lineVertices' :: (Metric v, OrderedField n) => n -> Located (Trail' Line v n) -> [Point v n]

-- | Extract the vertices of a concretely located loop. Note that the
--   initial vertex is not repeated at the end. See trailVertices
--   for more information.
loopVertices' :: (Metric v, OrderedField n) => n -> Located (Trail' Loop v n) -> [Point v n]

-- | Like trailVertices', with a default tolerance.
trailVertices :: (Metric v, OrderedField n) => Located (Trail v n) -> [Point v n]

-- | Like lineVertices', with a default tolerance.
lineVertices :: (Metric v, OrderedField n) => Located (Trail' Line v n) -> [Point v n]

-- | Same as loopVertices', with a default tolerance.
loopVertices :: (Metric v, OrderedField n) => Located (Trail' Loop v n) -> [Point v n]

-- | Convert a concretely located trail into a list of located segments.
trailLocSegments :: (Metric v, OrderedField n) => Located (Trail v n) -> [Located (Segment Closed v n)]

-- | Convert a concretely located trail into a list of fixed segments.
fixTrail :: (Metric v, OrderedField n) => Located (Trail v n) -> [FixedSegment v n]

-- | Reverse a trail. Semantically, if a trail given by a function t from
--   [0,1] to vectors, then the reverse of t is given by t'(s) = t(1-s).
--   reverseTrail is an involution, that is,
--   
--   
--   reverseTrail . reverseTrail === id
--   
--   
reverseTrail :: (Metric v, OrderedField n) => Trail v n -> Trail v n

-- | Reverse a concretely located trail. The endpoint of the original trail
--   becomes the starting point of the reversed trail, so the original and
--   reversed trails comprise exactly the same set of points.
--   reverseLocTrail is an involution, i.e.
--   
--   
--   reverseLocTrail . reverseLocTrail === id
--   
--   
reverseLocTrail :: (Metric v, OrderedField n) => Located (Trail v n) -> Located (Trail v n)

-- | Reverse a line. See reverseTrail.
reverseLine :: (Metric v, OrderedField n) => Trail' Line v n -> Trail' Line v n

-- | Reverse a concretely located line. See reverseLocTrail.
reverseLocLine :: (Metric v, OrderedField n) => Located (Trail' Line v n) -> Located (Trail' Line v n)

-- | Reverse a loop. See reverseTrail.
reverseLoop :: (Metric v, OrderedField n) => Trail' Loop v n -> Trail' Loop v n

-- | Reverse a concretely located loop. See reverseLocTrail. Note
--   that this is guaranteed to preserve the location.
reverseLocLoop :: (Metric v, OrderedField n) => Located (Trail' Loop v n) -> Located (Trail' Loop v n)

-- | Type tag for trails with distinct endpoints.
data Line

-- | Type tag for "loopy" trails which return to their starting point.
data Loop

-- | A SegTree represents a sequence of closed segments, stored in
--   a fingertree so we can easily recover various monoidal measures of the
--   segments (number of segments, arc length, envelope...) and also easily
--   slice and dice them according to the measures (e.g., split off
--   the smallest number of segments from the beginning which have a
--   combined arc length of at least 5).
newtype SegTree v n
SegTree :: (FingerTree (SegMeasure v n) (Segment Closed v n)) -> SegTree v n

-- | Given a default result (to be used in the case of an empty trail), and
--   a function to map a single measure to a result, extract the given
--   measure for a trail and use it to compute a result. Put another way,
--   lift a function on a single measure (along with a default value) to a
--   function on an entire trail.
trailMeasure :: (Metric v, OrderedField n, SegMeasure v n :>: m, Measured (SegMeasure v n) t) => a -> (m -> a) -> t -> a

-- | Compute the number of segments of anything measured by
--   SegMeasure (e.g. SegMeasure itself,
--   Segment, SegTree, Trails...)
numSegs :: (OrderedField n, Num c, Metric v, Measured (SegMeasure v n) a) => a -> c

-- | Compute the total offset of anything measured by SegMeasure.
offset :: (OrderedField n, Metric v, Measured (SegMeasure v n) t) => t -> v n

-- | A newtype wrapper around trails which exists solely for its
--   Parametric, DomainBounds and EndValues instances.
--   The idea is that if tr is a trail, you can write, e.g.
--   
--   
--   getSegment tr atParam 0.6
--   
--   
--   
--   or
--   
--   
--   atStart (getSegment tr)
--   
--   
--   
--   to get the segment at parameter 0.6 or the first segment in the trail,
--   respectively.
--   
--   The codomain for GetSegment, i.e. the result you get
--   from calling atParam, atStart, or atEnd, is
--   Maybe (v, Segment Closed v, AnIso' n n). Nothing
--   results if the trail is empty; otherwise, you get:
--   
--   
--   
- the offset from the start of the trail to the beginning of the
--   segment,
--   
- the segment itself, and
--   
- a reparameterization isomorphism: in the forward direction, it
--   translates from parameters on the whole trail to a parameters on the
--   segment. Note that for technical reasons you have to call
--   cloneIso on the AnIso' value to get a real isomorphism
--   you can use.
--   
newtype GetSegment t
GetSegment :: t -> GetSegment t

-- | Create a GetSegment wrapper around a trail, after which you can
--   call atParam, atStart, or atEnd to extract a
--   segment.
getSegment :: t -> GetSegment t
instance (GHC.Float.Floating n, GHC.Classes.Ord n, Linear.Metric.Metric v) => Data.FingerTree.Measured (Diagrams.Segment.SegMeasure v n) (Diagrams.Trail.SegTree v n)
instance (GHC.Float.Floating n, GHC.Classes.Ord n, Linear.Metric.Metric v) => Diagrams.Core.Transform.Transformable (Diagrams.Trail.SegTree v n)
instance (GHC.Float.Floating n, GHC.Classes.Ord n, Linear.Metric.Metric v) => GHC.Base.Monoid (Diagrams.Trail.SegTree v n)
instance GHC.Show.Show (v n) => GHC.Show.Show (Diagrams.Trail.SegTree v n)
instance GHC.Classes.Ord (v n) => GHC.Classes.Ord (Diagrams.Trail.SegTree v n)
instance GHC.Classes.Eq (v n) => GHC.Classes.Eq (Diagrams.Trail.SegTree v n)
instance GHC.Classes.Eq (v n) => GHC.Classes.Eq (Diagrams.Trail.Trail' l v n)
instance GHC.Classes.Ord (v n) => GHC.Classes.Ord (Diagrams.Trail.Trail' l v n)
instance GHC.Show.Show (v n) => GHC.Show.Show (Diagrams.Trail.Trail v n)
instance (Linear.Metric.Metric (Diagrams.Core.V.V a), Diagrams.Core.Envelope.OrderedField (Diagrams.Core.V.N a), Data.FingerTree.Measured m a, Diagrams.Core.Transform.Transformable a) => Diagrams.Core.Transform.Transformable (Data.FingerTree.FingerTree m a)
instance (Data.FingerTree.Measured m a, Data.FingerTree.Measured n b) => Control.Lens.Cons.Cons (Data.FingerTree.FingerTree m a) (Data.FingerTree.FingerTree n b) a b
instance (Data.FingerTree.Measured m a, Data.FingerTree.Measured n b) => Control.Lens.Cons.Snoc (Data.FingerTree.FingerTree m a) (Data.FingerTree.FingerTree n b) a b
instance Control.Lens.Wrapped.Wrapped (Diagrams.Trail.SegTree v n)
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n, Linear.Metric.Metric u, Diagrams.Core.Envelope.OrderedField n') => Control.Lens.Cons.Cons (Diagrams.Trail.SegTree v n) (Diagrams.Trail.SegTree u n') (Diagrams.Segment.Segment Diagrams.Segment.Closed v n) (Diagrams.Segment.Segment Diagrams.Segment.Closed u n')
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n, Linear.Metric.Metric u, Diagrams.Core.Envelope.OrderedField n') => Control.Lens.Cons.Snoc (Diagrams.Trail.SegTree v n) (Diagrams.Trail.SegTree u n') (Diagrams.Segment.Segment Diagrams.Segment.Closed v n) (Diagrams.Segment.Segment Diagrams.Segment.Closed u n')
instance Control.Lens.Wrapped.Rewrapped (Diagrams.Trail.SegTree v n) (Diagrams.Trail.SegTree v' n')
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n, GHC.Real.Real n) => Diagrams.Parametric.Parametric (Diagrams.Trail.SegTree v n)
instance GHC.Num.Num n => Diagrams.Parametric.DomainBounds (Diagrams.Trail.SegTree v n)
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n, GHC.Real.Real n) => Diagrams.Parametric.EndValues (Diagrams.Trail.SegTree v n)
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n, GHC.Real.Real n) => Diagrams.Parametric.Sectionable (Diagrams.Trail.SegTree v n)
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n, GHC.Real.Real n) => Diagrams.Parametric.HasArcLength (Diagrams.Trail.SegTree v n)
instance GHC.Show.Show (v n) => GHC.Show.Show (Diagrams.Trail.Trail' l v n)
instance (Diagrams.Core.Envelope.OrderedField n, Linear.Metric.Metric v) => Data.Semigroup.Semigroup (Diagrams.Trail.Trail' Diagrams.Trail.Line v n)
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n) => GHC.Base.Monoid (Diagrams.Trail.Trail' Diagrams.Trail.Line v n)
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n) => Control.Lens.Empty.AsEmpty (Diagrams.Trail.Trail' Diagrams.Trail.Line v n)
instance (Diagrams.Core.Transform.HasLinearMap v, Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n) => Diagrams.Core.Transform.Transformable (Diagrams.Trail.Trail' l v n)
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n) => Diagrams.Core.Envelope.Enveloped (Diagrams.Trail.Trail' l v n)
instance (Diagrams.Core.Transform.HasLinearMap v, Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n) => Diagrams.Core.Types.Renderable (Diagrams.Trail.Trail' o v n) Diagrams.Core.Types.NullBackend
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n, GHC.Real.Real n) => Diagrams.Parametric.Parametric (Diagrams.Trail.Trail' l v n)
instance (Diagrams.Parametric.Parametric (Diagrams.Trail.GetSegment (Diagrams.Trail.Trail' c v n)), Linear.Vector.Additive v, GHC.Num.Num n) => Diagrams.Parametric.Parametric (Diagrams.Tangent.Tangent (Diagrams.Trail.Trail' c v n))
instance (Diagrams.Parametric.Parametric (Diagrams.Trail.GetSegment (Diagrams.Trail.Trail' c v n)), Diagrams.Parametric.EndValues (Diagrams.Trail.GetSegment (Diagrams.Trail.Trail' c v n)), Linear.Vector.Additive v, GHC.Num.Num n) => Diagrams.Parametric.EndValues (Diagrams.Tangent.Tangent (Diagrams.Trail.Trail' c v n))
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n, GHC.Real.Real n) => Diagrams.Parametric.Parametric (Diagrams.Tangent.Tangent (Diagrams.Trail.Trail v n))
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n, GHC.Real.Real n) => Diagrams.Parametric.EndValues (Diagrams.Tangent.Tangent (Diagrams.Trail.Trail v n))
instance GHC.Num.Num n => Diagrams.Parametric.DomainBounds (Diagrams.Trail.Trail' l v n)
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n, GHC.Real.Real n) => Diagrams.Parametric.EndValues (Diagrams.Trail.Trail' l v n)
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n, GHC.Real.Real n) => Diagrams.Parametric.Sectionable (Diagrams.Trail.Trail' Diagrams.Trail.Line v n)
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n, GHC.Real.Real n) => Diagrams.Parametric.HasArcLength (Diagrams.Trail.Trail' l v n)
instance Control.Lens.Wrapped.Rewrapped (Diagrams.Trail.Trail' Diagrams.Trail.Line v n) (Diagrams.Trail.Trail' Diagrams.Trail.Line v' n')
instance Control.Lens.Wrapped.Wrapped (Diagrams.Trail.Trail' Diagrams.Trail.Line v n)
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n, Linear.Metric.Metric u, Diagrams.Core.Envelope.OrderedField n') => Control.Lens.Cons.Cons (Diagrams.Trail.Trail' Diagrams.Trail.Line v n) (Diagrams.Trail.Trail' Diagrams.Trail.Line u n') (Diagrams.Segment.Segment Diagrams.Segment.Closed v n) (Diagrams.Segment.Segment Diagrams.Segment.Closed u n')
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n, Linear.Metric.Metric u, Diagrams.Core.Envelope.OrderedField n') => Control.Lens.Cons.Snoc (Diagrams.Trail.Trail' Diagrams.Trail.Line v n) (Diagrams.Trail.Trail' Diagrams.Trail.Line u n') (Diagrams.Segment.Segment Diagrams.Segment.Closed v n) (Diagrams.Segment.Segment Diagrams.Segment.Closed u n')
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n) => Diagrams.Parametric.Parametric (Diagrams.Trail.GetSegment (Diagrams.Trail.Trail' Diagrams.Trail.Line v n))
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n, GHC.Real.Real n) => Diagrams.Parametric.Parametric (Diagrams.Trail.GetSegment (Diagrams.Trail.Trail' Diagrams.Trail.Loop v n))
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n, GHC.Real.Real n) => Diagrams.Parametric.Parametric (Diagrams.Trail.GetSegment (Diagrams.Trail.Trail v n))
instance Diagrams.Parametric.DomainBounds t => Diagrams.Parametric.DomainBounds (Diagrams.Trail.GetSegment t)
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n, GHC.Real.Real n) => Diagrams.Parametric.EndValues (Diagrams.Trail.GetSegment (Diagrams.Trail.Trail' Diagrams.Trail.Line v n))
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n, GHC.Real.Real n) => Diagrams.Parametric.EndValues (Diagrams.Trail.GetSegment (Diagrams.Trail.Trail' Diagrams.Trail.Loop v n))
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n, GHC.Real.Real n) => Diagrams.Parametric.EndValues (Diagrams.Trail.GetSegment (Diagrams.Trail.Trail v n))
instance GHC.Classes.Eq (v n) => GHC.Classes.Eq (Diagrams.Trail.Trail v n)
instance GHC.Classes.Ord (v n) => GHC.Classes.Ord (Diagrams.Trail.Trail v n)
instance (Diagrams.Core.Envelope.OrderedField n, Linear.Metric.Metric v) => Data.Semigroup.Semigroup (Diagrams.Trail.Trail v n)
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n) => GHC.Base.Monoid (Diagrams.Trail.Trail v n)
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n) => Control.Lens.Empty.AsEmpty (Diagrams.Trail.Trail v n)
instance (Diagrams.Core.Transform.HasLinearMap v, Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n) => Diagrams.Core.Transform.Transformable (Diagrams.Trail.Trail v n)
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n) => Diagrams.Core.Envelope.Enveloped (Diagrams.Trail.Trail v n)
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n, GHC.Real.Real n) => Diagrams.Parametric.Parametric (Diagrams.Trail.Trail v n)
instance GHC.Num.Num n => Diagrams.Parametric.DomainBounds (Diagrams.Trail.Trail v n)
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n, GHC.Real.Real n) => Diagrams.Parametric.EndValues (Diagrams.Trail.Trail v n)
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n, GHC.Real.Real n) => Diagrams.Parametric.Sectionable (Diagrams.Trail.Trail v n)
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n, GHC.Real.Real n) => Diagrams.Parametric.HasArcLength (Diagrams.Trail.Trail v n)
instance Control.Lens.Wrapped.Rewrapped (Diagrams.Trail.Trail v n) (Diagrams.Trail.Trail v' n')
instance Control.Lens.Wrapped.Wrapped (Diagrams.Trail.Trail v n)
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n) => Control.Lens.Internal.Iso.Reversing (Diagrams.Trail.Trail' l v n)
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n) => Control.Lens.Internal.Iso.Reversing (Diagrams.Trail.Trail v n)
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n) => Control.Lens.Internal.Iso.Reversing (Diagrams.Located.Located (Diagrams.Trail.Trail' l v n))
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n) => Control.Lens.Internal.Iso.Reversing (Diagrams.Located.Located (Diagrams.Trail.Trail v n))

-- | Compute curvature for segments in two dimensions.
module Diagrams.TwoD.Curvature

-- | Curvature measures how curved the segment is at a point. One intuition
--   for the concept is how much you would turn the wheel when driving a
--   car along the curve. When the wheel is held straight there is zero
--   curvature. When turning a corner to the left we will have positive
--   curvature. When turning to the right we will have negative curvature.
--   
--   Another way to measure this idea is to find the largest circle that we
--   can push up against the curve and have it touch (locally) at exactly
--   the point and not cross the curve. This is a tangent circle. The
--   radius of that circle is the "Radius of Curvature" and it is the
--   reciprocal of curvature. Note that if the circle is on the "left" of
--   the curve, we have a positive radius, and if it is to the right we
--   have a negative radius. Straight segments have an infinite radius
--   which leads us to our representation. We result in a pair of numerator
--   and denominator so we can include infinity and zero for both the
--   radius and the curvature.
--   
--   Lets consider the following curve:
--   
--   
--   The curve starts with positive curvature,
--   
--   
--   approaches zero curvature
--   
--   
--   then has negative curvature
--   
--   
--   
--   {-# LANGUAGE GADTs #-}
--   
--   import Diagrams.TwoD.Curvature
--   import Data.Monoid.Inf
--   import Diagrams.Coordinates
--   
--   segmentA :: Segment Closed V2 Double
--   segmentA = Cubic (12 ^& 0) (8 ^& 10) (OffsetClosed (20 ^& 8))
--   
--   curveA = lw thick . strokeP . fromSegments $ [segmentA]
--   
--   diagramA = pad 1.1 . centerXY $ curveA
--   
--   diagramPos = diagramWithRadius 0.2
--   
--   diagramZero = diagramWithRadius 0.45
--   
--   diagramNeg = diagramWithRadius 0.8
--   
--   diagramWithRadius t = pad 1.1 . centerXY
--            $ curveA
--           <> showCurvature segmentA t
--            # withEnvelope (curveA :: D V2 Double)
--            # lc red
--   
--   showCurvature :: Segment Closed V2 Double -> Double -> Diagram SVG
--   showCurvature bez@(Cubic b c (OffsetClosed d)) t
--     | v == (0,0) = mempty
--     | otherwise  = go (radiusOfCurvature bez t)
--     where
--       v@(x,y) = unr2 $ firstDerivative b c d t
--       vp = (-y) ^& x
--   
--       firstDerivative b c d t = let tt = t*t in (3*(3*tt-4*t+1))*^b + (3*(2-3*t)*t)*^c + (3*tt)*^d
--   
--       go Infinity   = mempty
--       go (Finite r) = (circle (abs r) # translate vpr
--                    <> strokeP (origin ~~ (origin .+^ vpr)))
--                     # moveTo (origin .+^ atParam bez t)
--         where
--           vpr = signorm vp ^* r
--   
curvature :: RealFloat n => Segment Closed V2 n -> n -> PosInf n

-- | Reciprocal of curvature.
radiusOfCurvature :: RealFloat n => Segment Closed V2 n -> n -> PosInf n

-- | With squaredCurvature we can compute values in spaces that do
--   not support sqrt and it is just as useful for relative ordering
--   of curvatures or looking for zeros.
squaredCurvature :: RealFloat n => Segment Closed V2 n -> n -> PosInf n

-- | Reciprocal of squaredCurvature
squaredRadiusOfCurvature :: RealFloat n => Segment Closed V2 n -> n -> PosInf n

-- | The TrailLike class abstracts over anything which can be
--   constructed from a concretely located Trail, including lines,
--   loops, trails, paths, vertex lists, and diagrams.
module Diagrams.TrailLike

-- | A type class for trail-like things, i.e. things which can be
--   constructed from a concretely located Trail. Instances include
--   lines, loops, trails, paths, lists of vertices, two-dimensional
--   Diagrams, and Located variants of all the above.
--   
--   Usually, type variables with TrailLike constraints are used as
--   the output types of functions, like
--   
--   
--   foo :: (TrailLike t) => ... -> t
--   
--   
--   
--   Functions with such a type can be used to construct trails, paths,
--   diagrams, lists of points, and so on, depending on the context.
--   
--   To write a function with a signature like the above, you can of course
--   call trailLike directly; more typically, one would use one of
--   the provided functions like fromOffsets, fromVertices,
--   fromSegments, or ~~.
class (Metric (V t), OrderedField (N t)) => TrailLike t
trailLike :: TrailLike t => Located (Trail (V t) (N t)) -> t

-- | Construct a trail-like thing from a list of segments, with the origin
--   as the location.
--   
--   
--   
--   fromSegmentsEx = fromSegments
--     [ straight (r2 (1,1))
--     , bézier3  (r2 (1,1)) unitX unit_Y
--     , straight unit_X
--     ]
--     # centerXY # pad 1.1
--   
fromSegments :: TrailLike t => [Segment Closed (V t) (N t)] -> t

-- | Construct a trail-like thing from a located list of segments.
fromLocSegments :: TrailLike t => Located [Segment Closed (V t) (N t)] -> t

-- | Construct a trail-like thing of linear segments from a list of
--   offsets, with the origin as the location.
--   
--   
--   
--   fromOffsetsEx = fromOffsets
--     [ unitX
--     , unitX # rotateBy (1/6)
--     , unitX # rotateBy (-1/6)
--     , unitX
--     ]
--     # centerXY # pad 1.1
--   
fromOffsets :: TrailLike t => [Vn t] -> t

-- | Construct a trail-like thing of linear segments from a located list of
--   offsets.
fromLocOffsets :: (V t ~ v, N t ~ n, V (v n) ~ v, N (v n) ~ n, TrailLike t) => Located [v n] -> t

-- | Construct a trail-like thing connecting the given vertices with linear
--   segments, with the first vertex as the location. If no vertices are
--   given, the empty trail is used with the origin as the location.
--   
--   
--   
--   import Data.List (transpose)
--   
--   fromVerticesEx =
--     ( [ pentagon 1
--       , pentagon 1.3 # rotateBy (1/15)
--       , pentagon 1.5 # rotateBy (2/15)
--       ]
--       # transpose
--       # concat
--     )
--     # fromVertices
--     # closeTrail # strokeTrail
--     # centerXY # pad 1.1
--   
fromVertices :: TrailLike t => [Point (V t) (N t)] -> t

-- | Create a linear trail between two given points.
--   
--   
--   
--   twiddleEx
--     = mconcat ((~~) <$> hexagon 1 <*> hexagon 1)
--     # centerXY # pad 1.1
--   
(~~) :: (V t ~ v, N t ~ n, TrailLike t) => Point v n -> Point v n -> t

-- | Given a concretely located trail, "explode" it by turning each segment
--   into its own separate trail. Useful for (say) applying a different
--   style to each segment.
--   
--   
--   
--   explodeTrailEx
--     = pentagon 1
--     # explodeTrail  -- generate a list of diagrams
--     # zipWith lc [orange, green, yellow, red, blue]
--     # mconcat # centerXY # pad 1.1
--   
explodeTrail :: (V t ~ v, N t ~ n, Additive v, TrailLike t) => Located (Trail v n) -> [t]
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n) => Diagrams.TrailLike.TrailLike [Linear.Affine.Point v n]
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n) => Diagrams.TrailLike.TrailLike (Diagrams.Trail.Trail' Diagrams.Trail.Line v n)
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n) => Diagrams.TrailLike.TrailLike (Diagrams.Trail.Trail' Diagrams.Trail.Loop v n)
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n) => Diagrams.TrailLike.TrailLike (Diagrams.Trail.Trail v n)
instance Diagrams.TrailLike.TrailLike t => Diagrams.TrailLike.TrailLike (Diagrams.Core.Transform.TransInv t)
instance Diagrams.TrailLike.TrailLike t => Diagrams.TrailLike.TrailLike (Diagrams.Located.Located t)

-- | A few utilities and class instances for Active (from the
--   active package). In particular, this module defines
--   
--   
--   
- An instance of V for Active: V
--   (Active a) = V a
--   
- HasOrigin, Transformable, and HasStyle
--   instances for Active which all work pointwise.
--   
- A TrailLike instance for Active p where
--   p is also TrailLike, which simply lifts a pathlike
--   thing to a constant active value.
--   
- A Juxtaposable instance for Active a where
--   a is also Juxtaposable. An active value can be
--   juxtaposed against another by doing the juxtaposition pointwise over
--   time. The era of juxtapose v a1 a2 will be the same as the
--   era of a2, unless a2 is constant, in which case it
--   will be the era of a1. (Note that juxtapose v a1 a2
--   and liftA2 (juxtapose v) a1 a2 therefore have different
--   semantics: the second is an active value whose era is the
--   combination of the eras of a1 and a2).
--   
- An Alignable instance for Active a where
--   a is also Alignable; the active value is aligned
--   pointwise over time.
--   
module Diagrams.Animation.Active

-- | An active value can be juxtaposed against another by doing the
--   juxtaposition pointwise over time. The era of juxtapose v a1
--   a2 will be the same as the era of a2, unless a2
--   is constant, in which case it will be the era of a1. (Note
--   that juxtapose v a1 a2 and liftA2 (juxtapose v) a1
--   a2 therefore have different semantics: the second is an active
--   value whose era is the combination of the eras of a1
--   and a2).
instance Diagrams.Core.HasOrigin.HasOrigin a => Diagrams.Core.HasOrigin.HasOrigin (Data.Active.Active a)
instance Diagrams.Core.Transform.Transformable a => Diagrams.Core.Transform.Transformable (Data.Active.Active a)
instance Diagrams.Core.Style.HasStyle a => Diagrams.Core.Style.HasStyle (Data.Active.Active a)
instance Diagrams.TrailLike.TrailLike t => Diagrams.TrailLike.TrailLike (Data.Active.Active t)
instance Diagrams.Core.Juxtapose.Juxtaposable a => Diagrams.Core.Juxtapose.Juxtaposable (Data.Active.Active a)

-- | A cubic spline is a smooth, connected sequence of cubic curves
--   passing through a given sequence of points. This module provides the
--   cubicSpline method, which can be used to create closed or open
--   cubic splines from a list of points. For access to the internals of
--   the spline generation algorithm (including in particular a solver for
--   cyclic tridiagonal systems of linear equations), see
--   Diagrams.CubicSpline.Internal.
module Diagrams.CubicSpline

-- | Construct a spline path-like thing of cubic segments from a list of
--   vertices, with the first vertex as the starting point. The first
--   argument specifies whether the path should be closed.
--   
--   
--   
--   pts = map p2 [(0,0), (2,3), (5,-2), (-4,1), (0,3)]
--   spot = circle 0.2 # fc blue # lw none
--   mkPath closed = position (zip pts (repeat spot))
--                <> cubicSpline closed pts
--   cubicSplineEx = (mkPath False ||| strutX 2 ||| mkPath True)
--                 # centerXY # pad 1.1
--   
--   
--   For more information, see
--   http://mathworld.wolfram.com/CubicSpline.html.
cubicSpline :: (V t ~ v, N t ~ n, TrailLike t, Fractional (v n)) => Bool -> [Point v n] -> t

-- | Two-dimensional arcs, approximated by cubic bezier curves.
module Diagrams.TwoD.Arc

-- | Given a start direction d and a sweep angle s,
--   arc d s is the path of a radius one arc starting at
--   d and sweeping out the angle s counterclockwise (for
--   positive s). The resulting Trail is allowed to wrap around
--   and overlap itself.
arc :: (InSpace V2 n t, OrderedField n, TrailLike t) => Direction V2 n -> Angle n -> t

-- | Given a radus r, a start direction d and an angle
--   s, arc' r d s is the path of a radius
--   (abs r) arc starting at d and sweeping out the angle
--   s counterclockwise (for positive s). The origin of the arc is
--   its center.
--   
--   
--   
--   arc'Ex = mconcat [ arc' r xDir (1/4 @@ turn) | r <- [0.5,-1,1.5] ]
--          # centerXY # pad 1.1
--   
arc' :: (InSpace V2 n t, OrderedField n, TrailLike t) => n -> Direction V2 n -> Angle n -> t

-- | Given a start direction d and a sweep angle s,
--   arcT d s is the Trail of a radius one arc
--   starting at d and sweeping out the angle s
--   counterclockwise (for positive s). The resulting Trail is
--   allowed to wrap around and overlap itself.
arcT :: OrderedField n => Direction V2 n -> Angle n -> Trail V2 n

-- | Given a start direction s and end direction e,
--   arcCCW s e is the path of a radius one arc counterclockwise
--   between the two directions. The origin of the arc is its center.
arcCCW :: (InSpace V2 n t, RealFloat n, TrailLike t) => Direction V2 n -> Direction V2 n -> t

-- | Like arcAngleCCW but clockwise.
arcCW :: (InSpace V2 n t, RealFloat n, TrailLike t) => Direction V2 n -> Direction V2 n -> t

-- | bezierFromSweep s constructs a series of Cubic
--   segments that start in the positive y direction and sweep counter
--   clockwise through the angle s. If s is negative, it
--   will start in the negative y direction and sweep clockwise. When
--   s is less than 0.0001 the empty list results. If the sweep is
--   greater than fullTurn later segments will overlap earlier
--   segments.
bezierFromSweep :: OrderedField n => Angle n -> [Segment Closed V2 n]

-- | Create a circular wedge of the given radius, beginning at the given
--   direction and extending through the given angle.
--   
--   
--   
--   wedgeEx = hcat' (with & sep .~ 0.5)
--     [ wedge 1 xDir (1/4 @@ turn)
--     , wedge 1 (rotate (7/30 @@ turn) xDir) (4/30 @@ turn)
--     , wedge 1 (rotate (1/8 @@ turn) xDir) (3/4 @@ turn)
--     ]
--     # fc blue
--     # centerXY # pad 1.1
--   
wedge :: (InSpace V2 n t, OrderedField n, TrailLike t) => n -> Direction V2 n -> Angle n -> t

-- | arcBetween p q height creates an arc beginning at p
--   and ending at q, with its midpoint at a distance of abs
--   height away from the straight line from p to q.
--   A positive value of height results in an arc to the left of
--   the line from p to q; a negative value yields one to
--   the right.
--   
--   
--   
--   arcBetweenEx = mconcat
--     [ arcBetween origin (p2 (2,1)) ht | ht <- [-0.2, -0.1 .. 0.2] ]
--     # centerXY # pad 1.1
--   
arcBetween :: (TrailLike t, V t ~ V2, N t ~ n, RealFloat n) => Point V2 n -> Point V2 n -> n -> t

-- | Create an annular wedge of the given radii, beginning at the first
--   direction and extending through the given sweep angle. The radius of
--   the outer circle is given first.
--   
--   
--   
--   annularWedgeEx = hsep 0.50
--     [ annularWedge 1 0.5 xDir (1/4 @@ turn)
--     , annularWedge 1 0.3 (rotate (7/30 @@ turn) xDir) (4/30 @@ turn)
--     , annularWedge 1 0.7 (rotate (1/8 @@ turn) xDir) (3/4 @@ turn)
--     ]
--     # fc blue
--     # centerXY # pad 1.1
--   
annularWedge :: (TrailLike t, V t ~ V2, N t ~ n, RealFloat n) => n -> n -> Direction V2 n -> Angle n -> t

-- | Two-dimensional ellipses (and, as a special case, circles).
module Diagrams.TwoD.Ellipse

-- | A circle of radius 1, with center at the origin.
unitCircle :: (TrailLike t, V t ~ V2, N t ~ n, RealFloat n) => t

-- | A circle of the given radius, centered at the origin. As a path, it
--   begins at (r,0).
circle :: (TrailLike t, V t ~ V2, N t ~ n, RealFloat n, Transformable t) => n -> t

-- | ellipse e constructs an ellipse with eccentricity e
--   by scaling the unit circle in the X direction. The eccentricity must
--   be within the interval [0,1).
ellipse :: (TrailLike t, V t ~ V2, N t ~ n, RealFloat n, Transformable t) => n -> t

-- | ellipseXY x y creates an axis-aligned ellipse, centered at
--   the origin, with radius x along the x-axis and radius
--   y along the y-axis.
ellipseXY :: (TrailLike t, V t ~ V2, N t ~ n, RealFloat n, Transformable t) => n -> n -> t

-- | Segments in two dimensions are special since we may meaningfully
--   compute their point of intersection with a ray.
module Diagrams.TwoD.Segment

-- | Compute the intersections between two fixed segments.
intersectPointsS :: OrderedField n => FixedSegment V2 n -> FixedSegment V2 n -> [P2 n]

-- | Compute the intersections between two segments using the given
--   tolerance.
intersectPointsS' :: OrderedField n => n -> FixedSegment V2 n -> FixedSegment V2 n -> [P2 n]

-- | Get the closest point(s) on a FixedSegment from a point.
closestPoint :: OrderedField n => FixedSegment V2 n -> P2 n -> [P2 n]

-- | Get the closest point(s) on a FixedSegment from a point within
--   given tolerance.
closestPoint' :: OrderedField n => n -> FixedSegment V2 n -> P2 n -> [P2 n]

-- | Get the closest distance(s) from a point to a FixedSegment.
closestDistance :: OrderedField n => FixedSegment V2 n -> P2 n -> [n]

-- | Get the closest distance(s) from a point to a FixedSegment
--   within given tolerance.
closestDistance' :: OrderedField n => n -> FixedSegment V2 n -> P2 n -> [n]

-- | Find the closest value(s) on the Bêzier to the given point.
closestParam :: OrderedField n => FixedSegment V2 n -> P2 n -> [n]

-- | Find the closest value(s) on the Bêzier to the given point within
--   given tolerance.
closestParam' :: OrderedField n => n -> FixedSegment V2 n -> P2 n -> [n]

-- | Return the intersection points with the parameters at which each
--   segment intersects.
segmentSegment :: OrderedField n => n -> FixedSegment V2 n -> FixedSegment V2 n -> [(n, n, P2 n)]

-- | Return the intersection points with the parameters at which the line
--   and segment intersect.
lineSegment :: OrderedField n => n -> Located (V2 n) -> FixedSegment V2 n -> [(n, n, P2 n)]
instance Diagrams.Core.Envelope.OrderedField n => Diagrams.Core.Trace.Traced (Diagrams.Segment.Segment Diagrams.Segment.Closed Linear.V2.V2 n)
instance Diagrams.Core.Envelope.OrderedField n => Diagrams.Core.Trace.Traced (Diagrams.Segment.FixedSegment Linear.V2.V2 n)

-- | Higher-level tools for combining diagrams.
module Diagrams.Combinators

-- | Use the envelope from some object as the envelope for a diagram, in
--   place of the diagram's default envelope.
--   
--   
--   
--   sqNewEnv =
--       circle 1 # fc green
--       |||
--       (    c # dashingG [0.1,0.1] 0 # lc white
--         <> square 2 # withEnvelope (c :: D V2 Double) # fc blue
--       )
--   c = circle 0.8
--   withEnvelopeEx = sqNewEnv # centerXY # pad 1.5
--   
withEnvelope :: (InSpace v n a, Metric v, OrderedField n, Monoid' m, Enveloped a) => a -> QDiagram b v n m -> QDiagram b v n m

-- | Use the trace from some object as the trace for a diagram, in place of
--   the diagram's default trace.
withTrace :: (InSpace v n a, Metric v, OrderedField n, Monoid' m, Traced a) => a -> QDiagram b v n m -> QDiagram b v n m

-- | phantom x produces a "phantom" diagram, which has the same
--   envelope and trace as x but produces no output.
phantom :: (InSpace v n a, Monoid' m, Enveloped a, Traced a) => a -> QDiagram b v n m

-- | strut v is a diagram which produces no output, but with
--   respect to alignment and envelope acts like a 1-dimensional segment
--   oriented along the vector v, with local origin at its center.
--   (Note, however, that it has an empty trace; for 2D struts with a
--   nonempty trace see strutR2, strutX, and
--   strutY from Diagrams.TwoD.Combinators.) Useful for
--   manually creating separation between two diagrams.
--   
--   
--   
--   strutEx = (circle 1 ||| strut unitX ||| circle 1) # centerXY # pad 1.1
--   
strut :: (Metric v, OrderedField n, Monoid' m) => v n -> QDiagram b v n m

-- | pad s "pads" a diagram, expanding its envelope by a factor of
--   s (factors between 0 and 1 can be used to shrink the
--   envelope). Note that the envelope will expand with respect to the
--   local origin, so if the origin is not centered the padding may appear
--   "uneven". If this is not desired, the origin can be centered (using,
--   e.g., centerXY for 2D diagrams) before applying pad.
pad :: (Metric v, OrderedField n, Monoid' m) => n -> QDiagram b v n m -> QDiagram b v n m

-- | frame s increases the envelope of a diagram by and absolute
--   amount s, s is in the local units of the diagram. This
--   function is similar to pad, only it takes an absolute
--   quantity and pre-centering should not be necessary.
frame :: (Metric v, OrderedField n, Monoid' m) => n -> QDiagram b v n m -> QDiagram b v n m

-- | extrudeEnvelope v d asymmetrically "extrudes" the envelope of
--   a diagram in the given direction. All parts of the envelope within 90
--   degrees of this direction are modified, offset outwards by the
--   magnitude of the vector.
--   
--   This works by offsetting the envelope distance proportionally to the
--   cosine of the difference in angle, and leaving it unchanged when this
--   factor is negative.
extrudeEnvelope :: (Metric v, OrderedField n, Monoid' m) => v n -> QDiagram b v n m -> QDiagram b v n m

-- | intrudeEnvelope v d asymmetrically "intrudes" the envelope of
--   a diagram away from the given direction. All parts of the envelope
--   within 90 degrees of this direction are modified, offset inwards by
--   the magnitude of the vector.
--   
--   Note that this could create strange inverted envelopes, where 
--   diameter v d < 0 .
intrudeEnvelope :: (Metric v, OrderedField n, Monoid' m) => v n -> QDiagram b v n m -> QDiagram b v n m

-- | A convenient synonym for mappend on diagrams, designed to be
--   used infix (to help remember which diagram goes on top of which when
--   combining them, namely, the first on top of the second).
atop :: (OrderedField n, Metric v, Semigroup m) => QDiagram b v n m -> QDiagram b v n m -> QDiagram b v n m

-- | beneath is just a convenient synonym for flip
--   atop; that is, d1 `beneath` d2 is the diagram
--   with d2 superimposed on top of d1.
beneath :: (Metric v, OrderedField n, Monoid' m) => QDiagram b v n m -> QDiagram b v n m -> QDiagram b v n m

-- | Place two monoidal objects (i.e. diagrams, paths,
--   animations...) next to each other along the given vector. In
--   particular, place the second object so that the vector points from the
--   local origin of the first object to the local origin of the second
--   object, at a distance so that their envelopes are just tangent. The
--   local origin of the new, combined object is the local origin of the
--   first object (unless the first object is the identity element, in
--   which case the second object is returned unchanged).
--   
--   
--   
--   besideEx = beside (r2 (20,30))
--                     (circle 1 # fc orange)
--                     (circle 1.5 # fc purple)
--              # showOrigin
--              # centerXY # pad 1.1
--   
--   
--   Note that beside v is associative, so objects under
--   beside v form a semigroup for any given vector v. In
--   fact, they also form a monoid: mempty is clearly a right
--   identity (beside v d1 mempty === d1), and there should also
--   be a special case to make it a left identity, as described above.
--   
--   In older versions of diagrams, beside put the local origin of
--   the result at the point of tangency between the two inputs. That
--   semantics can easily be recovered by performing an alignment on the
--   first input before combining. That is, if beside' denotes the
--   old semantics,
--   
--   
--   beside' v x1 x2 = beside v (x1 # align v) x2
--   
--   
--   To get something like beside v x1 x2 whose local origin is
--   identified with that of x2 instead of x1, use
--   beside (negateV v) x2 x1.
beside :: (Juxtaposable a, Semigroup a) => Vn a -> a -> a -> a

-- | Place two diagrams (or other juxtaposable objects) adjacent to one
--   another, with the second diagram placed in the direction d
--   from the first. The local origin of the resulting combined diagram is
--   the same as the local origin of the first. See the documentation of
--   beside for more information.
atDirection :: (InSpace v n a, Metric v, Floating n, Juxtaposable a, Semigroup a) => Direction v n -> a -> a -> a

-- | appends x ys appends each of the objects in ys to
--   the object x in the corresponding direction. Note that each
--   object in ys is positioned beside x without
--   reference to the other objects in ys, so this is not the same
--   as iterating beside.
--   
--   
--   
--   appendsEx = appends c (zip (iterateN 6 (rotateBy (1/6)) unitX) (repeat c))
--               # centerXY # pad 1.1
--     where c = circle 1
--   
appends :: (Juxtaposable a, Monoid' a) => a -> [(Vn a, a)] -> a

-- | Position things absolutely: combine a list of objects (e.g. diagrams
--   or paths) by assigning them absolute positions in the vector space of
--   the combined object.
--   
--   
--   
--   positionEx = position (zip (map mkPoint [-3, -2.8 .. 3]) (repeat spot))
--     where spot      = circle 0.2 # fc black
--           mkPoint :: Double -> P2 Double
--           mkPoint x = p2 (x,x*x)
--   
position :: (InSpace v n a, HasOrigin a, Monoid' a) => [(Point v n, a)] -> a

-- | Curried version of position, takes a list of points and a
--   list of objects.
atPoints :: (InSpace v n a, HasOrigin a, Monoid' a) => [Point v n] -> [a] -> a

-- | cat v positions a list of objects so that their local origins
--   lie along a line in the direction of v. Successive objects
--   will have their envelopes just touching. The local origin of the
--   result will be the same as the local origin of the first object.
--   
--   See also cat', which takes an extra options record allowing
--   certain aspects of the operation to be tweaked.
cat :: (InSpace v n a, Metric v, Floating n, Juxtaposable a, Monoid' a, HasOrigin a) => v n -> [a] -> a

-- | Like cat, but taking an extra CatOpts arguments allowing
--   the user to specify
--   
--   
--   
- The spacing method: catenation (uniform spacing between envelopes)
--   or distribution (uniform spacing between local origins). The default
--   is catenation.
--   
- The amount of separation between successive diagram
--   envelopes/origins (depending on the spacing method). The default is
--   0.
--   
--   
--   CatOpts is an instance of Default, so with may be
--   used for the second argument, as in cat' (1,2) (with & sep .~
--   2).
--   
--   Note that cat' v (with & catMethod .~ Distrib) ===
--   mconcat (distributing with a separation of 0 is the same as
--   superimposing).
cat' :: (InSpace v n a, Metric v, Floating n, Juxtaposable a, Monoid' a, HasOrigin a) => v n -> CatOpts n -> [a] -> a

-- | Options for cat'.
data CatOpts n

-- | Which CatMethod should be used: normal catenation (default), or
--   distribution?
catMethod :: Lens' (CatOpts n) CatMethod

-- | How much separation should be used between successive diagrams
--   (default: 0)? When catMethod = Cat, this is the distance
--   between envelopes; when catMethod = Distrib, this is
--   the distance between origins.
sep :: Lens' (CatOpts n) n

-- | Methods for concatenating diagrams.
data CatMethod

-- | Normal catenation: simply put diagrams next to one another (possibly
--   with a certain distance in between each). The distance between
--   successive diagram envelopes will be consistent; the distance
--   between origins may vary if the diagrams are of different
--   sizes.
Cat :: CatMethod

-- | Distribution: place the local origins of diagrams at regular
--   intervals. With this method, the distance between successive
--   origins will be consistent but the distance between envelopes
--   may not be. Indeed, depending on the amount of separation, diagrams
--   may overlap.
Distrib :: CatMethod
instance GHC.Num.Num n => Data.Default.Class.Default (Diagrams.Combinators.CatOpts n)

-- | "Envelopes", aka functional bounding regions. See
--   Diagrams.Core.Envelope for internal implementation details.
module Diagrams.Envelope

-- | Every diagram comes equipped with an envelope. What is an
--   envelope?
--   
--   Consider first the idea of a bounding box. A bounding box
--   expresses the distance to a bounding plane in every direction parallel
--   to an axis. That is, a bounding box can be thought of as the
--   intersection of a collection of half-planes, two perpendicular to each
--   axis.
--   
--   More generally, the intersection of half-planes in every
--   direction would give a tight "bounding region", or convex hull.
--   However, representing such a thing intensionally would be impossible;
--   hence bounding boxes are often used as an approximation.
--   
--   An envelope is an extensional representation of such a
--   "bounding region". Instead of storing some sort of direct
--   representation, we store a function which takes a direction as
--   input and gives a distance to a bounding half-plane as output. The
--   important point is that envelopes can be composed, and transformed by
--   any affine transformation.
--   
--   Formally, given a vector v, the envelope computes a scalar
--   s such that
--   
--   
--   
- for every point u inside the diagram, if the projection
--   of (u - origin) onto v is s' *^ v, then
--   s' <= s.
--   
- s is the smallest such scalar.
--   
--   
--   There is also a special "empty envelope".
--   
--   The idea for envelopes came from Sebastian Setzer; see
--   http://byorgey.wordpress.com/2009/10/28/collecting-attributes/#comment-2030.
--   See also Brent Yorgey, Monoids: Theme and Variations, published
--   in the 2012 Haskell Symposium:
--   http://www.cis.upenn.edu/~byorgey/pub/monoid-pearl.pdf; video:
--   http://www.youtube.com/watch?v=X-8NCkD2vOw.
data Envelope (v :: * -> *) n :: (* -> *) -> * -> *

-- | Enveloped abstracts over things which have an envelope.
class (Metric (V a), OrderedField (N a)) => Enveloped a

-- | Lens onto the Envelope of a QDiagram.
envelope :: (OrderedField n, Metric v, Monoid' m) => Lens' (QDiagram b v n m) (Envelope v n)

-- | Replace the envelope of a diagram.
setEnvelope :: (OrderedField n, Metric v, Monoid' m) => Envelope v n -> QDiagram b v n m -> QDiagram b v n m

-- | Use the envelope from some object as the envelope for a diagram, in
--   place of the diagram's default envelope.
--   
--   
--   
--   sqNewEnv =
--       circle 1 # fc green
--       |||
--       (    c # dashingG [0.1,0.1] 0 # lc white
--         <> square 2 # withEnvelope (c :: D V2 Double) # fc blue
--       )
--   c = circle 0.8
--   withEnvelopeEx = sqNewEnv # centerXY # pad 1.5
--   
withEnvelope :: (InSpace v n a, Metric v, OrderedField n, Monoid' m, Enveloped a) => a -> QDiagram b v n m -> QDiagram b v n m

-- | phantom x produces a "phantom" diagram, which has the same
--   envelope and trace as x but produces no output.
phantom :: (InSpace v n a, Monoid' m, Enveloped a, Traced a) => a -> QDiagram b v n m

-- | pad s "pads" a diagram, expanding its envelope by a factor of
--   s (factors between 0 and 1 can be used to shrink the
--   envelope). Note that the envelope will expand with respect to the
--   local origin, so if the origin is not centered the padding may appear
--   "uneven". If this is not desired, the origin can be centered (using,
--   e.g., centerXY for 2D diagrams) before applying pad.
pad :: (Metric v, OrderedField n, Monoid' m) => n -> QDiagram b v n m -> QDiagram b v n m

-- | extrudeEnvelope v d asymmetrically "extrudes" the envelope of
--   a diagram in the given direction. All parts of the envelope within 90
--   degrees of this direction are modified, offset outwards by the
--   magnitude of the vector.
--   
--   This works by offsetting the envelope distance proportionally to the
--   cosine of the difference in angle, and leaving it unchanged when this
--   factor is negative.
extrudeEnvelope :: (Metric v, OrderedField n, Monoid' m) => v n -> QDiagram b v n m -> QDiagram b v n m

-- | intrudeEnvelope v d asymmetrically "intrudes" the envelope of
--   a diagram away from the given direction. All parts of the envelope
--   within 90 degrees of this direction are modified, offset inwards by
--   the magnitude of the vector.
--   
--   Note that this could create strange inverted envelopes, where 
--   diameter v d < 0 .
intrudeEnvelope :: (Metric v, OrderedField n, Monoid' m) => v n -> QDiagram b v n m -> QDiagram b v n m

-- | Compute the vector from the local origin to a separating hyperplane in
--   the given direction, or Nothing for the empty envelope.
envelopeVMay :: Enveloped a => Vn a -> a -> Maybe (Vn a)

-- | Compute the vector from the local origin to a separating hyperplane in
--   the given direction. Returns the zero vector for the empty envelope.
envelopeV :: Enveloped a => Vn a -> a -> Vn a

-- | Compute the point on a separating hyperplane in the given direction,
--   or Nothing for the empty envelope.
envelopePMay :: ((~) (* -> *) (V a) v, (~) * (N a) n, Enveloped a) => v n -> a -> Maybe (Point v n)

-- | Compute the point on a separating hyperplane in the given direction.
--   Returns the origin for the empty envelope.
envelopeP :: ((~) (* -> *) (V a) v, (~) * (N a) n, Enveloped a) => v n -> a -> Point v n

-- | Compute the diameter of a enveloped object along a particular vector.
--   Returns zero for the empty envelope.
diameter :: ((~) (* -> *) (V a) v, (~) * (N a) n, Enveloped a) => v n -> a -> n

-- | Compute the "radius" (1/2 the diameter) of an enveloped object along a
--   particular vector.
radius :: ((~) (* -> *) (V a) v, (~) * (N a) n, Enveloped a) => v n -> a -> n

-- | "Traces", aka embedded raytracers, for finding points on the edge of a
--   diagram. See Diagrams.Core.Trace for internal implementation
--   details.
module Diagrams.Trace

-- | Every diagram comes equipped with a trace. Intuitively, the
--   trace for a diagram is like a raytracer: given a line (represented as
--   a base point and a direction vector), the trace computes a sorted list
--   of signed distances from the base point to all intersections of the
--   line with the boundary of the diagram.
--   
--   Note that the outputs are not absolute distances, but multipliers
--   relative to the input vector. That is, if the base point is p
--   and direction vector is v, and one of the output scalars is
--   s, then there is an intersection at the point p .+^ (s *^
--   v).
--   
data Trace (v :: * -> *) n :: (* -> *) -> * -> *

-- | Traced abstracts over things which have a trace.
class (Additive (V a), Ord (N a)) => Traced a

-- | Lens onto the Trace of a QDiagram.
trace :: (Metric v, OrderedField n, Semigroup m) => Lens' (QDiagram b v n m) (Trace v n)

-- | Replace the trace of a diagram.
setTrace :: (OrderedField n, Metric v, Semigroup m) => Trace v n -> QDiagram b v n m -> QDiagram b v n m

-- | Use the trace from some object as the trace for a diagram, in place of
--   the diagram's default trace.
withTrace :: (InSpace v n a, Metric v, OrderedField n, Monoid' m, Traced a) => a -> QDiagram b v n m -> QDiagram b v n m

-- | Compute the vector from the given point p to the "smallest"
--   boundary intersection along the given vector v. The
--   "smallest" boundary intersection is defined as the one given by p
--   .+^ (s *^ v) for the smallest (most negative) value of
--   s. Return Nothing if there is no intersection. See
--   also traceP.
--   
--   See also rayTraceV which uses the smallest positive
--   intersection, which is often more intuitive behavior.
--   
traceV :: ((~) * n (N a), Num n, Traced a) => Point (V a) n -> V a n -> a -> Maybe (V a n)

-- | Compute the "smallest" boundary point along the line determined by the
--   given point p and vector v. The "smallest" boundary
--   point is defined as the one given by p .+^ (s *^ v) for the
--   smallest (most negative) value of s. Return Nothing
--   if there is no such boundary point. See also traceV.
--   
--   See also rayTraceP which uses the smallest positive
--   intersection, which is often more intuitive behavior.
--   
traceP :: ((~) * n (N a), Traced a, Num n) => Point (V a) n -> V a n -> a -> Maybe (Point (V a) n)

-- | Like traceV, but computes a vector to the "largest" boundary
--   point instead of the smallest. (Note, however, the "largest" boundary
--   point may still be in the opposite direction from the given vector, if
--   all the boundary points are, as in the third example shown below.)
--   
maxTraceV :: ((~) * n (N a), Num n, Traced a) => Point (V a) n -> V a n -> a -> Maybe (V a n)

-- | Like traceP, but computes the "largest" boundary point instead
--   of the smallest. (Note, however, the "largest" boundary point may
--   still be in the opposite direction from the given vector, if all the
--   boundary points are.)
--   
maxTraceP :: ((~) * n (N a), Num n, Traced a) => Point (V a) n -> V a n -> a -> Maybe (Point (V a) n)

-- | Compute the furthest point on the boundary of a subdiagram, beginning
--   from the location (local origin) of the subdiagram and moving in the
--   direction of the given vector. If there is no such point, the origin
--   is returned; see also boundaryFromMay.
boundaryFrom :: (OrderedField n, Metric v, Semigroup m) => Subdiagram b v n m -> v n -> Point v n

-- | Compute the furthest point on the boundary of a subdiagram, beginning
--   from the location (local origin) of the subdiagram and moving in the
--   direction of the given vector, or Nothing if there is no such
--   point.
boundaryFromMay :: (Metric v, OrderedField n, Semigroup m) => Subdiagram b v n m -> v n -> Maybe (Point v n)

-- | The alignment of an object refers to the position of its local
--   origin with respect to its envelope. This module defines the
--   Alignable class for things which can be aligned, as well as a
--   default implementation in terms of HasOrigin and
--   Enveloped, along with several utility methods for alignment.
module Diagrams.Align

-- | Class of things which can be aligned.
class Alignable a where alignBy' = alignBy'Default alignBy = alignBy' defaultBoundary

-- | alignBy v d a moves the origin of a along the vector
--   v. If d = 1, the origin is moved to the edge of the
--   boundary in the direction of v; if d = -1, it moves
--   to the edge of the boundary in the direction of the negation of
--   v. Other values of d interpolate linearly (so for
--   example, d = 0 centers the origin along the direction of
--   v).
alignBy' :: (Alignable a, InSpace v n a, Fractional n, HasOrigin a) => (v n -> a -> Point v n) -> v n -> n -> a -> a
defaultBoundary :: (Alignable a, V a ~ v, N a ~ n) => v n -> a -> Point v n
alignBy :: (Alignable a, InSpace v n a, Fractional n, HasOrigin a) => v n -> n -> a -> a

-- | Default implementation of alignBy for types with
--   HasOrigin and AdditiveGroup instances.
alignBy'Default :: (InSpace v n a, Fractional n, HasOrigin a) => (v n -> a -> Point v n) -> v n -> n -> a -> a

-- | Some standard functions which can be used as the boundary
--   argument to alignBy'.
envelopeBoundary :: (V a ~ v, N a ~ n, Enveloped a) => v n -> a -> Point v n
traceBoundary :: (V a ~ v, N a ~ n, Num n, Traced a) => v n -> a -> Point v n

-- | align v aligns an enveloped object along the edge in the
--   direction of v. That is, it moves the local origin in the
--   direction of v until it is on the edge of the envelope. (Note
--   that if the local origin is outside the envelope to begin with, it may
--   have to move "backwards".)
align :: (InSpace v n a, Fractional n, Alignable a, HasOrigin a) => v n -> a -> a

-- | Like align but uses trace.
snug :: (InSpace v n a, Fractional n, Alignable a, Traced a, HasOrigin a) => v n -> a -> a

-- | centerV v centers an enveloped object along the direction of
--   v.
centerV :: (InSpace v n a, Fractional n, Alignable a, HasOrigin a) => v n -> a -> a

-- | center centers an enveloped object along all of its basis
--   vectors.
center :: (InSpace v n a, Fractional n, Traversable v, Alignable a, HasOrigin a) => a -> a

-- | Version of alignBy specialized to use traceBoundary
snugBy :: (InSpace v n a, Fractional n, Alignable a, Traced a, HasOrigin a) => v n -> n -> a -> a

-- | Like centerV using trace.
snugCenterV :: (InSpace v n a, Fractional n, Alignable a, Traced a, HasOrigin a) => v n -> a -> a

-- | Like center using trace.
snugCenter :: (InSpace v n a, Traversable v, Fractional n, Alignable a, HasOrigin a, Traced a) => a -> a
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n) => Diagrams.Align.Alignable (Diagrams.Core.Envelope.Envelope v n)
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n) => Diagrams.Align.Alignable (Diagrams.Core.Trace.Trace v n)
instance (Diagrams.Core.V.V b ~ v, Diagrams.Core.V.N b ~ n, Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n, Diagrams.Align.Alignable b) => Diagrams.Align.Alignable [b]
instance (Diagrams.Core.V.V b ~ v, Diagrams.Core.V.N b ~ n, Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n, Diagrams.Align.Alignable b) => Diagrams.Align.Alignable (Data.Set.Base.Set b)
instance (Diagrams.Core.V.V b ~ v, Diagrams.Core.V.N b ~ n, Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n, Diagrams.Align.Alignable b) => Diagrams.Align.Alignable (Data.Map.Base.Map k b)
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n, Data.Monoid.WithSemigroup.Monoid' m) => Diagrams.Align.Alignable (Diagrams.Core.Types.QDiagram b v n m)
instance (Diagrams.Core.V.InSpace v n a, Diagrams.Core.HasOrigin.HasOrigin a, Diagrams.Align.Alignable a) => Diagrams.Align.Alignable (b -> a)

-- | This module defines paths, which are collections of concretely
--   located Trails. Many drawing systems (cairo, svg, ...) have a
--   similar notion of "path". Note that paths with multiple trails are
--   necessary for being able to draw e.g. filled objects with holes
--   in them.
module Diagrams.Path

-- | A path is a (possibly empty) list of Located
--   Trails. Hence, unlike trails, paths are not translationally
--   invariant, and they form a monoid under superposition (placing
--   one path on top of another) rather than concatenation.
newtype Path v n
Path :: [Located (Trail v n)] -> Path v n

-- | Extract the located trails making up a Path.
pathTrails :: Path v n -> [Located (Trail v n)]

-- | Type class for things that can be converted to a Path.
--   
--   Note that this class is very different from TrailLike.
--   TrailLike is usually the result of a library function to give
--   you a convenient, polymorphic result (Path, Diagram
--   etc.).
class ToPath t

-- | toPath takes something that can be converted to Path and
--   returns the Path.
toPath :: (ToPath t, Metric (V t), OrderedField (N t)) => t -> Path (V t) (N t)

-- | Convert a trail to a path beginning at the origin.
pathFromTrail :: (Metric v, OrderedField n) => Trail v n -> Path v n

-- | Convert a trail to a path with a particular starting point.
pathFromTrailAt :: (Metric v, OrderedField n) => Trail v n -> Point v n -> Path v n

-- | Convert a located trail to a singleton path. This is equivalent to
--   trailLike, but provided with a more specific name and type for
--   convenience.
pathFromLocTrail :: (Metric v, OrderedField n) => Located (Trail v n) -> Path v n

-- | Extract the points of a path, resulting in a separate list of points
--   for each component trail. Here a point is any place where two
--   segments join; see also pathVertices and trailPoints.
--   
--   This function allows you "observe" the fact that trails are
--   implemented as lists of segments, which may be problematic if we want
--   to think of trails as parametric vector functions. This also means
--   that the behavior of this function may not be stable under future
--   changes to the implementation of trails and paths. For an
--   unproblematic version which only yields vertices at which there is a
--   sharp corner, excluding points differentiable points, see
--   pathVertices.
--   
--   This function is not re-exported from Diagrams.Prelude; to use
--   it, import Diagrams.Path.
pathPoints :: (Metric v, OrderedField n) => Path v n -> [[Point v n]]

-- | Extract the vertices of a path, resulting in a separate list of
--   vertices for each component trail. Here a vertex is defined as
--   a non-differentiable point on the trail, i.e. a sharp corner.
--   (Vertices are thus a subset of the places where segments join; if you
--   want all joins between segments, see pathPoints.) The tolerance
--   determines how close the tangents of two segments must be at their
--   endpoints to consider the transition point to be differentiable. See
--   trailVertices for more information.
pathVertices' :: (Metric v, OrderedField n) => n -> Path v n -> [[Point v n]]

-- | Like pathVertices', with a default tolerance.
pathVertices :: (Metric v, OrderedField n) => Path v n -> [[Point v n]]

-- | Compute the total offset of each trail comprising a path (see
--   trailOffset).
pathOffsets :: (Metric v, OrderedField n) => Path v n -> [v n]

-- | Compute the centroid of a path (i.e. the average
--   location of its vertices; see pathVertices).
pathCentroid :: (Metric v, OrderedField n) => Path v n -> Point v n

-- | Convert a path into a list of lists of located segments.
pathLocSegments :: (Metric v, OrderedField n) => Path v n -> [[Located (Segment Closed v n)]]

-- | Convert a path into a list of lists of FixedSegments.
fixPath :: (Metric v, OrderedField n) => Path v n -> [[FixedSegment v n]]

-- | Scale a path using its centroid (see pathCentroid) as the base
--   point for the scale.
scalePath :: (HasLinearMap v, Metric v, OrderedField n) => n -> Path v n -> Path v n

-- | Reverse all the component trails of a path.
reversePath :: (Metric v, OrderedField n) => Path v n -> Path v n

-- | "Explode" a path by exploding every component trail (see
--   explodeTrail).
explodePath :: (V t ~ v, N t ~ n, Additive v, TrailLike t) => Path v n -> [[t]]

-- | Partition a path into two paths based on a predicate on trails: the
--   first containing all the trails for which the predicate returns
--   True, and the second containing the remaining trails.
partitionPath :: (Located (Trail v n) -> Bool) -> Path v n -> (Path v n, Path v n)
instance GHC.Base.Monoid (Diagrams.Path.Path v n)
instance Data.Semigroup.Semigroup (Diagrams.Path.Path v n)
instance GHC.Show.Show (v n) => GHC.Show.Show (Diagrams.Path.Path v n)
instance GHC.Classes.Eq (v n) => GHC.Classes.Eq (Diagrams.Path.Path v n)
instance GHC.Classes.Ord (v n) => GHC.Classes.Ord (Diagrams.Path.Path v n)
instance Control.Lens.Wrapped.Wrapped (Diagrams.Path.Path v n)
instance Control.Lens.Wrapped.Rewrapped (Diagrams.Path.Path v n) (Diagrams.Path.Path v' n')
instance Control.Lens.Each.Each (Diagrams.Path.Path v n) (Diagrams.Path.Path v' n') (Diagrams.Located.Located (Diagrams.Trail.Trail v n)) (Diagrams.Located.Located (Diagrams.Trail.Trail v' n'))
instance Control.Lens.Empty.AsEmpty (Diagrams.Path.Path v n)
instance Control.Lens.Cons.Cons (Diagrams.Path.Path v n) (Diagrams.Path.Path v' n') (Diagrams.Located.Located (Diagrams.Trail.Trail v n)) (Diagrams.Located.Located (Diagrams.Trail.Trail v' n'))
instance Control.Lens.Cons.Snoc (Diagrams.Path.Path v n) (Diagrams.Path.Path v' n') (Diagrams.Located.Located (Diagrams.Trail.Trail v n)) (Diagrams.Located.Located (Diagrams.Trail.Trail v' n'))
instance (Linear.Vector.Additive v, GHC.Num.Num n) => Diagrams.Core.HasOrigin.HasOrigin (Diagrams.Path.Path v n)
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n) => Diagrams.TrailLike.TrailLike (Diagrams.Path.Path v n)
instance (Diagrams.Core.Transform.HasLinearMap v, Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n) => Diagrams.Core.Transform.Transformable (Diagrams.Path.Path v n)
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n) => Diagrams.Core.Envelope.Enveloped (Diagrams.Path.Path v n)
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n) => Diagrams.Core.Juxtapose.Juxtaposable (Diagrams.Path.Path v n)
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n) => Diagrams.Align.Alignable (Diagrams.Path.Path v n)
instance (Diagrams.Core.Transform.HasLinearMap v, Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n) => Diagrams.Core.Types.Renderable (Diagrams.Path.Path v n) Diagrams.Core.Types.NullBackend
instance Diagrams.Path.ToPath (Diagrams.Path.Path v n)
instance Diagrams.Path.ToPath (Diagrams.Trail.Trail v n)
instance Diagrams.Path.ToPath (Diagrams.Located.Located (Diagrams.Trail.Trail v n))
instance Diagrams.Path.ToPath (Diagrams.Located.Located (Diagrams.Trail.Trail' l v n))
instance Diagrams.Path.ToPath (Diagrams.Located.Located (Diagrams.Segment.Segment Diagrams.Segment.Closed v n))
instance Diagrams.Path.ToPath (Diagrams.Located.Located [Diagrams.Segment.Segment Diagrams.Segment.Closed v n])
instance Diagrams.Path.ToPath (Diagrams.Segment.FixedSegment v n)
instance Diagrams.Path.ToPath a => Diagrams.Path.ToPath [a]
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n) => Control.Lens.Internal.Iso.Reversing (Diagrams.Path.Path v n)

module Diagrams.Deform

-- | Deformations are a superset of the affine transformations
--   represented by the Transformation type. In general they are not
--   invertible. Deformations include projective transformations.
--   Deformation can represent other functions from points to
--   points which are "well-behaved", in that they do not introduce small
--   wiggles.
newtype Deformation v u n
Deformation :: (Point v n -> Point u n) -> Deformation v u n
class Deformable a b

-- | deform' epsilon d a transforms a by the deformation
--   d. If the type of a is not closed under projection,
--   approximate to accuracy epsilon.
deform' :: Deformable a b => N a -> Deformation (V a) (V b) (N a) -> a -> b

-- | deform d a transforms a by the deformation
--   d. If the type of a is not closed under projection,
--   deform should call deform' with some reasonable
--   default value of epsilon.
deform :: Deformable a b => Deformation (V a) (V b) (N a) -> a -> b

-- | asDeformation converts a Transformation to a
--   Deformation by discarding the inverse transform. This allows
--   reusing Transformations in the construction of
--   Deformations.
asDeformation :: (Additive v, Num n) => Transformation v n -> Deformation v v n
instance Data.Semigroup.Semigroup (Diagrams.Deform.Deformation v v n)
instance GHC.Base.Monoid (Diagrams.Deform.Deformation v v n)
instance (r ~ Linear.Affine.Point u n) => Diagrams.Deform.Deformable (Linear.Affine.Point v n) r
instance (Linear.Metric.Metric v, Linear.Metric.Metric u, Diagrams.Core.Envelope.OrderedField n, r ~ Diagrams.Located.Located (Diagrams.Trail.Trail u n)) => Diagrams.Deform.Deformable (Diagrams.Located.Located (Diagrams.Trail.Trail v n)) r
instance (Linear.Metric.Metric v, Linear.Metric.Metric u, Diagrams.Core.Envelope.OrderedField n, r ~ Diagrams.Path.Path u n) => Diagrams.Deform.Deformable (Diagrams.Path.Path v n) r

module Diagrams.TwoD.Deform

-- | The parallel projection onto the plane x=0
parallelX0 :: (R1 v, Num n) => Deformation v v n

-- | The perspective division onto the plane x=1 along lines going through
--   the origin.
perspectiveX1 :: (R1 v, Functor v, Fractional n) => Deformation v v n

-- | The parallel projection onto the plane y=0
parallelY0 :: (R2 v, Num n) => Deformation v v n

-- | The perspective division onto the plane y=1 along lines going through
--   the origin.
perspectiveY1 :: (R2 v, Functor v, Floating n) => Deformation v v n

-- | The viewing transform for a viewer facing along the positive X axis. X
--   coördinates stay fixed, while Y coördinates are compressed with
--   increasing distance. asDeformation (translation unitX) <>
--   parallelX0 <> frustrumX = perspectiveX1
facingX :: (R1 v, Functor v, Fractional n) => Deformation v v n
facingY :: (R2 v, Functor v, Fractional n) => Deformation v v n

module Diagrams.ThreeD.Deform

-- | The parallel projection onto the plane x=0
parallelX0 :: (R1 v, Num n) => Deformation v v n

-- | The perspective division onto the plane x=1 along lines going through
--   the origin.
perspectiveX1 :: (R1 v, Functor v, Fractional n) => Deformation v v n

-- | The viewing transform for a viewer facing along the positive X axis. X
--   coördinates stay fixed, while Y coördinates are compressed with
--   increasing distance. asDeformation (translation unitX) <>
--   parallelX0 <> frustrumX = perspectiveX1
facingX :: (R1 v, Functor v, Fractional n) => Deformation v v n

-- | The parallel projection onto the plane y=0
parallelY0 :: (R2 v, Num n) => Deformation v v n

-- | The perspective division onto the plane y=1 along lines going through
--   the origin.
perspectiveY1 :: (R2 v, Functor v, Floating n) => Deformation v v n
facingY :: (R2 v, Functor v, Fractional n) => Deformation v v n

-- | The parallel projection onto the plane z=0
parallelZ0 :: (R3 v, Num n) => Deformation v v n

-- | The perspective division onto the plane z=1 along lines going through
--   the origin.
perspectiveZ1 :: (R3 v, Functor v, Fractional n) => Deformation v v n
facingZ :: (R3 v, Functor v, Fractional n) => Deformation v v n

-- | Paths in two dimensions are special since we may stroke them to create
--   a 2D diagram, and (eventually) perform operations such as intersection
--   and union. They also have a trace, whereas paths in higher dimensions
--   do not.
module Diagrams.TwoD.Path

-- | Convert a ToPath object into a diagram. The resulting diagram
--   has the names 0, 1, ... assigned to each of the path's vertices.
--   
--   See also stroke', which takes an extra options record allowing
--   its behaviour to be customized.
stroke :: (InSpace V2 n t, ToPath t, TypeableFloat n, Renderable (Path V2 n) b) => t -> QDiagram b V2 n Any

-- | A variant of stroke that takes an extra record of options to
--   customize its behaviour. In particular:
--   
--   
--   
- Names can be assigned to the path's vertices
--   
--   
--   StrokeOpts is an instance of Default, so stroke'
--   (with & ... ) syntax may be used.
stroke' :: (InSpace V2 n t, ToPath t, TypeableFloat n, Renderable (Path V2 n) b, IsName a) => StrokeOpts a -> t -> QDiagram b V2 n Any

-- | stroke specialised to Path.
strokePath :: (TypeableFloat n, Renderable (Path V2 n) b) => Path V2 n -> QDiagram b V2 n Any

-- | stroke specialised to Path.
strokeP :: (TypeableFloat n, Renderable (Path V2 n) b) => Path V2 n -> QDiagram b V2 n Any

-- | stroke' specialised to Path.
strokePath' :: (TypeableFloat n, Renderable (Path V2 n) b, IsName a) => StrokeOpts a -> Path V2 n -> QDiagram b V2 n Any

-- | stroke' specialised to Path.
strokeP' :: (TypeableFloat n, Renderable (Path V2 n) b, IsName a) => StrokeOpts a -> Path V2 n -> QDiagram b V2 n Any

-- | stroke specialised to Trail.
strokeTrail :: (TypeableFloat n, Renderable (Path V2 n) b) => Trail V2 n -> QDiagram b V2 n Any

-- | stroke specialised to Trail.
strokeT :: (TypeableFloat n, Renderable (Path V2 n) b) => Trail V2 n -> QDiagram b V2 n Any

-- | A composition of stroke' and pathFromTrail for
--   conveniently converting a trail directly into a diagram.
strokeTrail' :: (TypeableFloat n, Renderable (Path V2 n) b, IsName a) => StrokeOpts a -> Trail V2 n -> QDiagram b V2 n Any

-- | Deprecated synonym for strokeTrail'.
strokeT' :: (TypeableFloat n, Renderable (Path V2 n) b, IsName a) => StrokeOpts a -> Trail V2 n -> QDiagram b V2 n Any

-- | A composition of strokeT and wrapLine for conveniently
--   converting a line directly into a diagram.
strokeLine :: (TypeableFloat n, Renderable (Path V2 n) b) => Trail' Line V2 n -> QDiagram b V2 n Any

-- | A composition of strokeT and wrapLoop for conveniently
--   converting a loop directly into a diagram.
strokeLoop :: (TypeableFloat n, Renderable (Path V2 n) b) => Trail' Loop V2 n -> QDiagram b V2 n Any

-- | A convenience function for converting a Located Trail
--   directly into a diagram; strokeLocTrail = stroke . trailLike.
strokeLocTrail :: (TypeableFloat n, Renderable (Path V2 n) b) => Located (Trail V2 n) -> QDiagram b V2 n Any

-- | Deprecated synonym for strokeLocTrail.
strokeLocT :: (TypeableFloat n, Renderable (Path V2 n) b) => Located (Trail V2 n) -> QDiagram b V2 n Any

-- | A convenience function for converting a Located line directly
--   into a diagram; strokeLocLine = stroke . trailLike . mapLoc
--   wrapLine.
strokeLocLine :: (TypeableFloat n, Renderable (Path V2 n) b) => Located (Trail' Line V2 n) -> QDiagram b V2 n Any

-- | A convenience function for converting a Located loop directly
--   into a diagram; strokeLocLoop = stroke . trailLike . mapLoc
--   wrapLoop.
strokeLocLoop :: (TypeableFloat n, Renderable (Path V2 n) b) => Located (Trail' Loop V2 n) -> QDiagram b V2 n Any

-- | Enumeration of algorithms or "rules" for determining which points lie
--   in the interior of a (possibly self-intersecting) path.
data FillRule

-- | Interior points are those with a nonzero winding number.
--   See http://en.wikipedia.org/wiki/Nonzero-rule.
Winding :: FillRule

-- | Interior points are those where a ray extended infinitely in a
--   particular direction crosses the path an odd number of times. See
--   http://en.wikipedia.org/wiki/Even-odd_rule.
EvenOdd :: FillRule

-- | Extract the fill rule from a FillRuleA attribute.
getFillRule :: FillRule -> FillRule

-- | Specify the fill rule that should be used for determining which points
--   are inside a path.
fillRule :: HasStyle a => FillRule -> a -> a

-- | Lens onto the fill rule of a style.
_fillRule :: Lens' (Style V2 n) FillRule

-- | A record of options that control how a path is stroked.
--   StrokeOpts is an instance of Default, so a
--   StrokeOpts records can be created using with {
--   ... } notation.
data StrokeOpts a
StrokeOpts :: [[a]] -> FillRule -> StrokeOpts a
[_vertexNames] :: StrokeOpts a -> [[a]]
[_queryFillRule] :: StrokeOpts a -> FillRule

-- | Atomic names that should be assigned to the vertices of the path so
--   that they can be referenced later. If there are not enough names, the
--   extra vertices are not assigned names; if there are too many, the
--   extra names are ignored. Note that this is a list of lists of
--   names, since paths can consist of multiple trails. The first list of
--   names are assigned to the vertices of the first trail, the second list
--   to the second trail, and so on.
--   
--   The default value is the empty list.
vertexNames :: Lens (StrokeOpts a) (StrokeOpts a') [[a]] [[a']]

-- | The fill rule used for determining which points are inside the path.
--   The default is Winding. NOTE: for now, this only affects the
--   resulting diagram's Query, not how it will be drawn! To
--   set the fill rule determining how it is to be drawn, use the
--   fillRule function.
queryFillRule :: Lens' (StrokeOpts a) FillRule

-- | Test whether the given point is inside the given path, by testing
--   whether the point's winding number is nonzero. Note that
--   False is always returned for paths consisting of lines
--   (as opposed to loops), regardless of the winding number.
isInsideWinding :: RealFloat n => Point V2 n -> Path V2 n -> Bool

-- | Test whether the given point is inside the given path, by testing
--   whether a ray extending from the point in the positive x direction
--   crosses the path an even (outside) or odd (inside) number of times.
--   Note that False is always returned for paths
--   consisting of lines (as opposed to loops), regardless of the number of
--   crossings.
isInsideEvenOdd :: RealFloat n => Point V2 n -> Path V2 n -> Bool

-- | Clip tracks the accumulated clipping paths applied to a
--   diagram. Note that the semigroup structure on Clip is list
--   concatenation, so applying multiple clipping paths is sensible. The
--   clipping region is the intersection of all the applied clipping paths.
newtype Clip n
Clip :: [Path V2 n] -> Clip n
_Clip :: Iso (Clip n) (Clip n') [Path V2 n] [Path V2 n']

-- | Lens onto the Clip in a style. An empty list means no clipping.
_clip :: (Typeable n, OrderedField n) => Lens' (Style V2 n) [Path V2 n]

-- | Clip a diagram by the given path:
--   
--   
--   
- Only the parts of the diagram which lie in the interior of the
--   path will be drawn.
--   
- The envelope of the diagram is unaffected.
--   
clipBy :: (HasStyle a, V a ~ V2, N a ~ n, TypeableFloat n) => Path V2 n -> a -> a

-- | Clip a diagram to the given path setting its envelope to the pointwise
--   minimum of the envelopes of the diagram and path. The trace consists
--   of those parts of the original diagram's trace which fall within the
--   clipping path, or parts of the path's trace within the original
--   diagram.
clipTo :: (TypeableFloat n, Renderable (Path V2 n) b) => Path V2 n -> QDiagram b V2 n Any -> QDiagram b V2 n Any

-- | Clip a diagram to the clip path taking the envelope and trace of the
--   clip path.
clipped :: (TypeableFloat n, Renderable (Path V2 n) b) => Path V2 n -> QDiagram b V2 n Any -> QDiagram b V2 n Any

-- | Find the intersect points of two objects that can be converted to a
--   path.
intersectPoints :: (InSpace V2 n t, SameSpace t s, ToPath t, ToPath s, OrderedField n) => t -> s -> [P2 n]

-- | Find the intersect points of two objects that can be converted to a
--   path within the given tolerance.
intersectPoints' :: (InSpace V2 n t, SameSpace t s, ToPath t, ToPath s, OrderedField n) => n -> t -> s -> [P2 n]

-- | Compute the intersect points between two paths.
intersectPointsP :: OrderedField n => Path V2 n -> Path V2 n -> [P2 n]

-- | Compute the intersect points between two paths within given tolerance.
intersectPointsP' :: OrderedField n => n -> Path V2 n -> Path V2 n -> [P2 n]

-- | Compute the intersect points between two located trails.
intersectPointsT :: OrderedField n => Located (Trail V2 n) -> Located (Trail V2 n) -> [P2 n]

-- | Compute the intersect points between two located trails within the
--   given tolerance.
intersectPointsT' :: OrderedField n => n -> Located (Trail V2 n) -> Located (Trail V2 n) -> [P2 n]
instance (Diagrams.TwoD.Path.Clip n1 ~ t0) => Control.Lens.Wrapped.Rewrapped (Diagrams.TwoD.Path.Clip n0) t0
instance Control.Lens.Wrapped.Wrapped (Diagrams.TwoD.Path.Clip n0)
instance Data.Typeable.Internal.Typeable n => Diagrams.Core.Style.AttributeClass (Diagrams.TwoD.Path.Clip n)
instance Control.Lens.Empty.AsEmpty (Diagrams.TwoD.Path.Clip n)
instance Diagrams.Core.Envelope.OrderedField n => Diagrams.Core.Transform.Transformable (Diagrams.TwoD.Path.Clip n)
instance Data.Semigroup.Semigroup (Diagrams.TwoD.Path.Clip n)
instance Data.Default.Class.Default (Diagrams.TwoD.Path.StrokeOpts a)
instance (Diagrams.Core.Types.TypeableFloat n, Diagrams.Core.Types.Renderable (Diagrams.Path.Path Linear.V2.V2 n) b) => Diagrams.TrailLike.TrailLike (Diagrams.Core.Types.QDiagram b Linear.V2.V2 n Data.Monoid.Any)
instance GHC.Classes.Ord Diagrams.TwoD.Path.FillRule
instance GHC.Classes.Eq Diagrams.TwoD.Path.FillRule
instance GHC.Show.Show Diagrams.TwoD.Path.FillRule
instance GHC.Float.RealFloat n => Diagrams.Core.Trace.Traced (Diagrams.Trail.Trail Linear.V2.V2 n)
instance GHC.Float.RealFloat n => Diagrams.Core.Trace.Traced (Diagrams.Path.Path Linear.V2.V2 n)
instance Diagrams.Core.Style.AttributeClass Diagrams.TwoD.Path.FillRule
instance Data.Semigroup.Semigroup Diagrams.TwoD.Path.FillRule
instance Data.Default.Class.Default Diagrams.TwoD.Path.FillRule

-- | Linear maps. Unlike Transformations these are not restricted to
--   the same space. In practice these are used for projections in
--   Diagrams.ThreeD.Projection. Unless you want to work with
--   projections you're probably better off using Transform.
--   
--   Currently only path-like things can be projected. In the future we
--   hope to support projecting diagrams.
module Diagrams.LinearMap

-- | Type for holding linear maps. Note that these are not affine
--   transforms so attemping apply a translation with LinearMap will
--   likely produce incorrect results.
newtype LinearMap v u n
LinearMap :: (v n -> u n) -> LinearMap v u n
[lapply] :: LinearMap v u n -> v n -> u n

-- | Class of things that have vectors that can be mapped over.
class LinearMappable a b

-- | Apply a linear map to an object. If the map is not linear, behaviour
--   will likely be wrong.
vmap :: LinearMappable a b => (Vn a -> Vn b) -> a -> b

-- | Apply a linear map.
linmap :: (InSpace v n a, Foldable v, LinearMappable a b, N b ~ n) => LinearMap v (V b) n -> a -> b

-- | Affine linear maps. Unlike Transformation these do not have to
--   be invertible so we can map between spaces.
data AffineMap v u n
AffineMap :: (LinearMap v u n) -> (u n) -> AffineMap v u n
class (LinearMappable a b, N a ~ N b) => AffineMappable a b where amap (AffineMap f _) = linmap f

-- | Affine map over an object. Has a default implimentation of only
--   applying the linear map
amap :: (AffineMappable a b, Additive (V a), Foldable (V a), Additive (V b), Num (N b)) => AffineMap (V a) (V b) (N b) -> a -> b

-- | Make an affine map from a linear function and a translation.
mkAffineMap :: (v n -> u n) -> u n -> AffineMap v u n
toAffineMap :: (HasBasis v, Num n) => Transformation v n -> AffineMap v v n
instance (r ~ Diagrams.Segment.Offset c u m) => Diagrams.LinearMap.LinearMappable (Diagrams.Segment.Offset c v n) r
instance (r ~ Diagrams.Segment.Segment c u m) => Diagrams.LinearMap.LinearMappable (Diagrams.Segment.Segment c v n) r
instance (Linear.Metric.Metric v, Linear.Metric.Metric u, Diagrams.Core.Envelope.OrderedField n, Diagrams.Core.Envelope.OrderedField m, r ~ Diagrams.Trail.SegTree u m) => Diagrams.LinearMap.LinearMappable (Diagrams.Trail.SegTree v n) r
instance (Linear.Metric.Metric v, Linear.Metric.Metric u, Diagrams.Core.Envelope.OrderedField n, Diagrams.Core.Envelope.OrderedField m, r ~ Diagrams.Trail.Trail' l u m) => Diagrams.LinearMap.LinearMappable (Diagrams.Trail.Trail' l v n) r
instance (Linear.Metric.Metric v, Linear.Metric.Metric u, Diagrams.Core.Envelope.OrderedField n, Diagrams.Core.Envelope.OrderedField m, r ~ Diagrams.Trail.Trail u m) => Diagrams.LinearMap.LinearMappable (Diagrams.Trail.Trail v n) r
instance Diagrams.LinearMap.LinearMappable (Linear.Affine.Point v n) (Linear.Affine.Point u m)
instance (r ~ Diagrams.Segment.FixedSegment u m) => Diagrams.LinearMap.LinearMappable (Diagrams.Segment.FixedSegment v n) r
instance (Diagrams.LinearMap.LinearMappable a b, r ~ Diagrams.Located.Located b) => Diagrams.LinearMap.LinearMappable (Diagrams.Located.Located a) r
instance (Linear.Metric.Metric v, Linear.Metric.Metric u, Diagrams.Core.Envelope.OrderedField n, Diagrams.Core.Envelope.OrderedField m, r ~ Diagrams.Path.Path u m) => Diagrams.LinearMap.LinearMappable (Diagrams.Path.Path v n) r
instance (r ~ Diagrams.Segment.Offset c u n) => Diagrams.LinearMap.AffineMappable (Diagrams.Segment.Offset c v n) r
instance (r ~ Diagrams.Segment.Segment c u n) => Diagrams.LinearMap.AffineMappable (Diagrams.Segment.Segment c v n) r
instance (Linear.Metric.Metric v, Linear.Metric.Metric u, Diagrams.Core.Envelope.OrderedField n, r ~ Diagrams.Trail.SegTree u n) => Diagrams.LinearMap.AffineMappable (Diagrams.Trail.SegTree v n) r
instance (Linear.Metric.Metric v, Linear.Metric.Metric u, Diagrams.Core.Envelope.OrderedField n, r ~ Diagrams.Trail.Trail' l u n) => Diagrams.LinearMap.AffineMappable (Diagrams.Trail.Trail' l v n) r
instance (Linear.Metric.Metric v, Linear.Metric.Metric u, Diagrams.Core.Envelope.OrderedField n, r ~ Diagrams.Trail.Trail u n) => Diagrams.LinearMap.AffineMappable (Diagrams.Trail.Trail v n) r
instance (Linear.Vector.Additive v, Data.Foldable.Foldable v, GHC.Num.Num n, r ~ Linear.Affine.Point u n) => Diagrams.LinearMap.AffineMappable (Linear.Affine.Point v n) r
instance (r ~ Diagrams.Segment.FixedSegment u n) => Diagrams.LinearMap.AffineMappable (Diagrams.Segment.FixedSegment v n) r
instance (Diagrams.LinearMap.LinearMappable a b, Diagrams.Core.V.N a ~ Diagrams.Core.V.N b, r ~ Diagrams.Located.Located b) => Diagrams.LinearMap.AffineMappable (Diagrams.Located.Located a) r
instance (Linear.Metric.Metric v, Linear.Metric.Metric u, Diagrams.Core.Envelope.OrderedField n, r ~ Diagrams.Path.Path u n) => Diagrams.LinearMap.AffineMappable (Diagrams.Path.Path v n) r

-- | 3D projections are a way of viewing a three-dimensional objects on a
--   two-dimensional plane.
--   
--   This module can be used with the functions in
--   Linear.Projection.
--   
--   Disclaimer: This module should be considered experimental and is
--   likely to change.
module Diagrams.ThreeD.Projection

-- | Look at the xy-plane with y as the up direction.
facingXY :: (Epsilon n, Floating n) => AffineMap V3 V2 n

-- | Look at the xz-plane with z as the up direction.
facingXZ :: (Epsilon n, Floating n) => AffineMap V3 V2 n

-- | Look at the yz-plane with z as the up direction.
facingYZ :: (Epsilon n, Floating n) => AffineMap V3 V2 n

-- | Apply an isometric projection given the up direction
isometricApply :: (InSpace V3 n a, InSpace V2 n b, AffineMappable a b, Floating n, Epsilon n) => Direction V3 n -> a -> b

-- | Make an isometric affine map with the given up direction.
isometric :: (Floating n, Epsilon n) => Direction V3 n -> AffineMap V3 V2 n
lookingAt :: (Epsilon n, Floating n) => P3 n -> P3 n -> Direction V3 n -> AffineMap V3 V2 n

-- | Apply the affine part of a homogeneous matrix.
m44AffineApply :: (InSpace V3 n a, InSpace V2 n b, AffineMappable a b) => M44 n -> a -> b

-- | Create an AffineMap from a 4x4 homogeneous matrix, ignoring any
--   perspective transforms.
m44AffineMap :: Num n => M44 n -> AffineMap V3 V2 n

-- | Apply a transformation matrix and translation.
m33AffineApply :: (InSpace V3 n a, InSpace V2 n b, AffineMappable a b) => M33 n -> V2 n -> a -> b

-- | Create an AffineMap from a 3x3 transformation matrix and a
--   translation vector.
m33AffineMap :: Num n => M33 n -> V2 n -> AffineMap V3 V2 n

-- | Make a deformation from a 4x4 homogeneous matrix.
m44Deformation :: Fractional n => M44 n -> Deformation V3 V2 n

-- | This module defines a general API for creating various types of
--   polygons.
module Diagrams.TwoD.Polygons

-- | Method used to determine the vertices of a polygon.
data PolyType n

-- | A "polar" polygon.
--   
--   
--   
- The first argument is a list of central angles from
--   each vertex to the next.
--   
- The second argument is a list of radii from the origin to
--   each successive vertex.
--   
--   
--   To construct an n-gon, use a list of n-1 angles and
--   n radii. Extra angles or radii are ignored.
--   
--   Cyclic polygons (with all vertices lying on a circle) can be
--   constructed using a second argument of (repeat r).
PolyPolar :: [Angle n] -> [n] -> PolyType n

-- | A polygon determined by the distance between successive vertices and
--   the external angles formed by each three successive vertices. In other
--   words, a polygon specified by "turtle graphics": go straight ahead x1
--   units; turn by external angle a1; go straight ahead x2 units; turn by
--   external angle a2; etc. The polygon will be centered at the
--   centroid of its vertices.
--   
--   
--   
- The first argument is a list of vertex angles,
--   giving the external angle at each vertex from the previous vertex to
--   the next. The first angle in the list is the external angle at the
--   second vertex; the first edge always starts out heading in the
--   positive y direction from the first vertex.
--   
- The second argument is a list of distances between successive
--   vertices.
--   
--   
--   To construct an n-gon, use a list of n-2 angles and
--   n-1 edge lengths. Extra angles or lengths are ignored.
PolySides :: [Angle n] -> [n] -> PolyType n

-- | A regular polygon with the given number of sides (first argument) and
--   the given radius (second argument).
PolyRegular :: Int -> n -> PolyType n

-- | Determine how a polygon should be oriented.
data PolyOrientation n

-- | No special orientation; the first vertex will be at (1,0). This is the
--   default.
NoOrient :: PolyOrientation n

-- | Orient horizontally, so the bottommost edge is parallel to the
--   x-axis.
OrientH :: PolyOrientation n

-- | Orient vertically, so the leftmost edge is parallel to the
--   y-axis.
OrientV :: PolyOrientation n

-- | Orient so some edge is facing in the
--   direction of, that is, perpendicular to, the given
--   vector.
OrientTo :: (V2 n) -> PolyOrientation n

-- | Options for specifying a polygon.
data PolygonOpts n
PolygonOpts :: PolyType n -> PolyOrientation n -> Point V2 n -> PolygonOpts n
[_polyType] :: PolygonOpts n -> PolyType n
[_polyOrient] :: PolygonOpts n -> PolyOrientation n
[_polyCenter] :: PolygonOpts n -> Point V2 n

-- | Specification for the polygon's vertices.
polyType :: Lens' (PolygonOpts n) (PolyType n)

-- | Should a rotation be applied to the polygon in order to orient it in a
--   particular way?
polyOrient :: Lens' (PolygonOpts n) (PolyOrientation n)

-- | Should a translation be applied to the polygon in order to place the
--   center at a particular location?
polyCenter :: Lens' (PolygonOpts n) (Point V2 n)

-- | Generate the polygon described by the given options.
polygon :: (InSpace V2 n t, TrailLike t, OrderedField n) => PolygonOpts n -> t

-- | Generate a polygon. See PolygonOpts for more information.
polyTrail :: OrderedField n => PolygonOpts n -> Located (Trail V2 n)

-- | Generate the located trail of a polygon specified by polar data
--   (central angles and radii). See PolyPolar.
polyPolarTrail :: OrderedField n => [Angle n] -> [n] -> Located (Trail V2 n)

-- | Generate the vertices of a polygon specified by side length and
--   angles, and a starting point for the trail such that the origin is at
--   the centroid of the vertices. See PolySides.
polySidesTrail :: OrderedField n => [Angle n] -> [n] -> Located (Trail V2 n)

-- | Generate the vertices of a regular polygon. See PolyRegular.
polyRegularTrail :: OrderedField n => Int -> n -> Located (Trail V2 n)

-- | Generate a transformation to orient a trail. orient v t
--   generates the smallest rotation such that one of the segments adjacent
--   to the vertex furthest in the direction of v is perpendicular
--   to v.
orient :: OrderedField n => V2 n -> Located (Trail V2 n) -> Transformation V2 n

-- | Options for creating "star" polygons, where the edges connect possibly
--   non-adjacent vertices.
data StarOpts

-- | Specify the order in which the vertices should be connected by a
--   function that maps each vertex index to the index of the vertex that
--   should come next. Indexing of vertices begins at 0.
StarFun :: (Int -> Int) -> StarOpts

-- | Specify a star polygon by a "skip". A skip of 1 indicates a normal
--   polygon, where edges go between successive vertices. A skip of 2 means
--   that edges will connect every second vertex, skipping one in between.
--   Generally, a skip of n means that edges will connect every
--   nth vertex.
StarSkip :: Int -> StarOpts

-- | Create a generalized star polygon. The StarOpts
--   are used to determine in which order the given vertices should be
--   connected. The intention is that the second argument of type
--   [Point v] could be generated by a call to polygon,
--   regPoly, or the like, since a list of vertices is
--   TrailLike. But of course the list can be generated any way you
--   like. A Path v is returned (instead of any
--   TrailLike) because the resulting path may have more than one
--   component, for example if the vertices are to be connected in several
--   disjoint cycles.
star :: OrderedField n => StarOpts -> [Point V2 n] -> Path V2 n

-- | Pieces of a function graph can either be cycles or "hairs".
data GraphPart a
Cycle :: [a] -> GraphPart a
Hair :: [a] -> GraphPart a

-- | orbits f n computes the graph of f on the integers
--   mod n.
orbits :: (Int -> Int) -> Int -> [GraphPart Int]

-- | Generate a function graph from the given function and labels.
mkGraph :: (Int -> Int) -> [a] -> [GraphPart a]
instance GHC.Base.Functor Diagrams.TwoD.Polygons.GraphPart
instance GHC.Show.Show a => GHC.Show.Show (Diagrams.TwoD.Polygons.GraphPart a)
instance GHC.Num.Num n => Data.Default.Class.Default (Diagrams.TwoD.Polygons.PolygonOpts n)
instance GHC.Read.Read n => GHC.Read.Read (Diagrams.TwoD.Polygons.PolyOrientation n)
instance GHC.Show.Show n => GHC.Show.Show (Diagrams.TwoD.Polygons.PolyOrientation n)
instance GHC.Classes.Ord n => GHC.Classes.Ord (Diagrams.TwoD.Polygons.PolyOrientation n)
instance GHC.Classes.Eq n => GHC.Classes.Eq (Diagrams.TwoD.Polygons.PolyOrientation n)

-- | Various two-dimensional shapes.
module Diagrams.TwoD.Shapes

-- | Create a centered horizontal (L-R) line of the given length.
--   
--   
--   
--   hruleEx = vcat' (with & sep .~ 0.2) (map hrule [1..5])
--           # centerXY # pad 1.1
--   
hrule :: (InSpace V2 n t, TrailLike t) => n -> t

-- | Create a centered vertical (T-B) line of the given length.
--   
--   
--   
--   vruleEx = hcat' (with & sep .~ 0.2) (map vrule [1, 1.2 .. 2])
--           # centerXY # pad 1.1
--   
vrule :: (InSpace V2 n t, TrailLike t) => n -> t

-- | Create a regular polygon. The first argument is the number of sides,
--   and the second is the length of the sides. (Compare to the
--   polygon function with a PolyRegular option, which
--   produces polygons of a given radius).
--   
--   The polygon will be oriented with one edge parallel to the x-axis.
regPoly :: (InSpace V2 n t, TrailLike t, OrderedField n) => Int -> n -> t

-- | An equilateral triangle, with sides of the given length and base
--   parallel to the x-axis.
--   
triangle :: (InSpace V2 n t, TrailLike t, OrderedField n) => n -> t

-- | A synonym for triangle, provided for backwards compatibility.
eqTriangle :: (InSpace V2 n t, TrailLike t, OrderedField n) => n -> t

-- | A square with its center at the origin and sides of the given length,
--   oriented parallel to the axes.
--   
square :: (InSpace V2 n t, TrailLike t, OrderedField n) => n -> t

-- | A regular pentagon, with sides of the given length and base parallel
--   to the x-axis.
--   
pentagon :: (InSpace V2 n t, TrailLike t, OrderedField n) => n -> t

-- | A regular hexagon, with sides of the given length and base parallel to
--   the x-axis.
--   
hexagon :: (InSpace V2 n t, TrailLike t, OrderedField n) => n -> t

-- | A regular heptagon, with sides of the given length and base parallel
--   to the x-axis.
--   
heptagon :: (InSpace V2 n t, TrailLike t, OrderedField n) => n -> t

-- | A synonym for heptagon. It is, however, completely inferior,
--   being a base admixture of the Latin septum (seven) and the
--   Greek γωνία (angle).
septagon :: (InSpace V2 n t, TrailLike t, OrderedField n) => n -> t

-- | A regular octagon, with sides of the given length and base parallel to
--   the x-axis.
--   
octagon :: (InSpace V2 n t, TrailLike t, OrderedField n) => n -> t

-- | A regular nonagon, with sides of the given length and base parallel to
--   the x-axis.
--   
nonagon :: (InSpace V2 n t, TrailLike t, OrderedField n) => n -> t

-- | A regular decagon, with sides of the given length and base parallel to
--   the x-axis.
--   
decagon :: (InSpace V2 n t, TrailLike t, OrderedField n) => n -> t

-- | A regular hendecagon, with sides of the given length and base parallel
--   to the x-axis.
--   
hendecagon :: (InSpace V2 n t, TrailLike t, OrderedField n) => n -> t

-- | A regular dodecagon, with sides of the given length and base parallel
--   to the x-axis.
--   
dodecagon :: (InSpace V2 n t, TrailLike t, OrderedField n) => n -> t

-- | A square with its center at the origin and sides of length 1, oriented
--   parallel to the axes.
--   
unitSquare :: (InSpace V2 n t, TrailLike t, OrderedField n) => t

-- | rect w h is an axis-aligned rectangle of width w and
--   height h, centered at the origin.
--   
rect :: (InSpace V2 n t, TrailLike t, OrderedField n) => n -> n -> t

-- | roundedRect w h r generates a closed trail, or closed path
--   centered at the origin, of an axis-aligned rectangle with width
--   w, height h, and circular rounded corners of radius
--   r. If r is negative the corner will be cut out in a
--   reverse arc. If the size of r is larger than half the smaller
--   dimension of w and h, then it will be reduced to fit
--   in that range, to prevent the corners from overlapping. The trail or
--   path begins with the right edge and proceeds counterclockwise. If you
--   need to specify a different radius for each corner individually, use
--   roundedRect' instead.
--   
--   
--   
--   roundedRectEx = pad 1.1 . centerXY $ hcat' (with & sep .~ 0.2)
--     [ roundedRect  0.5 0.4 0.1
--     , roundedRect  0.5 0.4 (-0.1)
--     , roundedRect' 0.7 0.4 (with & radiusTL .~ 0.2
--                                  & radiusTR .~ -0.2
--                                  & radiusBR .~ 0.1)
--     ]
--   
roundedRect :: (InSpace V2 n t, TrailLike t, RealFloat n) => n -> n -> n -> t
data RoundedRectOpts d
RoundedRectOpts :: d -> d -> d -> d -> RoundedRectOpts d
[_radiusTL] :: RoundedRectOpts d -> d
[_radiusTR] :: RoundedRectOpts d -> d
[_radiusBL] :: RoundedRectOpts d -> d
[_radiusBR] :: RoundedRectOpts d -> d
radiusTL :: Lens' (RoundedRectOpts d_a35SY) d_a35SY
radiusTR :: Lens' (RoundedRectOpts d_a35SY) d_a35SY
radiusBL :: Lens' (RoundedRectOpts d_a35SY) d_a35SY
radiusBR :: Lens' (RoundedRectOpts d_a35SY) d_a35SY

-- | roundedRect' works like roundedRect but allows you
--   to set the radius of each corner indivually, using
--   RoundedRectOpts. The default corner radius is 0. Each radius
--   can also be negative, which results in the curves being reversed to be
--   inward instead of outward.
roundedRect' :: (InSpace V2 n t, TrailLike t, RealFloat n) => n -> n -> RoundedRectOpts n -> t
instance GHC.Num.Num d => Data.Default.Class.Default (Diagrams.TwoD.Shapes.RoundedRectOpts d)

-- | Bounding boxes are not very compositional (e.g. it is not
--   possible to do anything sensible with them under rotation), so they
--   are not used in the diagrams core. However, they do have their uses;
--   this module provides definitions and functions for working with them.
module Diagrams.BoundingBox

-- | A bounding box is an axis-aligned region determined by two points
--   indicating its "lower" and "upper" corners. It can also represent an
--   empty bounding box - the points are wrapped in Maybe.
data BoundingBox v n

-- | An empty bounding box. This is the same thing as mempty, but
--   it doesn't require the same type constraints that the Monoid
--   instance does.
emptyBox :: BoundingBox v n

-- | Create a bounding box from a point that is component-wise
--   (<=) than the other. If this is not the case, then
--   mempty is returned.
fromCorners :: (Additive v, Foldable v, Ord n) => Point v n -> Point v n -> BoundingBox v n

-- | Create a degenerate bounding "box" containing only a single point.
fromPoint :: Point v n -> BoundingBox v n

-- | Create the smallest bounding box containing all the given points.
fromPoints :: (Additive v, Ord n) => [Point v n] -> BoundingBox v n

-- | Create a bounding box for any enveloped object (such as a diagram or
--   path).
boundingBox :: (InSpace v n a, HasBasis v, Num n, Enveloped a) => a -> BoundingBox v n

-- | Queries whether the BoundingBox is empty.
isEmptyBox :: BoundingBox v n -> Bool

-- | Gets the lower and upper corners that define the bounding box.
getCorners :: BoundingBox v n -> Maybe (Point v n, Point v n)

-- | Computes all of the corners of the bounding box.
getAllCorners :: (Additive v, Traversable v, Num n) => BoundingBox v n -> [Point v n]

-- | Get the size of the bounding box - the vector from the
--   (component-wise) lesser point to the greater point.
boxExtents :: (Additive v, Num n) => BoundingBox v n -> v n

-- | Get the center point in a bounding box.
boxCenter :: (Additive v, Fractional n) => BoundingBox v n -> Maybe (Point v n)

-- | Get the center of a the bounding box of an enveloped object, return
--   Nothing for object with empty envelope.
mCenterPoint :: (InSpace v n a, HasBasis v, Num n, Enveloped a) => a -> Maybe (Point v n)

-- | Get the center of a the bounding box of an enveloped object, return
--   the origin for object with empty envelope.
centerPoint :: (InSpace v n a, HasBasis v, Num n, Enveloped a) => a -> Point v n

-- | Create a transformation mapping points from one bounding box to the
--   other. Returns Nothing if either of the boxes are empty.
boxTransform :: (Additive v, Fractional n) => BoundingBox v n -> BoundingBox v n -> Maybe (Transformation v n)

-- | Transforms an enveloped thing to fit within a BoundingBox. If
--   the bounding box is empty, then the result is also mempty.
boxFit :: (InSpace v n a, HasBasis v, Enveloped a, Transformable a, Monoid a, Num n) => BoundingBox v n -> a -> a

-- | Check whether a point is contained in a bounding box (including its
--   edges).
contains :: (Additive v, Foldable v, Ord n) => BoundingBox v n -> Point v n -> Bool

-- | Check whether a point is strictly contained in a bounding box.
contains' :: (Additive v, Foldable v, Ord n) => BoundingBox v n -> Point v n -> Bool
boundingBoxQuery :: (Additive v, Foldable v, Ord n) => BoundingBox v n -> Query v n Any

-- | Test whether the first bounding box is contained inside the second.
inside :: (Additive v, Foldable v, Ord n) => BoundingBox v n -> BoundingBox v n -> Bool

-- | Test whether the first bounding box is strictly contained
--   inside the second.
inside' :: (Additive v, Foldable v, Ord n) => BoundingBox v n -> BoundingBox v n -> Bool

-- | Test whether the first bounding box lies outside the second (although
--   they may intersect in their boundaries).
outside :: (Additive v, Foldable v, Ord n) => BoundingBox v n -> BoundingBox v n -> Bool

-- | Test whether the first bounding box lies strictly outside the
--   second (they do not intersect at all).
outside' :: (Additive v, Foldable v, Ord n) => BoundingBox v n -> BoundingBox v n -> Bool

-- | Form the smallest bounding box containing the given two bound union.
--   This function is just an alias for mappend.
union :: (Additive v, Ord n) => BoundingBox v n -> BoundingBox v n -> BoundingBox v n

-- | Form the largest bounding box contained within this given two bounding
--   boxes, or Nothing if the two bounding boxes do not overlap at
--   all.
intersection :: (Additive v, Foldable v, Ord n) => BoundingBox v n -> BoundingBox v n -> BoundingBox v n
instance GHC.Base.Functor v => GHC.Base.Functor (Diagrams.BoundingBox.BoundingBox v)
instance GHC.Classes.Eq (v n) => GHC.Classes.Eq (Diagrams.BoundingBox.BoundingBox v n)
instance GHC.Base.Functor v => GHC.Base.Functor (Diagrams.BoundingBox.NonEmptyBoundingBox v)
instance GHC.Classes.Eq (v n) => GHC.Classes.Eq (Diagrams.BoundingBox.NonEmptyBoundingBox v n)
instance (Linear.Vector.Additive v, GHC.Classes.Ord n) => Data.Semigroup.Semigroup (Diagrams.BoundingBox.BoundingBox v n)
instance (Linear.Vector.Additive v, GHC.Classes.Ord n) => GHC.Base.Monoid (Diagrams.BoundingBox.BoundingBox v n)
instance (Linear.Vector.Additive v, GHC.Classes.Ord n) => Data.Semigroup.Semigroup (Diagrams.BoundingBox.NonEmptyBoundingBox v n)
instance Control.Lens.Empty.AsEmpty (Diagrams.BoundingBox.BoundingBox v n)
instance (Linear.Vector.Additive v', Data.Foldable.Foldable v', GHC.Classes.Ord n') => Control.Lens.Each.Each (Diagrams.BoundingBox.BoundingBox v n) (Diagrams.BoundingBox.BoundingBox v' n') (Linear.Affine.Point v n) (Linear.Affine.Point v' n')
instance (Linear.Vector.Additive v, GHC.Num.Num n, GHC.Classes.Ord n) => Diagrams.Core.HasOrigin.HasOrigin (Diagrams.BoundingBox.BoundingBox v n)
instance (Linear.Metric.Metric v, Data.Traversable.Traversable v, Diagrams.Core.Envelope.OrderedField n) => Diagrams.Core.Envelope.Enveloped (Diagrams.BoundingBox.BoundingBox v n)
instance GHC.Float.RealFloat n => Diagrams.Core.Trace.Traced (Diagrams.BoundingBox.BoundingBox Linear.V2.V2 n)
instance Diagrams.Core.Types.TypeableFloat n => Diagrams.Core.Trace.Traced (Diagrams.BoundingBox.BoundingBox Linear.V3.V3 n)
instance (Linear.Metric.Metric v, Data.Traversable.Traversable v, Diagrams.Core.Envelope.OrderedField n) => Diagrams.Align.Alignable (Diagrams.BoundingBox.BoundingBox v n)
instance GHC.Show.Show (v n) => GHC.Show.Show (Diagrams.BoundingBox.BoundingBox v n)
instance GHC.Read.Read (v n) => GHC.Read.Read (Diagrams.BoundingBox.BoundingBox v n)

-- | Utilities for working with sizes of objects.
module Diagrams.Size

-- | A SizeSpec is a way of specifying a size without needed lengths
--   for all the dimensions.
data SizeSpec v n

-- | Make a SizeSpec from a vector of maybe values. Any negative
--   values will be ignored. For 2D SizeSpecs see mkWidth
--   and mkHeight from Diagrams.TwoD.Size.
mkSizeSpec :: (Functor v, Num n) => v (Maybe n) -> SizeSpec v n

-- | Make a SizeSpec from a vector. Any negative values will be
--   ignored.
dims :: Functor v => v n -> SizeSpec v n

-- | A size spec with no hints to the size.
absolute :: (Additive v, Num n) => SizeSpec v n

-- | Retrieve a size spec as a vector of maybe values. Only positive sizes
--   are returned.
getSpec :: (Functor v, Num n, Ord n) => SizeSpec v n -> v (Maybe n)

-- | specToSize n spec extracts a size from a SizeSpec
--   sz. Any values not specified in the spec are replaced by the
--   smallest of the values that are specified. If there are no specified
--   values (i.e. absolute) then n is used.
specToSize :: (Foldable v, Functor v, Num n, Ord n) => n -> SizeSpec v n -> v n

-- | requiredScale spec sz returns the largest scaling factor to
--   make something of size sz fit the requested size
--   spec without changing the aspect ratio. sz should be
--   non-zero (otherwise a scale of 1 is returned). For non-uniform scaling
--   see boxFit.
requiredScale :: (Additive v, Foldable v, Fractional n, Ord n) => SizeSpec v n -> v n -> n

-- | Return the Transformation calcuated from requiredScale.
requiredScaling :: (Additive v, Foldable v, Fractional n, Ord n) => SizeSpec v n -> v n -> Transformation v n

-- | Uniformly scale any enveloped object so that it fits within the given
--   size. For non-uniform scaling see boxFit.
sized :: (InSpace v n a, HasLinearMap v, HasBasis v, Transformable a, Enveloped a, Fractional n, Ord n) => SizeSpec v n -> a -> a

-- | Uniformly scale an enveloped object so that it "has the same size as"
--   (fits within the width and height of) some other object.
sizedAs :: (InSpace v n a, SameSpace a b, HasLinearMap v, HasBasis v, Transformable a, Enveloped a, Enveloped b, Fractional n, Ord n) => b -> a -> a

-- | Get the adjustment to fit a BoundingBox in the given
--   SizeSpec. The vector is the new size and the transformation to
--   position the lower corner at the origin and scale to the size spec.
sizeAdjustment :: (Additive v, Foldable v, OrderedField n) => SizeSpec v n -> BoundingBox v n -> (v n, Transformation v n)
instance GHC.Generics.Constructor Diagrams.Size.C1_0SizeSpec
instance GHC.Generics.Datatype Diagrams.Size.D1SizeSpec
instance GHC.Show.Show (v n) => GHC.Show.Show (Diagrams.Size.SizeSpec v n)
instance Data.Hashable.Class.Hashable (v n) => Data.Hashable.Class.Hashable (Diagrams.Size.SizeSpec v n)
instance GHC.Generics.Generic (Diagrams.Size.SizeSpec v n)
instance GHC.Base.Functor v => GHC.Base.Functor (Diagrams.Size.SizeSpec v)

-- | Utilities for working with sizes of two-dimensional objects.
module Diagrams.TwoD.Size

-- | Compute the width of an enveloped object.
--   
--   Note this is just diameter unitX.
width :: (InSpace V2 n a, Enveloped a) => a -> n

-- | Compute the height of an enveloped object.
height :: (InSpace V2 n a, Enveloped a) => a -> n

-- | Compute the absolute x-coordinate range of an enveloped object in the
--   form (lo,hi). Return Nothing for objects with an
--   empty envelope.
--   
--   Note this is just extent unitX.
extentX :: (InSpace v n a, R1 v, Enveloped a) => a -> Maybe (n, n)

-- | Compute the absolute y-coordinate range of an enveloped object in the
--   form (lo,hi). Return Nothing for objects with an
--   empty envelope.
extentY :: (InSpace v n a, R2 v, Enveloped a) => a -> Maybe (n, n)

-- | Make a SizeSpec from possibly-specified width and height.
mkSizeSpec2D :: Num n => Maybe n -> Maybe n -> SizeSpec V2 n

-- | Make a SizeSpec with only width defined.
mkWidth :: Num n => n -> SizeSpec V2 n

-- | Make a SizeSpec with only height defined.
mkHeight :: Num n => n -> SizeSpec V2 n

-- | Make a SizeSpec from a width and height.
dims2D :: n -> n -> SizeSpec V2 n

-- | Utilities for working with sizes of three-dimensional objects.
module Diagrams.ThreeD.Size

-- | Compute the absolute x-coordinate range of an enveloped object in the
--   form (lo,hi). Return Nothing for objects with an
--   empty envelope.
--   
--   Note this is just extent unitX.
extentX :: (InSpace v n a, R1 v, Enveloped a) => a -> Maybe (n, n)

-- | Compute the absolute y-coordinate range of an enveloped object in the
--   form (lo,hi). Return Nothing for objects with an
--   empty envelope.
extentY :: (InSpace v n a, R2 v, Enveloped a) => a -> Maybe (n, n)

-- | Compute the absolute z-coordinate range of an enveloped object in the
--   form (lo,hi). Return Nothing for objects with an
--   empty envelope.
extentZ :: (InSpace v n a, R3 v, Enveloped a) => a -> Maybe (n, n)

-- | Make a SizeSpec from possibly-specified width and height.
mkSizeSpec3D :: Num n => Maybe n -> Maybe n -> Maybe n -> SizeSpec V3 n

-- | Make a SizeSpec from a width and height.
dims3D :: n -> n -> n -> SizeSpec V3 n

-- | An animation is a time-varying diagram, together with start and end
--   times. Most of the tools for working with animations can actually be
--   found in the active package, which defines the Active
--   type.
--   
--   XXX more documentation and examples should go here
module Diagrams.Animation

-- | A value of type QAnimation b v m is an animation (a
--   time-varying diagram with start and end times) that can be rendered by
--   backspace b, with vector space v and monoidal
--   annotations of type m.
type QAnimation b v n m = Active (QDiagram b v n m)

-- | A value of type Animation b v is an animation (a time-varying
--   diagram with start and end times) in vector space v that can
--   be rendered by backspace b.
--   
--   Note that Animation is actually a synonym for
--   QAnimation where the type of the monoidal annotations has
--   been fixed to Any (the default).
type Animation b v n = QAnimation b v n Any

-- | Automatically assign fixed a envelope to the entirety of an animation
--   by sampling the envelope at a number of points in time and taking the
--   union of all the sampled envelopes to form the "hull". This hull is
--   then used uniformly throughout the animation.
--   
--   This is useful when you have an animation that grows and shrinks in
--   size or shape over time, but you want it to take up a fixed amount of
--   space, e.g. so that the final rendered movie does not zoom in
--   and out, or so that it occupies a fixed location with respect to
--   another animation, when combining animations with something like
--   |||.
--   
--   By default, 30 samples per time unit are used; to adjust this number
--   see animEnvelope'.
--   
--   See also animRect for help constructing a background to go
--   behind an animation.
animEnvelope :: (Backend b v n, OrderedField n, Metric v, Monoid' m) => QAnimation b v n m -> QAnimation b v n m

-- | Like animEnvelope, but with an adjustible sample rate. The
--   first parameter is the number of samples per time unit to use. Lower
--   rates will be faster but less accurate; higher rates are more accurate
--   but slower.
animEnvelope' :: (Backend b v n, OrderedField n, Metric v, Monoid' m) => Rational -> QAnimation b v n m -> QAnimation b v n m

-- | animRect works similarly to animEnvelope for 2D
--   diagrams, but instead of adjusting the envelope, simply returns the
--   smallest bounding rectangle which encloses the entire animation.
--   Useful for e.g. creating a background to go behind an
--   animation.
--   
--   Uses 30 samples per time unit by default; to adjust this number see
--   animRect'.
animRect :: (InSpace V2 n t, Num n, Monoid' m, TrailLike t, Enveloped t, Transformable t, Monoid t) => QAnimation b V2 n m -> t

-- | Like animRect, but with an adjustible sample rate. The first
--   parameter is the number of samples per time unit to use. Lower rates
--   will be faster but less accurate; higher rates are more accurate but
--   slower.
animRect' :: (InSpace V2 n t, Num n, Monoid' m, TrailLike t, Enveloped t, Transformable t, Monoid t) => Rational -> QAnimation b V2 n m -> t

-- | Alignment combinators specialized for two dimensions. See
--   Diagrams.Align for more general alignment combinators.
--   
--   The basic idea is that alignment is achieved by moving diagrams' local
--   origins relative to their envelopes or traces (or some other sort of
--   boundary). For example, to align several diagrams along their tops, we
--   first move their local origins to the upper edge of their boundary
--   (using e.g. map alignTop), and then put them
--   together with their local origins along a horizontal line (using e.g.
--   hcat from Diagrams.TwoD.Combinators).
module Diagrams.TwoD.Align

-- | Align along the left edge, i.e. translate the diagram in a horizontal
--   direction so that the local origin is on the left edge of the
--   envelope.
alignL :: (InSpace V2 n a, Fractional n, Alignable a, HasOrigin a) => a -> a

-- | Align along the right edge.
alignR :: (InSpace V2 n a, Fractional n, Alignable a, HasOrigin a) => a -> a

-- | Align along the top edge.
alignT :: (InSpace V2 n a, Fractional n, Alignable a, HasOrigin a) => a -> a

-- | Align along the bottom edge.
alignB :: (InSpace V2 n a, Fractional n, Alignable a, HasOrigin a) => a -> a
alignTL :: (InSpace V2 n a, Fractional n, Alignable a, HasOrigin a) => a -> a
alignTR :: (InSpace V2 n a, Fractional n, Alignable a, HasOrigin a) => a -> a
alignBL :: (InSpace V2 n a, Fractional n, Alignable a, HasOrigin a) => a -> a
alignBR :: (InSpace V2 n a, Fractional n, Alignable a, HasOrigin a) => a -> a
snugL :: (InSpace V2 n a, Fractional n, Alignable a, Traced a, HasOrigin a) => a -> a
snugR :: (InSpace V2 n a, Fractional n, Alignable a, Traced a, HasOrigin a) => a -> a
snugT :: (InSpace V2 n a, Fractional n, Alignable a, Traced a, HasOrigin a) => a -> a
snugB :: (InSpace V2 n a, Fractional n, Alignable a, Traced a, HasOrigin a) => a -> a
snugTL :: (InSpace V2 n a, Fractional n, Alignable a, Traced a, HasOrigin a) => a -> a
snugTR :: (InSpace V2 n a, Fractional n, Alignable a, Traced a, HasOrigin a) => a -> a
snugBL :: (InSpace V2 n a, Fractional n, Alignable a, Traced a, HasOrigin a) => a -> a
snugBR :: (InSpace V2 n a, Fractional n, Alignable a, Traced a, HasOrigin a) => a -> a

-- | alignX and snugX move the local origin horizontally
--   as follows:
--   
--   
--   
- alignX (-1) moves the local origin to the left edge of
--   the boundary;
--   
- align 1 moves the local origin to the right edge;
--   
- any other argument interpolates linearly between these. For
--   example, alignX 0 centers, alignX 2 moves the origin
--   one "radius" to the right of the right edge, and so on.
--   
- snugX works the same way.
--   
alignX :: (InSpace v n a, R1 v, Fractional n, Alignable a, HasOrigin a) => n -> a -> a

-- | See the documentation for alignX.
snugX :: (InSpace v n a, R1 v, Fractional n, Alignable a, Traced a, HasOrigin a) => n -> a -> a

-- | Like alignX, but moving the local origin vertically, with an
--   argument of 1 corresponding to the top edge and (-1)
--   corresponding to the bottom edge.
alignY :: (InSpace v n a, R2 v, Fractional n, Alignable a, HasOrigin a) => n -> a -> a

-- | See the documentation for alignY.
snugY :: (InSpace v n a, R2 v, Fractional n, Alignable a, Traced a, HasOrigin a) => n -> a -> a

-- | Center the local origin along the X-axis.
centerX :: (InSpace v n a, R1 v, Fractional n, Alignable a, HasOrigin a) => a -> a

-- | Center the local origin along the Y-axis.
centerY :: (InSpace v n a, R2 v, Fractional n, Alignable a, HasOrigin a) => a -> a

-- | Center along both the X- and Y-axes.
centerXY :: (InSpace v n a, R2 v, Fractional n, Alignable a, HasOrigin a) => a -> a
snugCenterX :: (InSpace v n a, R1 v, Fractional n, Alignable a, Traced a, HasOrigin a) => a -> a
snugCenterY :: (InSpace v n a, R2 v, Fractional n, Alignable a, Traced a, HasOrigin a) => a -> a
snugCenterXY :: (InSpace v n a, R2 v, Fractional n, Alignable a, Traced a, HasOrigin a) => a -> a

-- | Alignment combinators specialized for three dimensions. See
--   Diagrams.Align for more general alignment combinators.
--   
--   The basic idea is that alignment is achieved by moving diagrams' local
--   origins relative to their envelopes or traces (or some other sort of
--   boundary). For example, to align several diagrams along their tops, we
--   first move their local origins to the upper edge of their boundary
--   (using e.g. map alignZMax), and then put them together
--   with their local origins along a line (using e.g. cat from
--   Diagrams.Combinators).
module Diagrams.ThreeD.Align

-- | Translate the diagram along unitX so that all points have positive
--   x-values.
alignXMin :: (InSpace v n a, R1 v, Fractional n, Alignable a, HasOrigin a) => a -> a

-- | Translate the diagram along unitX so that all points have negative
--   x-values.
alignXMax :: (InSpace v n a, R1 v, Fractional n, Alignable a, HasOrigin a) => a -> a

-- | Translate the diagram along unitY so that all points have positive
--   y-values.
alignYMin :: (InSpace v n a, R2 v, Fractional n, Alignable a, HasOrigin a) => a -> a

-- | Translate the diagram along unitY so that all points have negative
--   y-values.
alignYMax :: (InSpace v n a, R2 v, Fractional n, Alignable a, HasOrigin a) => a -> a

-- | Translate the diagram along unitZ so that all points have positive
--   z-values.
alignZMin :: (InSpace v n a, R3 v, Fractional n, Alignable a, HasOrigin a) => a -> a

-- | Translate the diagram along unitZ so that all points have negative
--   z-values.
alignZMax :: (InSpace v n a, R3 v, Fractional n, Alignable a, HasOrigin a) => a -> a
snugXMin :: (InSpace v n a, R1 v, Fractional n, Alignable a, HasOrigin a, Traced a) => a -> a
snugXMax :: (InSpace v n a, R1 v, Fractional n, Alignable a, HasOrigin a, Traced a) => a -> a
snugYMin :: (InSpace v n a, R2 v, Fractional n, Alignable a, HasOrigin a, Traced a) => a -> a
snugYMax :: (InSpace v n a, R2 v, Fractional n, Alignable a, HasOrigin a, Traced a) => a -> a
snugZMin :: (InSpace v n a, R3 v, Fractional n, Alignable a, HasOrigin a, Traced a) => a -> a
snugZMax :: (InSpace v n a, R3 v, Fractional n, Alignable a, HasOrigin a, Traced a) => a -> a

-- | alignX and snugX move the local origin horizontally
--   as follows:
--   
--   
--   
- alignX (-1) moves the local origin to the left edge of
--   the boundary;
--   
- align 1 moves the local origin to the right edge;
--   
- any other argument interpolates linearly between these. For
--   example, alignX 0 centers, alignX 2 moves the origin
--   one "radius" to the right of the right edge, and so on.
--   
- snugX works the same way.
--   
alignX :: (InSpace v n a, R1 v, Fractional n, Alignable a, HasOrigin a) => n -> a -> a

-- | See the documentation for alignX.
snugX :: (InSpace v n a, R1 v, Fractional n, Alignable a, Traced a, HasOrigin a) => n -> a -> a

-- | Like alignX, but moving the local origin vertically, with an
--   argument of 1 corresponding to the top edge and (-1)
--   corresponding to the bottom edge.
alignY :: (InSpace v n a, R2 v, Fractional n, Alignable a, HasOrigin a) => n -> a -> a

-- | See the documentation for alignY.
snugY :: (InSpace v n a, R2 v, Fractional n, Alignable a, Traced a, HasOrigin a) => n -> a -> a

-- | Like alignX, but moving the local origin in the Z direction,
--   with an argument of 1 corresponding to the top edge and
--   (-1) corresponding to the bottom edge.
alignZ :: (InSpace v n a, R3 v, Fractional n, Alignable a, HasOrigin a) => n -> a -> a

-- | See the documentation for alignZ.
snugZ :: (V a ~ v, N a ~ n, Alignable a, Traced a, HasOrigin a, R3 v, Additive v, Fractional n) => n -> a -> a

-- | Center the local origin along the X-axis.
centerX :: (InSpace v n a, R1 v, Fractional n, Alignable a, HasOrigin a) => a -> a

-- | Center the local origin along the Y-axis.
centerY :: (InSpace v n a, R2 v, Fractional n, Alignable a, HasOrigin a) => a -> a

-- | Center the local origin along the Z-axis.
centerZ :: (InSpace v n a, R3 v, Fractional n, Alignable a, HasOrigin a) => a -> a

-- | Center along both the X- and Y-axes.
centerXY :: (InSpace v n a, R2 v, Fractional n, Alignable a, HasOrigin a) => a -> a

-- | Center along both the X- and Z-axes.
centerXZ :: (InSpace v n a, R3 v, Fractional n, Alignable a, HasOrigin a) => a -> a

-- | Center along both the Y- and Z-axes.
centerYZ :: (InSpace v n a, R3 v, Fractional n, Alignable a, HasOrigin a) => a -> a

-- | Center an object in three dimensions.
centerXYZ :: (InSpace v n a, R3 v, Fractional n, Alignable a, HasOrigin a) => a -> a
snugCenterX :: (InSpace v n a, R1 v, Fractional n, Alignable a, Traced a, HasOrigin a) => a -> a
snugCenterY :: (InSpace v n a, R2 v, Fractional n, Alignable a, Traced a, HasOrigin a) => a -> a
snugCenterZ :: (InSpace v n a, R3 v, Fractional n, Alignable a, HasOrigin a, Traced a) => a -> a
snugCenterXY :: (InSpace v n a, R2 v, Fractional n, Alignable a, Traced a, HasOrigin a) => a -> a
snugCenterXZ :: (InSpace v n a, R3 v, Fractional n, Alignable a, HasOrigin a, Traced a) => a -> a
snugCenterYZ :: (InSpace v n a, R3 v, Fractional n, Alignable a, HasOrigin a, Traced a) => a -> a
snugCenterXYZ :: (InSpace v n a, R3 v, Fractional n, Alignable a, HasOrigin a, Traced a) => a -> a

-- | This module defines the three-dimensional vector space R^3,
--   three-dimensional transformations, and various predefined
--   three-dimensional shapes. This module re-exports useful functionality
--   from a group of more specific modules:
--   
--   
--   
- Diagrams.ThreeD.Types defines basic types for
--   two-dimensional diagrams, including types representing the 3D
--   Euclidean vector space and various systems of representing
--   directions.
--   
- Diagrams.ThreeD.Transform defines R^3-specific
--   transformations such as rotation by an angle, and scaling,
--   translation, and reflection in the X, Y, and Z directions.
--   Diagrams.ThreeD.Deform defines several R^3-specific non-affine
--   transformations, such as projections.
--   
- Diagrams.ThreeD.Shapes defines three-dimensional solids,
--   e.g. spheres and cubes.
--   
- Diagrams.ThreeD.Vector defines some special 3D vectors and
--   functions for converting between vectors and directions.
--   
- Diagrams.ThreeD.Light and Diagrams.ThreeD.Camera
--   define types needed for rendering 3D geometry to (2D) images.
--   
- Diagrams.ThreeD.Align defines many alignment combinators
--   specialized to three dimensions.
--   
- Diagrams.ThreeD.Attributes defines 3D-specific attributes
--   such as surface color, diffuse reflectance, and specular
--   highlights.
--   
module Diagrams.ThreeD

-- | Standard arrowheads and tails. Each arrowhead or tail is designed to
--   be drawn filled, with a line width of 0, and is normalized to fit
--   inside a circle of diameter 1.
module Diagrams.TwoD.Arrowheads

tri :: RealFloat n => ArrowHT n

dart :: RealFloat n => ArrowHT n

halfDart :: RealFloat n => ArrowHT n

spike :: RealFloat n => ArrowHT n

thorn :: RealFloat n => ArrowHT n

-- | A line the same width as the shaft.
lineHead :: RealFloat n => ArrowHT n
noHead :: (Floating n, Ord n) => ArrowHT n

-- | Isoceles triangle style. The above example specifies an angle of `2/5
--   Turn`.
--   
arrowheadTriangle :: RealFloat n => Angle n -> ArrowHT n

-- | Isoceles triangle with linear concave base. Inkscape type 1 - dart
--   like.
arrowheadDart :: RealFloat n => Angle n -> ArrowHT n

-- | Top half of an arrowheadDart.
arrowheadHalfDart :: RealFloat n => Angle n -> ArrowHT n

-- | Isoceles triangle with curved concave base. Inkscape type 2.
arrowheadSpike :: RealFloat n => Angle n -> ArrowHT n

-- | Curved sides, linear concave base. Illustrator CS5 #3
arrowheadThorn :: RealFloat n => Angle n -> ArrowHT n

tri' :: RealFloat n => ArrowHT n

dart' :: RealFloat n => ArrowHT n

halfDart' :: RealFloat n => ArrowHT n

spike' :: RealFloat n => ArrowHT n

thorn' :: RealFloat n => ArrowHT n

-- | A line the same width as the shaft.
lineTail :: RealFloat n => ArrowHT n
noTail :: OrderedField n => ArrowHT n

quill :: (Floating n, Ord n) => ArrowHT n

block :: RealFloat n => ArrowHT n

-- | The angle is where the top left corner intersects the circle.
arrowtailQuill :: OrderedField n => Angle n -> ArrowHT n
arrowtailBlock :: (RealFloat n) => Angle n -> ArrowHT n
type ArrowHT n = n -> n -> (Path V2 n, Path V2 n)

-- | Diagrams may have attributes which affect the way they are
--   rendered. This module defines some common attributes; particular
--   backends may also define more backend-specific attributes.
--   
--   Every attribute type must have a semigroup structure, that is,
--   an associative binary operation for combining two attributes into one.
--   Unless otherwise noted, all the attributes defined here use the
--   Last structure, that is, combining two attributes simply keeps
--   the second one and throws away the first. This means that child
--   attributes always override parent attributes.
module Diagrams.Attributes
ultraThin :: OrderedField n => Measure n
veryThin :: OrderedField n => Measure n
thin :: OrderedField n => Measure n
medium :: OrderedField n => Measure n
thick :: OrderedField n => Measure n
veryThick :: OrderedField n => Measure n
ultraThick :: OrderedField n => Measure n
none :: OrderedField n => Measure n
tiny :: OrderedField n => Measure n
verySmall :: OrderedField n => Measure n
small :: OrderedField n => Measure n
normal :: OrderedField n => Measure n
large :: OrderedField n => Measure n
veryLarge :: OrderedField n => Measure n
huge :: OrderedField n => Measure n

-- | Line widths specified on child nodes always override line widths
--   specified at parent nodes.
data LineWidth n
getLineWidth :: LineWidth n -> n
_LineWidth :: (Typeable n, OrderedField n) => Iso' (LineWidth n) n
_LineWidthM :: (Typeable n, OrderedField n) => Iso' (LineWidthM n) (Measure n)

-- | Set the line (stroke) width.
lineWidth :: (N a ~ n, HasStyle a, Typeable n) => Measure n -> a -> a

-- | Apply a LineWidth attribute.
lineWidthM :: (N a ~ n, HasStyle a, Typeable n) => LineWidthM n -> a -> a

-- | Lens onto a measured line width in a style.
_lineWidth :: (Typeable n, OrderedField n) => Lens' (Style v n) (Measure n)

-- | Lens onto a measured line width in a style.
_lw :: (Typeable n, OrderedField n) => Lens' (Style v n) (Measure n)

-- | Lens onto the unmeasured linewith attribute. This is useful for
--   backends to use on styles once they have been unmeasured. Using on a
--   diagram style could lead to unexpected results.
_lineWidthU :: (Typeable n, OrderedField n) => Lens' (Style v n) (Maybe n)

-- | Default for lineWidth.
lw :: (N a ~ n, HasStyle a, Typeable n) => Measure n -> a -> a

-- | A convenient synonym for 'lineWidth (normalized w)'.
lwN :: (N a ~ n, HasStyle a, Typeable n, Num n) => n -> a -> a

-- | A convenient synonym for 'lineWidth (output w)'.
lwO :: (N a ~ n, HasStyle a, Typeable n, Num n) => n -> a -> a

-- | A convenient sysnonym for 'lineWidth (local w)'.
lwL :: (N a ~ n, HasStyle a, Typeable n, Num n) => n -> a -> a

-- | A convenient synonym for 'lineWidth (global w)'.
lwG :: (N a ~ n, HasStyle a, Typeable n, Num n) => n -> a -> a

-- | Create lines that are dashing... er, dashed.
data Dashing n
Dashing :: [n] -> n -> Dashing n
getDashing :: Dashing n -> Dashing n

-- | Set the line dashing style.
dashing :: (N a ~ n, HasStyle a, Typeable n) => [Measure n] -> Measure n -> a -> a

-- | A convenient synonym for 'dashing (normalized w)'.
dashingN :: (N a ~ n, HasStyle a, Typeable n, Num n) => [n] -> n -> a -> a

-- | A convenient synonym for 'dashing (output w)'.
dashingO :: (N a ~ n, HasStyle a, Typeable n, Num n) => [n] -> n -> a -> a

-- | A convenient sysnonym for 'dashing (local w)'.
dashingL :: (N a ~ n, HasStyle a, Typeable n, Num n) => [n] -> n -> a -> a

-- | A convenient synonym for 'dashing (global w)'.
dashingG :: (N a ~ n, HasStyle a, Typeable n, Num n) => [n] -> n -> a -> a

-- | Lens onto a measured dashing attribute in a style.
_dashing :: (Typeable n, OrderedField n) => Lens' (Style v n) (Maybe (Measured n (Dashing n)))

-- | Lens onto the unmeasured Dashing attribute. This is useful for
--   backends to use on styles once they have been unmeasured. Using on a
--   diagram style could lead to unexpected results.
_dashingU :: (Typeable n, OrderedField n) => Lens' (Style v n) (Maybe (Dashing n))

-- | The Color type class encompasses color representations which
--   can be used by the Diagrams library. Instances are provided for both
--   the Colour and AlphaColour types from the
--   Data.Colour library.
class Color c

-- | Convert a color to its standard representation, AlphaColour.
toAlphaColour :: Color c => c -> AlphaColour Double

-- | Convert from an AlphaColour Double. Note that this direction may lose
--   some information. For example, the instance for Colour drops
--   the alpha channel.
fromAlphaColour :: Color c => AlphaColour Double -> c

-- | An existential wrapper for instances of the Color class.
data SomeColor
SomeColor :: c -> SomeColor

-- | Isomorphism between SomeColor and AlphaColour
--   Double.
_SomeColor :: Iso' SomeColor (AlphaColour Double)
someToAlpha :: SomeColor -> AlphaColour Double

-- | Although the individual colors in a diagram can have transparency, the
--   opacity/transparency of a diagram as a whole can be specified with the
--   Opacity attribute. The opacity is a value between 1
--   (completely opaque, the default) and 0 (completely transparent).
--   Opacity is multiplicative, that is, opacity o1 .
--   opacity o2 === opacity (o1 * o2). In other words,
--   for example, opacity 0.8 means "decrease this diagram's
--   opacity to 80% of its previous opacity".
data Opacity
_Opacity :: Iso' Opacity Double
getOpacity :: Opacity -> Double

-- | Multiply the opacity (see Opacity) by the given value. For
--   example, opacity 0.8 means "decrease this diagram's opacity
--   to 80% of its previous opacity".
opacity :: HasStyle a => Double -> a -> a

-- | Lens onto the opacity in a style.
_opacity :: Lens' (Style v n) Double

-- | Convert to sRGBA.
colorToSRGBA :: Color c => c -> (Double, Double, Double, Double)

-- | Convert to sRGBA.

-- | Deprecated: Renamed to colorToSRGBA.
colorToRGBA :: Color c => c -> (Double, Double, Double, Double)

-- | What sort of shape should be placed at the endpoints of lines?
data LineCap

-- | Lines end precisely at their endpoints.
LineCapButt :: LineCap

-- | Lines are capped with semicircles centered on endpoints.
LineCapRound :: LineCap

-- | Lines are capped with a squares centered on endpoints.
LineCapSquare :: LineCap
getLineCap :: LineCap -> LineCap

-- | Set the line end cap attribute.
lineCap :: HasStyle a => LineCap -> a -> a

-- | Lens onto the line cap in a style.
_lineCap :: Lens' (Style v n) LineCap

-- | How should the join points between line segments be drawn?
data LineJoin

-- | Use a "miter" shape (whatever that is).
LineJoinMiter :: LineJoin

-- | Use rounded join points.
LineJoinRound :: LineJoin

-- | Use a "bevel" shape (whatever that is). Are these... carpentry terms?
LineJoinBevel :: LineJoin
getLineJoin :: LineJoin -> LineJoin

-- | Set the segment join style.
lineJoin :: HasStyle a => LineJoin -> a -> a

-- | Lens onto the line join type in a style.
_lineJoin :: Lens' (Style v n) LineJoin

-- | Miter limit attribute affecting the LineJoinMiter joins. For
--   some backends this value may have additional effects.
newtype LineMiterLimit
LineMiterLimit :: (Last Double) -> LineMiterLimit
_LineMiterLimit :: Iso' LineMiterLimit Double
getLineMiterLimit :: LineMiterLimit -> Double

-- | Set the miter limit for joins with LineJoinMiter.
lineMiterLimit :: HasStyle a => Double -> a -> a

-- | Apply a LineMiterLimit attribute.
lineMiterLimitA :: HasStyle a => LineMiterLimit -> a -> a

-- | Lens onto the line miter limit in a style.
_lineMiterLimit :: Lens' (Style v n) Double

-- | Prism onto a Recommend.
_Recommend :: Prism' (Recommend a) a

-- | Prism onto a Commit.
_Commit :: Prism' (Recommend a) a

-- | Lens onto the value inside either a Recommend or Commit.
--   Unlike committed, this is a valid lens.
_recommend :: Lens (Recommend a) (Recommend b) a b

-- | Lens onto whether something is committed or not.
isCommitted :: Lens' (Recommend a) Bool

-- | Commit a value for any Recommend. This is *not* a valid
--   Iso because the resulting Recommend b is always a
--   Commit. This is useful because it means any Recommend
--   styles set with a lens will not be accidentally overridden. If you
--   want a valid lens onto a recommend value use _recommend.
--   
--   Other lenses that use this are labeled with a warning.
committed :: Iso (Recommend a) (Recommend b) a b
instance GHC.Classes.Ord Diagrams.Attributes.LineMiterLimit
instance GHC.Classes.Eq Diagrams.Attributes.LineMiterLimit
instance Data.Semigroup.Semigroup Diagrams.Attributes.LineMiterLimit
instance GHC.Show.Show Diagrams.Attributes.LineJoin
instance GHC.Classes.Ord Diagrams.Attributes.LineJoin
instance GHC.Classes.Eq Diagrams.Attributes.LineJoin
instance GHC.Show.Show Diagrams.Attributes.LineCap
instance GHC.Classes.Ord Diagrams.Attributes.LineCap
instance GHC.Classes.Eq Diagrams.Attributes.LineCap
instance Data.Semigroup.Semigroup Diagrams.Attributes.Opacity
instance GHC.Classes.Eq n => GHC.Classes.Eq (Diagrams.Attributes.Dashing n)
instance GHC.Base.Functor Diagrams.Attributes.Dashing
instance Data.Semigroup.Semigroup (Diagrams.Attributes.LineWidth n)
instance Data.Typeable.Internal.Typeable n => Diagrams.Core.Style.AttributeClass (Diagrams.Attributes.LineWidth n)
instance Diagrams.Core.Envelope.OrderedField n => Data.Default.Class.Default (Diagrams.Attributes.LineWidthM n)
instance Data.Semigroup.Semigroup (Diagrams.Attributes.Dashing n)
instance Data.Typeable.Internal.Typeable n => Diagrams.Core.Style.AttributeClass (Diagrams.Attributes.Dashing n)
instance GHC.Show.Show Diagrams.Attributes.SomeColor
instance (a ~ GHC.Types.Double) => Diagrams.Attributes.Color (Data.Colour.Internal.Colour a)
instance (a ~ GHC.Types.Double) => Diagrams.Attributes.Color (Data.Colour.Internal.AlphaColour a)
instance Diagrams.Attributes.Color Diagrams.Attributes.SomeColor
instance Diagrams.Core.Style.AttributeClass Diagrams.Attributes.Opacity
instance Data.Default.Class.Default Diagrams.Attributes.LineCap
instance Diagrams.Core.Style.AttributeClass Diagrams.Attributes.LineCap
instance Data.Semigroup.Semigroup Diagrams.Attributes.LineCap
instance Diagrams.Core.Style.AttributeClass Diagrams.Attributes.LineJoin
instance Data.Semigroup.Semigroup Diagrams.Attributes.LineJoin
instance Data.Default.Class.Default Diagrams.Attributes.LineJoin
instance Diagrams.Core.Style.AttributeClass Diagrams.Attributes.LineMiterLimit
instance Data.Default.Class.Default Diagrams.Attributes.LineMiterLimit

-- | Convenient creation of command-line-driven executables for rendering
--   diagrams. This module provides a general framework and default
--   behaviors for parsing command-line arguments, records for diagram
--   creation options in various forms, and classes and instances for a
--   unified entry point to command-line-driven diagram creation
--   executables.
--   
--   For a tutorial on command-line diagram creation see
--   http://projects.haskell.org/diagrams/doc/cmdline.html.
module Diagrams.Backend.CmdLine

-- | Standard options most diagrams are likely to have.
data DiagramOpts
DiagramOpts :: Maybe Int -> Maybe Int -> FilePath -> DiagramOpts

-- | Final output width of diagram.
[_width] :: DiagramOpts -> Maybe Int

-- | Final output height of diagram.
[_height] :: DiagramOpts -> Maybe Int

-- | Output file path, format is typically chosen by extension.
[_output] :: DiagramOpts -> FilePath

-- | Command line parser for DiagramOpts. Width is option
--   --width or -w. Height is option --height or
--   -h (note we change help to be -? due to this).
--   Output is option --output or -o.
diagramOpts :: Parser DiagramOpts
width :: Lens' DiagramOpts (Maybe Int)
height :: Lens' DiagramOpts (Maybe Int)
output :: Lens' DiagramOpts FilePath

-- | Extra options for a program that can offer a choice between multiple
--   diagrams.
data DiagramMultiOpts
DiagramMultiOpts :: Maybe String -> Bool -> DiagramMultiOpts

-- | Selected diagram to render.
[_selection] :: DiagramMultiOpts -> Maybe String

-- | Flag to indicate that a list of available diagrams should be printed
--   to standard out.
[_list] :: DiagramMultiOpts -> Bool

-- | Command line parser for DiagramMultiOpts. Selection is option
--   --selection or -S. List is --list or
--   -L.
diagramMultiOpts :: Parser DiagramMultiOpts
selection :: Lens' DiagramMultiOpts (Maybe String)
list :: Lens' DiagramMultiOpts Bool

-- | Extra options for animations.
data DiagramAnimOpts
DiagramAnimOpts :: Double -> DiagramAnimOpts

-- | Number of frames per unit time to generate for the animation.
[_fpu] :: DiagramAnimOpts -> Double

-- | Command line parser for DiagramAnimOpts Frames per unit is
--   --fpu or -f.
diagramAnimOpts :: Parser DiagramAnimOpts
fpu :: Iso' DiagramAnimOpts Double

-- | Extra options for command-line looping.
data DiagramLoopOpts
DiagramLoopOpts :: Bool -> Maybe FilePath -> Int -> DiagramLoopOpts

-- | Flag to indicate that the program should loop creation.
[_loop] :: DiagramLoopOpts -> Bool

-- | File path for the source file to recompile.
[_src] :: DiagramLoopOpts -> Maybe FilePath

-- | Interval in seconds at which to check for recompilation.
[_interval] :: DiagramLoopOpts -> Int

-- | CommandLine parser for DiagramLoopOpts Loop is --loop
--   or -l. Source is --src or -s. Interval is
--   -i defaulting to one second.
diagramLoopOpts :: Parser DiagramLoopOpts
loop :: Lens' DiagramLoopOpts Bool
src :: Lens' DiagramLoopOpts (Maybe FilePath)
interval :: Lens' DiagramLoopOpts Int

-- | Parseable instances give a command line parser for a type. If a custom
--   parser for a common type is wanted a newtype wrapper could be used to
--   make a new Parseable instance. Notice that we do not
--   want as many instances as Read because we want to limit
--   ourselves to things that make sense to parse from the command line.
class Parseable a
parser :: Parseable a => Parser a

-- | Parses a hexadecimal color. The string can start with "0x" or
--   "#" or just be a string of hexadecimal values. If four or
--   three digits are given each digit is repeated to form a full 24 or 32
--   bit color. For example, "0xfc4" is the same as
--   "0xffcc44". When eight or six digits are given each pair of
--   digits is a color or alpha channel with the order being red, green,
--   blue, alpha.
readHexColor :: (Applicative m, Monad m) => String -> m (AlphaColour Double)

-- | This class represents the various ways we want to support diagram
--   creation from the command line. It has the right instances to select
--   between creating single static diagrams, multiple static diagrams,
--   static animations, and functions that produce diagrams as long as the
--   arguments are Parseable.
--   
--   Backends are expected to create Mainable instances for the
--   types that are suitable for generating output in the backend's format.
--   For instance, Postscript can handle single diagrams, pages of
--   diagrams, animations as separate files, and association lists. This
--   implies instances for Diagram Postscript R2, [Diagram
--   Postscript R2], Animation Postscript R2, and
--   [(String,Diagram Postscript R2)]. We can consider these as
--   the base cases for the function instance.
--   
--   The associated type MainOpts describes the options which need
--   to be parsed from the command-line and passed to mainRender.
class Mainable d where type family MainOpts d :: * mainArgs _ = defaultOpts parser mainWith d = do { opts <- mainArgs d; mainRender opts d }

-- | This method invokes the command-line parser resulting in an options
--   value or ending the program with an error or help message. Typically
--   the default instance will work. If a different help message or parsing
--   behavior is desired a new implementation is appropriate.
--   
--   Note the d argument should only be needed to fix the type
--   d. Its value should not be relied on as a parameter.
mainArgs :: (Mainable d, Parseable (MainOpts d)) => d -> IO (MainOpts d)

-- | Backend specific work of rendering with the given options and mainable
--   value is done here. All backend instances should implement this
--   method.
mainRender :: Mainable d => MainOpts d -> d -> IO ()

-- | Main entry point for command-line diagram creation. This is the method
--   that users will call from their program main. For instance an
--   expected user program would take the following form.
--   
--   
--   import Diagrams.Prelude
--   import Diagrams.Backend.TheBestBackend.CmdLine
--   
--   d :: Diagram B R2
--   d = ...
--   
--   main = mainWith d
--   
--   
--   Most backends should be able to use the default implementation. A
--   different implementation should be used to handle more complex
--   interactions with the user.
mainWith :: (Mainable d, Parseable (MainOpts d)) => d -> IO ()

-- | This class allows us to abstract over functions that take some
--   arguments and produce a final value. When some d is an
--   instance of ToResult we get a type Args d that
--   is a type of all the arguments at once, and a type
--   ResultOf d that is the type of the final result from
--   some base case instance.
class ToResult d where type family Args d :: * type family ResultOf d :: *
toResult :: ToResult d => d -> Args d -> ResultOf d

-- | defaultAnimMainRender is an implementation of
--   mainRender which renders an animation as numbered frames, named
--   by extending the given output file name by consecutive integers. For
--   example if the given output file name is foo/blah.ext, the
--   frames will be saved in foo/blah001.ext,
--   foo/blah002.ext, and so on (the number of padding digits used
--   depends on the total number of frames). It is up to the user to take
--   these images and stitch them together into an actual animation format
--   (using, e.g. ffmpeg).
--   
--   Of course, this is a rather crude method of rendering animations; more
--   sophisticated methods will likely be added in the future.
--   
--   The fpu option from DiagramAnimOpts can be used to
--   control how many frames will be output for each second (unit time) of
--   animation.
--   
--   This function requires a lens into the structure that the particular
--   backend uses for it's diagram base case. If MainOpts (QDiagram b v
--   n Any) ~ DiagramOpts then this lens will simply be output.
--   For a backend supporting looping it will most likely be _1 .
--   output. This lens is required because the implementation works by
--   modifying the output field and running the base mainRender.
--   Typically a backend can write its Animation B V instance as
--   
--   
--   instance Mainable (Animation B V) where
--       type MainOpts (Animation B V) = (DiagramOpts, DiagramAnimOpts)
--       mainRender = defaultAnimMainRender output
--   
--   
--   
--   We do not provide this instance in general so that backends can choose
--   to opt-in to this form or provide a different instance that makes more
--   sense.
defaultAnimMainRender :: (opts -> QDiagram b v n Any -> IO ()) -> Lens' opts FilePath -> (opts, DiagramAnimOpts) -> Animation b v n -> IO ()

-- | defaultMultiMainRender is an implementation of
--   mainRender where instead of a single diagram it takes a list of
--   diagrams paired with names as input. The generated executable then
--   takes a --selection option specifying the name of the diagram
--   that should be rendered. The list of available diagrams may also be
--   printed by passing the option --list.
--   
--   Typically a backend can write its [(String,QDiagram b v n
--   Any)] instance as
--   
--   
--   instance Mainable [(String,QDiagram b v n Any)] where
--       type MainOpts [(String,QDiagram b v n Any)] = (DiagramOpts, DiagramMultiOpts)
--       mainRender = defaultMultiMainRender
--   
--   
--   
--   We do not provide this instance in general so that backends can choose
--   to opt-in to this form or provide a different instance that makes more
--   sense.
defaultMultiMainRender :: Mainable d => (MainOpts d, DiagramMultiOpts) -> [(String, d)] -> IO ()
defaultLoopRender :: DiagramLoopOpts -> IO ()
instance Diagrams.Backend.CmdLine.Parseable GHC.Types.Int
instance Diagrams.Backend.CmdLine.Parseable GHC.Types.Double
instance Diagrams.Backend.CmdLine.Parseable GHC.Base.String
instance Diagrams.Backend.CmdLine.Parseable Diagrams.Backend.CmdLine.DiagramOpts
instance Diagrams.Backend.CmdLine.Parseable Diagrams.Backend.CmdLine.DiagramMultiOpts
instance Diagrams.Backend.CmdLine.Parseable Diagrams.Backend.CmdLine.DiagramAnimOpts
instance Diagrams.Backend.CmdLine.Parseable Diagrams.Backend.CmdLine.DiagramLoopOpts
instance Diagrams.Backend.CmdLine.Parseable (Data.Colour.Internal.Colour GHC.Types.Double)
instance Diagrams.Backend.CmdLine.Parseable (Data.Colour.Internal.AlphaColour GHC.Types.Double)
instance Diagrams.Backend.CmdLine.Parseable ()
instance (Diagrams.Backend.CmdLine.Parseable a, Diagrams.Backend.CmdLine.Parseable b) => Diagrams.Backend.CmdLine.Parseable (a, b)
instance (Diagrams.Backend.CmdLine.Parseable a, Diagrams.Backend.CmdLine.Parseable b, Diagrams.Backend.CmdLine.Parseable c) => Diagrams.Backend.CmdLine.Parseable (a, b, c)
instance (Diagrams.Backend.CmdLine.Parseable a, Diagrams.Backend.CmdLine.Parseable b, Diagrams.Backend.CmdLine.Parseable c, Diagrams.Backend.CmdLine.Parseable d) => Diagrams.Backend.CmdLine.Parseable (a, b, c, d)
instance Diagrams.Backend.CmdLine.ToResult (Diagrams.Core.Types.QDiagram b v n Data.Monoid.Any)
instance Diagrams.Backend.CmdLine.ToResult [Diagrams.Core.Types.QDiagram b v n Data.Monoid.Any]
instance Diagrams.Backend.CmdLine.ToResult [(GHC.Base.String, Diagrams.Core.Types.QDiagram b v n Data.Monoid.Any)]
instance Diagrams.Backend.CmdLine.ToResult (Diagrams.Animation.Animation b v n)
instance Diagrams.Backend.CmdLine.ToResult d => Diagrams.Backend.CmdLine.ToResult (GHC.Types.IO d)
instance Diagrams.Backend.CmdLine.ToResult d => Diagrams.Backend.CmdLine.ToResult (a -> d)
instance (Diagrams.Backend.CmdLine.Parseable (Diagrams.Backend.CmdLine.Args (a -> d)), Diagrams.Backend.CmdLine.ToResult d, Diagrams.Backend.CmdLine.Mainable (Diagrams.Backend.CmdLine.ResultOf d)) => Diagrams.Backend.CmdLine.Mainable (a -> d)
instance Diagrams.Backend.CmdLine.Mainable d => Diagrams.Backend.CmdLine.Mainable (GHC.Types.IO d)
instance Data.Data.Data Diagrams.Backend.CmdLine.DiagramAnimOpts
instance GHC.Show.Show Diagrams.Backend.CmdLine.DiagramAnimOpts
instance Data.Data.Data Diagrams.Backend.CmdLine.DiagramMultiOpts
instance GHC.Show.Show Diagrams.Backend.CmdLine.DiagramMultiOpts
instance Data.Data.Data Diagrams.Backend.CmdLine.DiagramOpts
instance GHC.Show.Show Diagrams.Backend.CmdLine.DiagramOpts

-- | Diagrams may have attributes which affect the way they are
--   rendered. This module defines Textures (Gradients and Colors)
--   in two dimensions. Like the attributes defined in the
--   Diagrams.Attributes module, all attributes defined here use the
--   Last or Recommend semigroup structure.
--   FillColor and LineColor attributes are provided so
--   that backends that don't support gradients need not be concerned with
--   using textures. Backends should only implement color attributes or
--   textures attributes, not both.
module Diagrams.TwoD.Attributes

-- | A Texture is either a color SC, linear gradient LG, or
--   radial gradient RG. An object can have only one texture which
--   is determined by the Last semigroup structure.
data Texture n
SC :: SomeColor -> Texture n
LG :: (LGradient n) -> Texture n
RG :: (RGradient n) -> Texture n

-- | Convert a solid colour into a texture.
solid :: Color a => a -> Texture n
_SC :: Prism' (Texture n_a46yH) SomeColor

-- | Prism onto an AlphaColour Double of a SC texture.
_AC :: Prism' (Texture n) (AlphaColour Double)
_LG :: Prism' (Texture n_a46yH) (LGradient n_a46yH)
_RG :: Prism' (Texture n_a46yH) (RGradient n_a46yH)

-- | A default is provided so that linear gradients can easily be created
--   using lenses. For example, lg = defaultLG & lGradStart .~
--   (0.25 ^& 0.33). Note that no default value is provided for
--   lGradStops, this must be set before the gradient value is
--   used, otherwise the object will appear transparent.
defaultLG :: Fractional n => Texture n

-- | A default is provided so that radial gradients can easily be created
--   using lenses. For example, rg = defaultRG & rGradRadius1 .~
--   0.25. Note that no default value is provided for
--   rGradStops, this must be set before the gradient value is
--   used, otherwise the object will appear transparent.
defaultRG :: Fractional n => Texture n

-- | A gradient stop contains a color and fraction (usually between 0 and
--   1)
data GradientStop d
GradientStop :: SomeColor -> d -> GradientStop d
[_stopColor] :: GradientStop d -> SomeColor
[_stopFraction] :: GradientStop d -> d

-- | A color for the stop.
stopColor :: Lens' (GradientStop n) SomeColor

-- | The fraction for stop.
stopFraction :: Lens' (GradientStop n) n

-- | A convenient function for making gradient stops from a list of
--   triples. (An opaque color, a stop fraction, an opacity).
mkStops :: [(Colour Double, d, Double)] -> [GradientStop d]

-- | The SpreadMethod determines what happens before
--   lGradStart and after lGradEnd. GradPad fills the
--   space before the start of the gradient with the color of the first
--   stop and the color after end of the gradient with the color of the
--   last stop. GradRepeat restarts the gradient and
--   GradReflect restarts the gradient with the stops in reverse
--   order.
data SpreadMethod
GradPad :: SpreadMethod
GradReflect :: SpreadMethod
GradRepeat :: SpreadMethod

-- | Apply a linear gradient.
lineLGradient :: (InSpace V2 n a, Typeable n, Floating n, HasStyle a) => LGradient n -> a -> a

-- | Apply a radial gradient.
lineRGradient :: (InSpace V2 n a, Typeable n, Floating n, HasStyle a) => RGradient n -> a -> a

-- | Linear Gradient
data LGradient n
LGradient :: [GradientStop n] -> Point V2 n -> Point V2 n -> Transformation V2 n -> SpreadMethod -> LGradient n
[_lGradStops] :: LGradient n -> [GradientStop n]
[_lGradStart] :: LGradient n -> Point V2 n
[_lGradEnd] :: LGradient n -> Point V2 n
[_lGradTrans] :: LGradient n -> Transformation V2 n
[_lGradSpreadMethod] :: LGradient n -> SpreadMethod

-- | A list of stops (colors and fractions).
lGradStops :: Lens' (LGradient n) [GradientStop n]

-- | A transformation to be applied to the gradient. Usually this field
--   will start as the identity transform and capture the transforms that
--   are applied to the gradient.
lGradTrans :: Lens' (LGradient n) (Transformation V2 n)

-- | The starting point for the first gradient stop. The coordinates are in
--   local units and the default is (-0.5, 0).
lGradStart :: Lens' (LGradient n) (Point V2 n)

-- | The ending point for the last gradient stop.The coordinates are in
--   local units and the default is (0.5, 0).
lGradEnd :: Lens' (LGradient n) (Point V2 n)

-- | For setting the spread method.
lGradSpreadMethod :: Lens' (LGradient n) SpreadMethod

-- | Make a linear gradient texture from a stop list, start point, end
--   point, and SpreadMethod. The lGradTrans field is set to
--   the identity transfrom, to change it use the lGradTrans lens.
mkLinearGradient :: Num n => [GradientStop n] -> Point V2 n -> Point V2 n -> SpreadMethod -> Texture n

-- | Radial Gradient
data RGradient n
RGradient :: [GradientStop n] -> Point V2 n -> n -> Point V2 n -> n -> Transformation V2 n -> SpreadMethod -> RGradient n
[_rGradStops] :: RGradient n -> [GradientStop n]
[_rGradCenter0] :: RGradient n -> Point V2 n
[_rGradRadius0] :: RGradient n -> n
[_rGradCenter1] :: RGradient n -> Point V2 n
[_rGradRadius1] :: RGradient n -> n
[_rGradTrans] :: RGradient n -> Transformation V2 n
[_rGradSpreadMethod] :: RGradient n -> SpreadMethod

-- | A list of stops (colors and fractions).
rGradStops :: Lens' (RGradient n) [GradientStop n]

-- | A transformation to be applied to the gradient. Usually this field
--   will start as the identity transform and capture the transforms that
--   are applied to the gradient.
rGradTrans :: Lens' (RGradient n) (Transformation V2 n)

-- | The center point of the inner circle.
rGradCenter0 :: Lens' (RGradient n) (Point V2 n)

-- | The radius of the inner cirlce in local coordinates.
rGradRadius0 :: Lens' (RGradient n) n

-- | The center of the outer circle.
rGradCenter1 :: Lens' (RGradient n) (Point V2 n)

-- | The radius of the outer circle in local coordinates.
rGradRadius1 :: Lens' (RGradient n) n

-- | For setting the spread method.
rGradSpreadMethod :: Lens' (RGradient n) SpreadMethod

-- | Make a radial gradient texture from a stop list, radius, start point,
--   end point, and SpreadMethod. The rGradTrans field is set
--   to the identity transfrom, to change it use the rGradTrans
--   lens.
mkRadialGradient :: Num n => [GradientStop n] -> Point V2 n -> n -> Point V2 n -> n -> SpreadMethod -> Texture n

-- | The texture with which lines are drawn. Note that child textures
--   always override parent textures. More precisely, the semigroup
--   structure on line texture attributes is that of Last.
newtype LineTexture n
LineTexture :: (Last (Texture n)) -> LineTexture n
_LineTexture :: Iso (LineTexture n) (LineTexture n') (Texture n) (Texture n')
getLineTexture :: LineTexture n -> Texture n
lineTexture :: (InSpace V2 n a, Typeable n, Floating n, HasStyle a) => Texture n -> a -> a
lineTextureA :: (InSpace V2 n a, Typeable n, Floating n, HasStyle a) => LineTexture n -> a -> a
mkLineTexture :: Texture n -> LineTexture n
_lineTexture :: (Floating n, Typeable n) => Lens' (Style V2 n) (Texture n)

-- | Set the line (stroke) color. This function is polymorphic in the color
--   type (so it can be used with either Colour or
--   AlphaColour), but this can sometimes create problems for type
--   inference, so the lc and lcA variants are provided with
--   more concrete types.
lineColor :: (InSpace V2 n a, Color c, Typeable n, Floating n, HasStyle a) => c -> a -> a

-- | A synonym for lineColor, specialized to Colour
--   Double (i.e. opaque colors). See comment in lineColor
--   about backends.
lc :: (InSpace V2 n a, Typeable n, Floating n, HasStyle a) => Colour Double -> a -> a

-- | A synonym for lineColor, specialized to AlphaColour
--   Double (i.e. colors with transparency). See comment in
--   lineColor about backends.
lcA :: (InSpace V2 n a, Typeable n, Floating n, HasStyle a) => AlphaColour Double -> a -> a

-- | The texture with which objects are filled. The semigroup structure on
--   fill texture attributes is that of 'Recommed . Last'.
newtype FillTexture n
FillTexture :: (Recommend (Last (Texture n))) -> FillTexture n
_FillTexture :: Iso' (FillTexture n) (Recommend (Texture n))
getFillTexture :: FillTexture n -> Texture n
fillTexture :: (InSpace V2 n a, Typeable n, Floating n, HasStyle a) => Texture n -> a -> a
mkFillTexture :: Texture n -> FillTexture n

-- | Commit a fill texture in a style. This is not a valid setter
--   because it doesn't abide the functor law (see committed).
_fillTexture :: (Typeable n, Floating n) => Lens' (Style V2 n) (Texture n)

-- | Lens onto the Recommend of a fill texture in a style.
_fillTextureR :: (Typeable n, Floating n) => Lens' (Style V2 n) (Recommend (Texture n))

-- | Set the fill color. This function is polymorphic in the color type (so
--   it can be used with either Colour or AlphaColour), but
--   this can sometimes create problems for type inference, so the
--   fc and fcA variants are provided with more concrete
--   types.
fillColor :: (InSpace V2 n a, Color c, Typeable n, Floating n, HasStyle a) => c -> a -> a

-- | A synonym for fillColor, specialized to Colour
--   Double (i.e. opaque colors). See comment after fillColor
--   about backends.
fc :: (InSpace V2 n a, Floating n, Typeable n, HasStyle a) => Colour Double -> a -> a

-- | A synonym for fillColor, specialized to AlphaColour
--   Double (i.e. colors with transparency). See comment after
--   fillColor about backends.
fcA :: (InSpace V2 n a, Floating n, Typeable n, HasStyle a) => AlphaColour Double -> a -> a

-- | Set a "recommended" fill color, to be used only if no explicit calls
--   to fillColor (or fc, or fcA) are used. See
--   comment after fillColor about backends.
recommendFillColor :: (InSpace V2 n a, Color c, Typeable n, Floating n, HasStyle a) => c -> a -> a

-- | Push fill attributes down until they are at the root of subtrees
--   containing only loops. This makes life much easier for backends, which
--   typically have a semantics where fill attributes are applied to
--   linesnon-closed paths as well as loopsclosed paths, whereas in
--   the semantics of diagrams, fill attributes only apply to loops.
splitTextureFills :: (Typeable v, Typeable n) => RTree b v n a -> RTree b v n a
instance Data.Semigroup.Semigroup (Diagrams.TwoD.Attributes.FillTexture n)
instance Data.Semigroup.Semigroup (Diagrams.TwoD.Attributes.LineTexture n)
instance GHC.Float.Floating n => Diagrams.Core.Transform.Transformable (Diagrams.TwoD.Attributes.Texture n)
instance Data.Typeable.Internal.Typeable n => Diagrams.Core.Style.AttributeClass (Diagrams.TwoD.Attributes.LineTexture n)
instance GHC.Float.Floating n => Diagrams.Core.Transform.Transformable (Diagrams.TwoD.Attributes.LineTexture n)
instance Data.Default.Class.Default (Diagrams.TwoD.Attributes.LineTexture n)
instance Data.Typeable.Internal.Typeable n => Diagrams.Core.Style.AttributeClass (Diagrams.TwoD.Attributes.FillTexture n)
instance GHC.Float.Floating n => Diagrams.Core.Transform.Transformable (Diagrams.TwoD.Attributes.FillTexture n)
instance Data.Default.Class.Default (Diagrams.TwoD.Attributes.FillTexture n)
instance Data.Typeable.Internal.Typeable n => Diagrams.Attributes.Compile.SplitAttribute (Diagrams.TwoD.Attributes.FillTextureLoops n)
instance GHC.Real.Fractional n => Diagrams.Core.Transform.Transformable (Diagrams.TwoD.Attributes.RGradient n)
instance GHC.Real.Fractional n => Diagrams.Core.Transform.Transformable (Diagrams.TwoD.Attributes.LGradient n)

-- | Drawing arrows in two dimensions. For a tutorial on drawing arrows
--   using this module, see the diagrams website:
--   http://projects.haskell.org/diagrams/doc/arrow.html.
module Diagrams.TwoD.Arrow

-- | arrowV v creates an arrow with the direction and norm of the
--   vector v (with its tail at the origin), using default
--   parameters.
arrowV :: (TypeableFloat n, Renderable (Path V2 n) b) => V2 n -> QDiagram b V2 n Any

-- | arrowV' v creates an arrow with the direction and norm of the
--   vector v (with its tail at the origin).
arrowV' :: (TypeableFloat n, Renderable (Path V2 n) b) => ArrowOpts n -> V2 n -> QDiagram b V2 n Any

-- | Create an arrow starting at s with length and direction determined by
--   the vector v.
arrowAt :: (TypeableFloat n, Renderable (Path V2 n) b) => Point V2 n -> V2 n -> QDiagram b V2 n Any
arrowAt' :: (TypeableFloat n, Renderable (Path V2 n) b) => ArrowOpts n -> Point V2 n -> V2 n -> QDiagram b V2 n Any

-- | arrowBetween s e creates an arrow pointing from s to
--   e with default parameters.
arrowBetween :: (TypeableFloat n, Renderable (Path V2 n) b) => Point V2 n -> Point V2 n -> QDiagram b V2 n Any

-- | arrowBetween' opts s e creates an arrow pointing from
--   s to e using the given options. In particular, it
--   scales and rotates arrowShaft to go between s and
--   e, taking head, tail, and gaps into account.
arrowBetween' :: (TypeableFloat n, Renderable (Path V2 n) b) => ArrowOpts n -> Point V2 n -> Point V2 n -> QDiagram b V2 n Any

-- | Connect two diagrams with a straight arrow.
connect :: (TypeableFloat n, Renderable (Path V2 n) b, IsName n1, IsName n2) => n1 -> n2 -> QDiagram b V2 n Any -> QDiagram b V2 n Any

-- | Connect two diagrams with an arbitrary arrow.
connect' :: (TypeableFloat n, Renderable (Path V2 n) b, IsName n1, IsName n2) => ArrowOpts n -> n1 -> n2 -> QDiagram b V2 n Any -> QDiagram b V2 n Any

-- | Connect two diagrams at point on the perimeter of the diagrams,
--   choosen by angle.
connectPerim :: (TypeableFloat n, Renderable (Path V2 n) b, IsName n1, IsName n2) => n1 -> n2 -> Angle n -> Angle n -> QDiagram b V2 n Any -> QDiagram b V2 n Any
connectPerim' :: (TypeableFloat n, Renderable (Path V2 n) b, IsName n1, IsName n2) => ArrowOpts n -> n1 -> n2 -> Angle n -> Angle n -> QDiagram b V2 n Any -> QDiagram b V2 n Any

-- | Draw an arrow from diagram named "n1" to diagram named "n2". The arrow
--   lies on the line between the centres of the diagrams, but is drawn so
--   that it stops at the boundaries of the diagrams, using traces to find
--   the intersection points.
connectOutside :: (TypeableFloat n, Renderable (Path V2 n) b, IsName n1, IsName n2) => n1 -> n2 -> QDiagram b V2 n Any -> QDiagram b V2 n Any
connectOutside' :: (TypeableFloat n, Renderable (Path V2 n) b, IsName n1, IsName n2) => ArrowOpts n -> n1 -> n2 -> QDiagram b V2 n Any -> QDiagram b V2 n Any

-- | arrow len creates an arrow of length len with
--   default parameters, starting at the origin and ending at the point
--   (len,0).
arrow :: (TypeableFloat n, Renderable (Path V2 n) b) => n -> QDiagram b V2 n Any

-- | arrow' opts len creates an arrow of length len using
--   the given options, starting at the origin and ending at the point
--   (len,0). In particular, it scales the given arrowShaft
--   so that the entire arrow has length len.
arrow' :: (TypeableFloat n, Renderable (Path V2 n) b) => ArrowOpts n -> n -> QDiagram b V2 n Any

-- | Turn a located trail into a default arrow by putting an arrowhead at
--   the end of the trail.
arrowFromLocatedTrail :: (Renderable (Path V2 n) b, RealFloat n, Typeable n) => Located (Trail V2 n) -> QDiagram b V2 n Any

-- | Turn a located trail into an arrow using the given options.
arrowFromLocatedTrail' :: (Renderable (Path V2 n) b, RealFloat n, Typeable n) => ArrowOpts n -> Located (Trail V2 n) -> QDiagram b V2 n Any
data ArrowOpts n
ArrowOpts :: ArrowHT n -> ArrowHT n -> Trail V2 n -> Measure n -> Measure n -> Style V2 n -> Measure n -> Style V2 n -> Measure n -> Style V2 n -> ArrowOpts n
[_arrowHead] :: ArrowOpts n -> ArrowHT n
[_arrowTail] :: ArrowOpts n -> ArrowHT n
[_arrowShaft] :: ArrowOpts n -> Trail V2 n
[_headGap] :: ArrowOpts n -> Measure n
[_tailGap] :: ArrowOpts n -> Measure n
[_headStyle] :: ArrowOpts n -> Style V2 n
[_headLength] :: ArrowOpts n -> Measure n
[_tailStyle] :: ArrowOpts n -> Style V2 n
[_tailLength] :: ArrowOpts n -> Measure n
[_shaftStyle] :: ArrowOpts n -> Style V2 n

-- | A shape to place at the head of the arrow.
arrowHead :: Lens' (ArrowOpts n) (ArrowHT n)

-- | A shape to place at the tail of the arrow.
arrowTail :: Lens' (ArrowOpts n) (ArrowHT n)

-- | The trail to use for the arrow shaft.
arrowShaft :: Lens' (ArrowOpts n) (Trail V2 n)

-- | Distance to leave between the head and the target point.
headGap :: Lens' (ArrowOpts n) (Measure n)

-- | Distance to leave between the starting point and the tail.
tailGap :: Lens' (ArrowOpts n) (Measure n)

-- | Set both the headGap and tailGap simultaneously.
gaps :: Traversal' (ArrowOpts n) (Measure n)

-- | Same as gaps, provided for backward compatiiblity.
gap :: Traversal' (ArrowOpts n) (Measure n)

-- | A lens for setting or modifying the texture of an arrowhead. For
--   example, one may write ... (with & headTexture .~ grad)
--   to get an arrow with a head filled with a gradient, assuming grad has
--   been defined. Or ... (with & headTexture .~ solid blue to
--   set the head color to blue. For more general control over the style of
--   arrowheads, see headStyle.
headTexture :: TypeableFloat n => Lens' (ArrowOpts n) (Texture n)

-- | Style to apply to the head. headStyle is modified by using
--   the lens combinator %~ to change the current style. For
--   example, to change an opaque black arrowhead to translucent orange:
--   (with & headStyle %~ fc orange . opacity 0.75).
headStyle :: Lens' (ArrowOpts n) (Style V2 n)

-- | The length from the start of the joint to the tip of the head.
headLength :: Lens' (ArrowOpts n) (Measure n)

-- | A lens for setting or modifying the texture of an arrow tail. This is
--   *not* a valid lens (see committed).
tailTexture :: TypeableFloat n => Lens' (ArrowOpts n) (Texture n)

-- | Style to apply to the tail. See headStyle.
tailStyle :: Lens' (ArrowOpts n) (Style V2 n)

-- | The length of the tail plus its joint.
tailLength :: Lens' (ArrowOpts n) (Measure n)

-- | Set both the headLength and tailLength
--   simultaneously.
lengths :: Traversal' (ArrowOpts n) (Measure n)

-- | A lens for setting or modifying the texture of an arrow shaft.
shaftTexture :: TypeableFloat n => Lens' (ArrowOpts n) (Texture n)

-- | Style to apply to the shaft. See headStyle.
shaftStyle :: Lens' (ArrowOpts n) (Style V2 n)

-- | Straight line arrow shaft.
straightShaft :: OrderedField n => Trail V2 n
instance Diagrams.Core.Types.TypeableFloat n => Data.Default.Class.Default (Diagrams.TwoD.Arrow.ArrowOpts n)

-- | Diagram combinators specialized to two dimensions. For more general
--   combinators, see Diagrams.Combinators.
module Diagrams.TwoD.Combinators

-- | Place two diagrams (or other objects) vertically adjacent to one
--   another, with the first diagram above the second. Since Haskell
--   ignores whitespace in expressions, one can thus write
--   
--   
--    c
--   ===
--    d
--   
--   
--   
--   to place c above d. The local origin of the
--   resulting combined diagram is the same as the local origin of the
--   first. (===) is associative and has mempty as an
--   identity. See the documentation of beside for more information.
(===) :: (InSpace V2 n a, Num n, Juxtaposable a, Semigroup a) => a -> a -> a

-- | Place two diagrams (or other juxtaposable objects) horizontally
--   adjacent to one another, with the first diagram to the left of the
--   second. The local origin of the resulting combined diagram is the same
--   as the local origin of the first. (|||) is associative and
--   has mempty as an identity. See the documentation of
--   beside for more information.
(|||) :: (InSpace V2 n a, Num n, Juxtaposable a, Semigroup a) => a -> a -> a

-- | Lay out a list of juxtaposable objects in a row from left to right, so
--   that their local origins lie along a single horizontal line, with
--   successive envelopes tangent to one another.
--   
--   
--   
- For more control over the spacing, see hcat'.
--   
- To align the diagrams vertically (or otherwise), use alignment
--   combinators (such as alignT or alignB) from
--   Diagrams.TwoD.Align before applying hcat.
--   
- For non-axis-aligned layout, see cat.
--   
hcat :: (InSpace V2 n a, Floating n, Juxtaposable a, HasOrigin a, Monoid' a) => [a] -> a

-- | A variant of hcat taking an extra CatOpts record to
--   control the spacing. See the cat' documentation for a
--   description of the possibilities. For the common case of setting just
--   a separation amount, see hsep.
hcat' :: (InSpace V2 n a, Floating n, Juxtaposable a, HasOrigin a, Monoid' a) => CatOpts n -> [a] -> a

-- | A convenient synonym for horizontal concatenation with separation:
--   hsep s === hcat' (with & sep .~ s).
hsep :: (InSpace V2 n a, Floating n, Juxtaposable a, HasOrigin a, Monoid' a) => n -> [a] -> a

-- | Lay out a list of juxtaposable objects in a column from top to bottom,
--   so that their local origins lie along a single vertical line, with
--   successive envelopes tangent to one another.
--   
--   
--   
- For more control over the spacing, see vcat'.
--   
- To align the diagrams horizontally (or otherwise), use alignment
--   combinators (such as alignL or alignR) from
--   Diagrams.TwoD.Align before applying vcat.
--   
- For non-axis-aligned layout, see cat.
--   
vcat :: (InSpace V2 n a, Floating n, Juxtaposable a, HasOrigin a, Monoid' a) => [a] -> a

-- | A variant of vcat taking an extra CatOpts record to
--   control the spacing. See the cat' documentation for a
--   description of the possibilities. For the common case of setting just
--   a separation amount, see vsep.
vcat' :: (InSpace V2 n a, Floating n, Juxtaposable a, HasOrigin a, Monoid' a) => CatOpts n -> [a] -> a

-- | A convenient synonym for vertical concatenation with separation:
--   vsep s === vcat' (with & sep .~ s).
vsep :: (InSpace V2 n a, Floating n, Juxtaposable a, HasOrigin a, Monoid' a) => n -> [a] -> a

-- | strutR2 v is a two-dimensional diagram which produces no
--   output, but with respect to alignment, envelope, and trace acts
--   like a 1-dimensional segment oriented along the vector v,
--   with local origin at its center. If you don't care about the trace
--   then there's no difference between strutR2 and the more
--   general strut.
strutR2 :: (RealFloat n, Monoid' m) => V2 n -> QDiagram b V2 n m

-- | strutX w is an empty diagram with width w, height 0,
--   and a centered local origin. Note that strutX (-w) behaves
--   the same as strutX w.
strutX :: (Metric v, R1 v, OrderedField n, Monoid' m) => n -> QDiagram b v n m

-- | strutY h is an empty diagram with height h, width 0,
--   and a centered local origin. Note that strutY (-h) behaves
--   the same as strutY h.
strutY :: (Metric v, R2 v, OrderedField n, Monoid' m) => n -> QDiagram b v n m

-- | padX s "pads" a diagram in the x-direction, expanding its
--   envelope horizontally by a factor of s (factors between 0 and
--   1 can be used to shrink the envelope). Note that the envelope will
--   expand with respect to the local origin, so if the origin is not
--   centered horizontally the padding may appear "uneven". If this is not
--   desired, the origin can be centered (using centerX) before
--   applying padX.
padX :: (Metric v, R2 v, OrderedField n, Monoid' m) => n -> QDiagram b v n m -> QDiagram b v n m

-- | padY s "pads" a diagram in the y-direction, expanding its
--   envelope vertically by a factor of s (factors between 0 and 1
--   can be used to shrink the envelope). Note that the envelope will
--   expand with respect to the local origin, so if the origin is not
--   centered vertically the padding may appear "uneven". If this is not
--   desired, the origin can be centered (using centerY) before
--   applying padY.
padY :: (Metric v, R2 v, Monoid' m, OrderedField n) => n -> QDiagram b v n m -> QDiagram b v n m

-- | extrudeLeft s "extrudes" a diagram in the negative
--   x-direction, offsetting its envelope by the provided distance. When
--    s < 0 , the envelope is inset instead.
--   
--   See the documentation for extrudeEnvelope for more information.
extrudeLeft :: (OrderedField n, Monoid' m) => n -> QDiagram b V2 n m -> QDiagram b V2 n m

-- | extrudeRight s "extrudes" a diagram in the positive
--   x-direction, offsetting its envelope by the provided distance. When
--    s < 0 , the envelope is inset instead.
--   
--   See the documentation for extrudeEnvelope for more information.
extrudeRight :: (OrderedField n, Monoid' m) => n -> QDiagram b V2 n m -> QDiagram b V2 n m

-- | extrudeBottom s "extrudes" a diagram in the negative
--   y-direction, offsetting its envelope by the provided distance. When
--    s < 0 , the envelope is inset instead.
--   
--   See the documentation for extrudeEnvelope for more information.
extrudeBottom :: (OrderedField n, Monoid' m) => n -> QDiagram b V2 n m -> QDiagram b V2 n m

-- | extrudeTop s "extrudes" a diagram in the positive
--   y-direction, offsetting its envelope by the provided distance. When
--    s < 0 , the envelope is inset instead.
--   
--   See the documentation for extrudeEnvelope for more information.
extrudeTop :: (OrderedField n, Monoid' m) => n -> QDiagram b V2 n m -> QDiagram b V2 n m

-- | rectEnvelope p v sets the envelope of a diagram to a
--   rectangle whose lower-left corner is at p and whose
--   upper-right corner is at p .+^ v. Useful for selecting the
--   rectangular portion of a diagram which should actually be "viewed" in
--   the final render, if you don't want to see the entire diagram.
rectEnvelope :: (OrderedField n, Monoid' m) => Point V2 n -> V2 n -> QDiagram b V2 n m -> QDiagram b V2 n m

-- | Construct a bounding rectangle for an enveloped object, that is, the
--   smallest axis-aligned rectangle which encloses the object.
boundingRect :: (InSpace V2 n a, SameSpace a t, Enveloped t, Transformable t, TrailLike t, Monoid t, Enveloped a) => a -> t

-- | "Set the background color" of a diagram. That is, place a diagram atop
--   a bounding rectangle of the given color.
bg :: (TypeableFloat n, Renderable (Path V2 n) b) => Colour Double -> QDiagram b V2 n Any -> QDiagram b V2 n Any

-- | Similar to bg but makes the colored background rectangle larger
--   than the diagram. The first parameter is used to set how far the
--   background extends beyond the diagram.
bgFrame :: (TypeableFloat n, Renderable (Path V2 n) b) => n -> Colour Double -> QDiagram b V2 n Any -> QDiagram b V2 n Any

-- | Importing external images into diagrams. Usage example: To create a
--   diagram from an embedded image with width 1 and height set according
--   to the aspect ratio, use image img # scaleUToX 1, where
--   img is a value of type DImage n e, created with a
--   function like loadImageEmb, loadImageExt, or
--   raster.
module Diagrams.TwoD.Image

-- | An image primitive, the two ints are width followed by height. Will
--   typically be created by loadImageEmb or loadImageExt
--   which, will handle setting the width and height to the actual width
--   and height of the image.
data DImage :: * -> * -> *
DImage :: ImageData t -> Int -> Int -> Transformation V2 n -> DImage n t

-- | ImageData is either a JuicyPixels DynamicImage tagged
--   as Embedded or a reference tagged as External.
--   Additionally Native is provided for external libraries to hook
--   into.
data ImageData :: * -> *
ImageRaster :: DynamicImage -> ImageData Embedded
ImageRef :: FilePath -> ImageData External
ImageNative :: t -> ImageData (Native t)
data Embedded
data External
data Native (t :: *)

-- | Make a DImage into a Diagram.
image :: (TypeableFloat n, Typeable a, Renderable (DImage n a) b) => DImage n a -> QDiagram b V2 n Any

-- | Use JuicyPixels to read an image in any format and wrap it in a
--   DImage. The width and height of the image are set to their
--   actual values.
loadImageEmb :: Num n => FilePath -> IO (Either String (DImage n Embedded))

-- | Check that a file exists, and use JuicyPixels to figure out the right
--   size, but save a reference to the image instead of the raster data
loadImageExt :: Num n => FilePath -> IO (Either String (DImage n External))

-- | Make an "unchecked" image reference; have to specify a width and
--   height. Unless the aspect ratio of the external image is the w :: h,
--   then the image will be distorted.
uncheckedImageRef :: Num n => FilePath -> Int -> Int -> DImage n External

-- | Create an image "from scratch" by specifying the pixel data
raster :: Num n => (Int -> Int -> AlphaColour Double) -> Int -> Int -> DImage n Embedded

-- | Crate a diagram from raw raster data.
rasterDia :: (TypeableFloat n, Renderable (DImage n Embedded) b) => (Int -> Int -> AlphaColour Double) -> Int -> Int -> QDiagram b V2 n Any
instance GHC.Real.Fractional n => Diagrams.Core.Transform.Transformable (Diagrams.TwoD.Image.DImage n a)
instance GHC.Real.Fractional n => Diagrams.Core.HasOrigin.HasOrigin (Diagrams.TwoD.Image.DImage n a)
instance GHC.Real.Fractional n => Diagrams.Core.Types.Renderable (Diagrams.TwoD.Image.DImage n a) Diagrams.Core.Types.NullBackend

-- | Very basic text primitives along with associated attributes.
module Diagrams.TwoD.Text

-- | A Text primitive consists of the string contents, text
--   alignment and the transformation to be applied. The transformation is
--   scale invarient, the average scale of the transform should always be
--   1. All text scaling is obtained from the FontSize attribute.
--   
--   This constructor should not be used directly. Use text,
--   alignedText or baselineText.
data Text n
Text :: (T2 n) -> (TextAlignment n) -> String -> Text n

-- | TextAlignment specifies the alignment of the text's origin.
data TextAlignment n
BaselineText :: TextAlignment n
BoxAlignedText :: n -> n -> TextAlignment n

-- | Create a primitive text diagram from the given string, with center
--   alignment, equivalent to alignedText 0.5 0.5.
--   
--   Note that it takes up no space, as text size information is not
--   available.
text :: (TypeableFloat n, Renderable (Text n) b) => String -> QDiagram b V2 n Any

-- | Create a primitive text diagram from the given string, origin at the
--   top left corner of the text's bounding box, equivalent to
--   alignedText 0 1.
--   
--   Note that it takes up no space.
topLeftText :: (TypeableFloat n, Renderable (Text n) b) => String -> QDiagram b V2 n Any

-- | Create a primitive text diagram from the given string, with the origin
--   set to a point interpolated within the bounding box. The first
--   parameter varies from 0 (left) to 1 (right), and the second parameter
--   from 0 (bottom) to 1 (top). Some backends do not implement this and
--   instead snap to closest corner or the center.
--   
--   The height of this box is determined by the font's potential ascent
--   and descent, rather than the height of the particular string.
--   
--   Note that it takes up no space.
alignedText :: (TypeableFloat n, Renderable (Text n) b) => n -> n -> String -> QDiagram b V2 n Any

-- | Create a primitive text diagram from the given string, with the origin
--   set to be on the baseline, at the beginning (although not bounding).
--   This is the reference point of showText in the Cairo graphics library.
--   
--   Note that it takes up no space.
baselineText :: (TypeableFloat n, Renderable (Text n) b) => String -> QDiagram b V2 n Any

-- | Make a text from a TextAlignment.
mkText :: (TypeableFloat n, Renderable (Text n) b) => TextAlignment n -> String -> QDiagram b V2 n Any

-- | The Font attribute specifies the name of a font family. Inner
--   Font attributes override outer ones.
newtype Font
Font :: (Last String) -> Font
_Font :: Iso' Font String

-- | Extract the font family name from a Font attribute.
getFont :: Font -> String

-- | Specify a font family to be used for all text within a diagram.
font :: HasStyle a => String -> a -> a

-- | Lens onto the font name of a style.
_font :: (Typeable n, OrderedField n) => Lens' (Style v n) (Maybe String)

-- | The FontSize attribute specifies the size of a font's
--   em-square. Inner FontSize attributes override outer ones.
newtype FontSize n
FontSize :: (Recommend (Last n)) -> FontSize n
_FontSize :: Iso' (FontSize n) (Recommend n)

-- | Extract the size from a FontSize attribute.
getFontSize :: FontSize n -> n

-- | Apply a FontSize attribute.
fontSizeM :: (N a ~ n, Typeable n, Num n, HasStyle a) => FontSizeM n -> a -> a

-- | Set the font size, that is, the size of the font's em-square as
--   measured within the current local vector space. The default size is
--   1.
fontSize :: (N a ~ n, Typeable n, HasStyle a) => Measure n -> a -> a

-- | A convenient synonym for 'fontSize (Normalized w)'.
fontSizeN :: (N a ~ n, Typeable n, Num n, HasStyle a) => n -> a -> a

-- | A convenient synonym for 'fontSize (Output w)'.
fontSizeO :: (N a ~ n, Typeable n, Num n, HasStyle a) => n -> a -> a

-- | A convenient sysnonym for 'fontSize (Local w)'.
fontSizeL :: (N a ~ n, Typeable n, Num n, HasStyle a) => n -> a -> a

-- | A convenient synonym for 'fontSize (Global w)'.
fontSizeG :: (N a ~ n, Typeable n, Num n, HasStyle a) => n -> a -> a
_fontSizeR :: (Typeable n, OrderedField n) => Lens' (Style v n) (Measured n (Recommend n))

-- | Lens to commit a font size. This is *not* a valid lens (see
--   commited.
_fontSize :: (Typeable n, OrderedField n) => Lens' (Style v n) (Measure n)
_fontSizeU :: (Typeable n, OrderedField n) => Lens' (Style v n) (Maybe n)

-- | The FontSlantA attribute specifies the slant (normal, italic,
--   or oblique) that should be used for all text within a diagram. Inner
--   FontSlantA attributes override outer ones.
data FontSlant
FontSlantNormal :: FontSlant
FontSlantItalic :: FontSlant
FontSlantOblique :: FontSlant

-- | Extract the font slant from a FontSlantA attribute.
getFontSlant :: FontSlant -> FontSlant

-- | Specify the slant (normal, italic, or oblique) that should be used for
--   all text within a diagram. See also italic and oblique
--   for useful special cases.
fontSlant :: HasStyle a => FontSlant -> a -> a

-- | Set all text in italics.
italic :: HasStyle a => a -> a

-- | Set all text using an oblique slant.
oblique :: HasStyle a => a -> a

-- | Lens onto the font slant in a style.
_fontSlant :: (Typeable n, OrderedField n) => Lens' (Style v n) FontSlant

-- | The FontWeightA attribute specifies the weight (normal or
--   bold) that should be used for all text within a diagram. Inner
--   FontWeightA attributes override outer ones.
data FontWeight
FontWeightNormal :: FontWeight
FontWeightBold :: FontWeight

-- | Extract the font weight.
getFontWeight :: FontWeight -> FontWeight

-- | Specify the weight (normal or bold) that should be used for all text
--   within a diagram. See also bold for a useful special case.
fontWeight :: HasStyle a => FontWeight -> a -> a

-- | Set all text using a bold font weight.
bold :: HasStyle a => a -> a

-- | Lens onto the font weight in a style.
_fontWeight :: (Typeable n, OrderedField n) => Lens' (Style v n) FontWeight
instance GHC.Show.Show Diagrams.TwoD.Text.FontWeight
instance GHC.Classes.Ord Diagrams.TwoD.Text.FontWeight
instance GHC.Classes.Eq Diagrams.TwoD.Text.FontWeight
instance GHC.Classes.Ord Diagrams.TwoD.Text.FontSlant
instance GHC.Show.Show Diagrams.TwoD.Text.FontSlant
instance GHC.Classes.Eq Diagrams.TwoD.Text.FontSlant
instance Data.Semigroup.Semigroup (Diagrams.TwoD.Text.FontSize n)
instance GHC.Classes.Eq Diagrams.TwoD.Text.Font
instance Data.Semigroup.Semigroup Diagrams.TwoD.Text.Font
instance GHC.Float.Floating n => Diagrams.Core.Transform.Transformable (Diagrams.TwoD.Text.Text n)
instance GHC.Float.Floating n => Diagrams.Core.HasOrigin.HasOrigin (Diagrams.TwoD.Text.Text n)
instance GHC.Float.Floating n => Diagrams.Core.Types.Renderable (Diagrams.TwoD.Text.Text n) Diagrams.Core.Types.NullBackend
instance Diagrams.Core.Style.AttributeClass Diagrams.TwoD.Text.Font
instance GHC.Base.Functor Diagrams.TwoD.Text.FontSize
instance Data.Typeable.Internal.Typeable n => Diagrams.Core.Style.AttributeClass (Diagrams.TwoD.Text.FontSize n)
instance GHC.Num.Num n => Data.Default.Class.Default (Diagrams.TwoD.Text.FontSizeM n)
instance Diagrams.Core.Style.AttributeClass Diagrams.TwoD.Text.FontSlant
instance Data.Semigroup.Semigroup Diagrams.TwoD.Text.FontSlant
instance Data.Default.Class.Default Diagrams.TwoD.Text.FontSlant
instance Diagrams.Core.Style.AttributeClass Diagrams.TwoD.Text.FontWeight
instance Data.Semigroup.Semigroup Diagrams.TwoD.Text.FontWeight
instance Data.Default.Class.Default Diagrams.TwoD.Text.FontWeight

-- | Tools for visualizing diagrams' internal model: local origins,
--   envelopes, traces, etc.
module Diagrams.TwoD.Model

-- | Mark the origin of a diagram by placing a red dot 1/50th its size.
showOrigin :: (TypeableFloat n, Renderable (Path V2 n) b, Monoid' m) => QDiagram b V2 n m -> QDiagram b V2 n m

-- | Mark the origin of a diagram, with control over colour and scale of
--   marker dot.
showOrigin' :: (TypeableFloat n, Renderable (Path V2 n) b, Monoid' m) => OriginOpts n -> QDiagram b V2 n m -> QDiagram b V2 n m
data OriginOpts n
OriginOpts :: Colour Double -> n -> n -> OriginOpts n
[_oColor] :: OriginOpts n -> Colour Double
[_oScale] :: OriginOpts n -> n
[_oMinSize] :: OriginOpts n -> n
oColor :: Lens' (OriginOpts n_a4IYd) (Colour Double)
oScale :: Lens' (OriginOpts n_a4IYd) n_a4IYd
oMinSize :: Lens' (OriginOpts n_a4IYd) n_a4IYd

-- | Mark the envelope with an approximating cubic spline using 32 points,
--   medium line width and red line color.
showEnvelope :: (Enum n, TypeableFloat n, Renderable (Path V2 n) b) => QDiagram b V2 n Any -> QDiagram b V2 n Any

-- | Mark the envelope with an approximating cubic spline with control over
--   the color, line width and number of points.
showEnvelope' :: (Enum n, TypeableFloat n, Renderable (Path V2 n) b) => EnvelopeOpts n -> QDiagram b V2 n Any -> QDiagram b V2 n Any
data EnvelopeOpts n
EnvelopeOpts :: Colour Double -> Measure n -> Int -> EnvelopeOpts n
[_eColor] :: EnvelopeOpts n -> Colour Double
[_eLineWidth] :: EnvelopeOpts n -> Measure n
[_ePoints] :: EnvelopeOpts n -> Int
eColor :: Lens' (EnvelopeOpts n_a4IYZ) (Colour Double)
eLineWidth :: Lens (EnvelopeOpts n_a4IYZ) (EnvelopeOpts n_a4J1c) (Measure n_a4IYZ) (Measure n_a4J1c)
ePoints :: Lens' (EnvelopeOpts n_a4IYZ) Int

-- | Mark the trace of a diagram by placing 64 red dots 1/100th its size
--   along the trace.
showTrace :: (Enum n, TypeableFloat n, Renderable (Path V2 n) b) => QDiagram b V2 n Any -> QDiagram b V2 n Any

-- | Mark the trace of a diagram, with control over colour and scale of
--   marker dot and the number of points on the trace.
showTrace' :: (Enum n, TypeableFloat n, Renderable (Path V2 n) b) => TraceOpts n -> QDiagram b V2 n Any -> QDiagram b V2 n Any
data TraceOpts n
TraceOpts :: Colour Double -> n -> n -> Int -> TraceOpts n
[_tColor] :: TraceOpts n -> Colour Double
[_tScale] :: TraceOpts n -> n
[_tMinSize] :: TraceOpts n -> n
[_tPoints] :: TraceOpts n -> Int
tColor :: Lens' (TraceOpts n_a4J1B) (Colour Double)
tScale :: Lens' (TraceOpts n_a4J1B) n_a4J1B
tMinSize :: Lens' (TraceOpts n_a4J1B) n_a4J1B
tPoints :: Lens' (TraceOpts n_a4J1B) Int
showLabels :: (TypeableFloat n, Renderable (Text n) b, Semigroup m) => QDiagram b V2 n m -> QDiagram b V2 n Any
instance GHC.Float.Floating n => Data.Default.Class.Default (Diagrams.TwoD.Model.TraceOpts n)
instance Diagrams.Core.Envelope.OrderedField n => Data.Default.Class.Default (Diagrams.TwoD.Model.EnvelopeOpts n)
instance GHC.Real.Fractional n => Data.Default.Class.Default (Diagrams.TwoD.Model.OriginOpts n)

-- | A default diagram-adjustment implementation for two-dimensional
--   diagrams, useful for backend implementors.
module Diagrams.TwoD.Adjust

-- | Set default attributes of a 2D diagram (in case they have not been
--   set):
--   
--   
--   
- LineWidth: 0.01
--   
- LineTexture: solid black
--   
- LineCap: LineCapButt
--   
- LineJoin: miter
--   
- MiterLimit: 10
--   
setDefault2DAttributes :: (TypeableFloat n, Semigroup m) => QDiagram b V2 n m -> QDiagram b V2 n m

-- | Adjust the size and position of a 2D diagram to fit within the
--   requested size. The first argument is a lens into the output size
--   contained in the rendering options. Returns an updated options record,
--   any transformation applied to the diagram (the inverse of which can be
--   used, say, to translate output/device coordinates back into local
--   diagram coordinates), and the modified diagram itself.
adjustSize2D :: (TypeableFloat n, Monoid' m) => Lens' (Options b V2 n) (SizeSpec V2 n) -> b -> Options b V2 n -> QDiagram b V2 n m -> (Options b V2 n, Transformation V2 n, QDiagram b V2 n m)

-- | adjustDia2D provides a useful default implementation of the
--   adjustDia method from the Backend type class.
--   
--   As its first argument it requires a lens into the output size
--   contained in the rendering options.
--   
--   It then performs the following adjustments:
--   
--   
--   
- Set default attributes (see setDefault2DAttributes)
--   
- Scale and translate the diagram to fit within the requested size
--   (see adjustDiaSize2D)
--   
--   
--   It returns an updated options record, any transformation applied to
--   the diagram (the inverse of which can be used, say, to translate
--   output/device coordinates back into local diagram coordinates), and
--   the modified diagram itself.
adjustDia2D :: (TypeableFloat n, Monoid' m) => Lens' (Options b V2 n) (SizeSpec V2 n) -> b -> Options b V2 n -> QDiagram b V2 n m -> (Options b V2 n, Transformation V2 n, QDiagram b V2 n m)

-- | Compute offsets to segments in two dimensions. More details can be
--   found in the manual at
--   http://projects.haskell.org/diagrams/doc/manual.html#offsets-of-segments-trails-and-paths.
module Diagrams.TwoD.Offset
offsetSegment :: RealFloat n => n -> n -> Segment Closed V2 n -> Located (Trail V2 n)

-- | Compute the offset of a segment. Given a segment compute the offset
--   curve that is a fixed distance from the original curve. For linear
--   segments nothing special happens, the same linear segment is returned
--   with a point that is offset by a perpendicular vector of the given
--   offset length.
--   
--   Cubic segments require a search for a subdivision of cubic segments
--   that gives an approximation of the offset within the given epsilon
--   factor (the given epsilon factor is applied to the radius giving a
--   concrete epsilon value). We must do this because the offset of a cubic
--   is not a cubic itself (the degree of the curve increases). Cubics do,
--   however, approach constant curvature as we subdivide. In light of this
--   we scale the handles of the offset cubic segment in proportion to the
--   radius of curvature difference between the original subsegment and the
--   offset which will have a radius increased by the offset parameter.
--   
--   In the following example the blue lines are the original segments and
--   the alternating green and red lines are the resulting offset trail
--   segments.
--   
--   
--   Note that when the original curve has a cusp, the offset curve forms a
--   radius around the cusp, and when there is a loop in the original
--   curve, there can be two cusps in the offset curve.
--   
--   Options for specifying line join and segment epsilon for an offset
--   involving multiple segments.
data OffsetOpts d
OffsetOpts :: LineJoin -> d -> d -> OffsetOpts d
[_offsetJoin] :: OffsetOpts d -> LineJoin
[_offsetMiterLimit] :: OffsetOpts d -> d
[_offsetEpsilon] :: OffsetOpts d -> d

-- | Specifies the style of join for between adjacent offset segments.
offsetJoin :: Lens' (OffsetOpts d) LineJoin

-- | Specifies the miter limit for the join.
offsetMiterLimit :: Lens' (OffsetOpts d) d

-- | Epsilon perimeter for offsetSegment.
offsetEpsilon :: Lens' (OffsetOpts d) d

-- | Offset a Trail with the default options and a given radius. See
--   offsetTrail'.
offsetTrail :: RealFloat n => n -> Located (Trail V2 n) -> Located (Trail V2 n)

-- | Offset a Trail with options and by a given radius. This
--   generates a new trail that is always radius r away from the
--   given Trail (depending on the line join option) on the right.
--   
--   The styles applied to an outside corner can be seen here (with the
--   original trail in blue and the result of offsetTrail' in
--   green):
--   
--   
--   When a negative radius is given, the offset trail will be on the left:
--   
--   
--   When offseting a counter-clockwise loop a positive radius gives an
--   outer loop while a negative radius gives an inner loop (both
--   counter-clockwise).
--   
offsetTrail' :: RealFloat n => OffsetOpts n -> n -> Located (Trail V2 n) -> Located (Trail V2 n)

-- | Offset a Path with the default options and given radius. See
--   offsetPath'.
offsetPath :: RealFloat n => n -> Path V2 n -> Path V2 n

-- | Offset a Path by applying offsetTrail' to each trail in
--   the path.
offsetPath' :: RealFloat n => OffsetOpts n -> n -> Path V2 n -> Path V2 n

-- | Options for specifying how a Trail should be expanded.
data ExpandOpts d
ExpandOpts :: LineJoin -> d -> LineCap -> d -> ExpandOpts d
[_expandJoin] :: ExpandOpts d -> LineJoin
[_expandMiterLimit] :: ExpandOpts d -> d
[_expandCap] :: ExpandOpts d -> LineCap
[_expandEpsilon] :: ExpandOpts d -> d

-- | Specifies the style of join for between adjacent offset segments.
expandJoin :: Lens' (ExpandOpts d) LineJoin

-- | Specifies the miter limit for the join.
expandMiterLimit :: Lens' (ExpandOpts d) d

-- | Specifies how the ends are handled.
expandCap :: Lens' (ExpandOpts d) LineCap

-- | Epsilon perimeter for offsetSegment.
expandEpsilon :: Lens' (ExpandOpts d) d

-- | Expand a Trail with the given radius and default options. See
--   expandTrail'.
expandTrail :: RealFloat n => n -> Located (Trail V2 n) -> Path V2 n

-- | Expand a Trail with the given options and radius r
--   around a given Trail. Expanding can be thought of as generating
--   the loop that, when filled, represents stroking the trail with a
--   radius r brush.
--   
--   The cap styles applied to an outside corner can be seen here (with the
--   original trail in white and the result of expandTrail' filled
--   in green):
--   
--   
--   Loops result in a path with an inner and outer loop:
--   
expandTrail' :: (OrderedField n, RealFloat n, RealFrac n) => ExpandOpts n -> n -> Located (Trail V2 n) -> Path V2 n

-- | Expand a Path with the given radius and default options. See
--   expandPath'.
expandPath :: RealFloat n => n -> Path V2 n -> Path V2 n

-- | Expand a Path using expandTrail' on each trail in the
--   path.
expandPath' :: RealFloat n => ExpandOpts n -> n -> Path V2 n -> Path V2 n
instance GHC.Real.Fractional d => Data.Default.Class.Default (Diagrams.TwoD.Offset.ExpandOpts d)
instance GHC.Show.Show d => GHC.Show.Show (Diagrams.TwoD.Offset.ExpandOpts d)
instance GHC.Classes.Eq d => GHC.Classes.Eq (Diagrams.TwoD.Offset.ExpandOpts d)
instance GHC.Real.Fractional d => Data.Default.Class.Default (Diagrams.TwoD.Offset.OffsetOpts d)
instance GHC.Classes.Eq d => GHC.Classes.Eq (Diagrams.TwoD.Offset.OffsetOpts d)
instance GHC.Show.Show d => GHC.Show.Show (Diagrams.TwoD.Offset.OffsetOpts d)

-- | This module defines the two-dimensional vector space R^2,
--   two-dimensional transformations, and various predefined
--   two-dimensional shapes. This module re-exports useful functionality
--   from a group of more specific modules:
--   
--   
--   
- Diagrams.TwoD.Types defines basic types for two-dimensional
--   diagrams, including types representing the 2D Euclidean vector space
--   and various systems of angle measurement.
--   
- Diagrams.TwoD.Align defines alignment combinators
--   specialized to two dimensions (see Diagrams.Align for more
--   general alignment).
--   
- Diagrams.TwoD.Combinators defines ways of combining
--   diagrams specialized to two dimensions (see also
--   Diagrams.Combinators for more general combining).
--   
- Diagrams.TwoD.Attributes defines attributes specific to two
--   dimensions, *e.g.* fill color, line color, and gradients.
--   
- Diagrams.TwoD.Transform defines R^2-specific
--   transformations such as rotation by an angle, and scaling,
--   translation, and reflection in the X and Y directions.
--   
- Diagrams.TwoD.Deform defines some non-affine
--   transformations specific to two dimensions, *e.g.* parallel and
--   perspective projections.
--   
- Diagrams.TwoD.Ellipse defines circles and ellipses.
--   
- Diagrams.TwoD.Arc defines circular arcs.
--   
- Diagrams.TwoD.Path exports various operations on
--   two-dimensional paths when viewed as regions of the plane.
--   
- Diagrams.TwoD.Polygons defines general algorithms for
--   drawing various types of polygons.
--   
- Diagrams.TwoD.Shapes defines other two-dimensional shapes,
--   e.g. various polygons.
--   
- Diagrams.TwoD.Arrow contains tools for drawing arrows
--   between things, and Diagrams.TwoD.Arrowheads defines a
--   collection of arrowheads.
--   
- Diagrams.TwoD.Text defines primitive text diagrams.
--   
- Diagrams.TwoD.Image allows importing external images into
--   diagrams.
--   
- Diagrams.TwoD.Vector defines some special 2D vectors and
--   functions for converting between vectors and angles.
--   
- Diagrams.TwoD.Size defines functions for working with the
--   size of 2D objects.
--   
- Diagrams.TwoD.Model defines some aids for visualizing
--   diagrams' internal model (local origins, envelopes, etc.)
--   
module Diagrams.TwoD

-- | A 2-dimensional vector
--   
--   
--   >>> pure 1 :: V2 Int
--   V2 1 1
--   
--   
--   
--   >>> V2 1 2 + V2 3 4
--   V2 4 6
--   
--   
--   
--   >>> V2 1 2 * V2 3 4
--   V2 3 8
--   
--   
--   
--   >>> sum (V2 1 2)
--   3
--   
data V2 a :: * -> *
V2 :: SrictNotUnpackeda -> SrictNotUnpackeda -> V2 a

-- | A space that has at least 1 basis vector _x.
class R1 (t :: * -> *)

-- | 
--   >>> V1 2 ^._x
--   2
--   
--   
--   
--   >>> V1 2 & _x .~ 3
--   V1 3
--   
_x :: (R1 t, Functor f) => (a -> f a) -> t a -> f (t a)

-- | A space that distinguishes 2 orthogonal basis vectors _x and
--   _y, but may have more.
class R1 t => R2 (t :: * -> *)

-- | 
--   >>> V2 1 2 ^._y
--   2
--   
--   
--   
--   >>> V2 1 2 & _y .~ 3
--   V2 1 3
--   
_y :: (R2 t, Functor f) => (a -> f a) -> t a -> f (t a)
_xy :: (R2 t, Functor f) => (V2 a -> f (V2 a)) -> t a -> f (t a)
type P2 = Point V2
type T2 = Transformation V2

-- | Construct a 2D vector from a pair of components. See also
--   &.
r2 :: (n, n) -> V2 n

-- | Convert a 2D vector back into a pair of components. See also
--   coords.
unr2 :: V2 n -> (n, n)

-- | Curried form of r2.
mkR2 :: n -> n -> V2 n

-- | Construct a 2D point from a pair of coordinates. See also
--   ^&.
p2 :: (n, n) -> P2 n

-- | Convert a 2D point back into a pair of coordinates. See also
--   coords.
unp2 :: P2 n -> (n, n)

-- | Curried form of p2.
mkP2 :: n -> n -> P2 n

-- | The unit vector in the positive X direction.
unitX :: (R1 v, Additive v, Num n) => v n

-- | The unit vector in the positive Y direction.
unitY :: (R2 v, Additive v, Num n) => v n

-- | The unit vector in the negative X direction.
unit_X :: (R1 v, Additive v, Num n) => v n

-- | The unit vector in the negative Y direction.
unit_Y :: (R2 v, Additive v, Num n) => v n

-- | the counter-clockwise perpendicular vector
--   
--   
--   >>> perp $ V2 10 20
--   V2 (-20) 10
--   
perp :: Num a => V2 a -> V2 a

-- | leftTurn v1 v2 tests whether the direction of v2 is
--   a left turn from v1 (that is, if the direction of v2
--   can be obtained from that of v1 by adding an angle 0 <=
--   theta <= tau/2).
leftTurn :: (Num n, Ord n) => V2 n -> V2 n -> Bool

-- | A Direction pointing in the X direction.
xDir :: (R1 v, Additive v, Num n) => Direction v n

-- | A Direction pointing in the Y direction.
yDir :: (R2 v, Additive v, Num n) => Direction v n

-- | The circle constant, the ratio of a circle's circumference to its
--   radius. Note that pi = tau/2.
--   
--   For more information and a well-reasoned argument why we should all be
--   using tau instead of pi, see The Tau Manifesto,
--   http://tauday.com/.
--   
--   To hear what it sounds like (and to easily memorize the first 30
--   digits or so), try http://youtu.be/3174T-3-59Q.
tau :: Floating a => a

-- | A unit vector at a specified angle counter-clockwise from the positive
--   x-axis
angleV :: Floating n => Angle n -> V2 n

-- | A direction at a specified angle counter-clockwise from the
--   xDir.
angleDir :: Floating n => Angle n -> Direction V2 n
signedAngleBetween :: RealFloat n => V2 n -> V2 n -> Angle n
signedAngleBetweenDirs :: RealFloat n => Direction V2 n -> Direction V2 n -> Angle n

-- | A space which has magnitude _r that can be calculated
--   numerically.
class HasR t
_r :: (HasR t, RealFloat n) => Lens' (t n) n
r2PolarIso :: RealFloat n => Iso' (V2 n) (n, Angle n)

-- | Convert a ToPath object into a diagram. The resulting diagram
--   has the names 0, 1, ... assigned to each of the path's vertices.
--   
--   See also stroke', which takes an extra options record allowing
--   its behaviour to be customized.
stroke :: (InSpace V2 n t, ToPath t, TypeableFloat n, Renderable (Path V2 n) b) => t -> QDiagram b V2 n Any

-- | A variant of stroke that takes an extra record of options to
--   customize its behaviour. In particular:
--   
--   
--   
- Names can be assigned to the path's vertices
--   
--   
--   StrokeOpts is an instance of Default, so stroke'
--   (with & ... ) syntax may be used.
stroke' :: (InSpace V2 n t, ToPath t, TypeableFloat n, Renderable (Path V2 n) b, IsName a) => StrokeOpts a -> t -> QDiagram b V2 n Any

-- | stroke specialised to Path.
strokePath :: (TypeableFloat n, Renderable (Path V2 n) b) => Path V2 n -> QDiagram b V2 n Any

-- | stroke specialised to Path.
strokeP :: (TypeableFloat n, Renderable (Path V2 n) b) => Path V2 n -> QDiagram b V2 n Any

-- | stroke' specialised to Path.
strokePath' :: (TypeableFloat n, Renderable (Path V2 n) b, IsName a) => StrokeOpts a -> Path V2 n -> QDiagram b V2 n Any

-- | stroke' specialised to Path.
strokeP' :: (TypeableFloat n, Renderable (Path V2 n) b, IsName a) => StrokeOpts a -> Path V2 n -> QDiagram b V2 n Any

-- | stroke specialised to Trail.
strokeTrail :: (TypeableFloat n, Renderable (Path V2 n) b) => Trail V2 n -> QDiagram b V2 n Any

-- | stroke specialised to Trail.
strokeT :: (TypeableFloat n, Renderable (Path V2 n) b) => Trail V2 n -> QDiagram b V2 n Any

-- | A composition of stroke' and pathFromTrail for
--   conveniently converting a trail directly into a diagram.
strokeTrail' :: (TypeableFloat n, Renderable (Path V2 n) b, IsName a) => StrokeOpts a -> Trail V2 n -> QDiagram b V2 n Any

-- | Deprecated synonym for strokeTrail'.
strokeT' :: (TypeableFloat n, Renderable (Path V2 n) b, IsName a) => StrokeOpts a -> Trail V2 n -> QDiagram b V2 n Any

-- | A composition of strokeT and wrapLine for conveniently
--   converting a line directly into a diagram.
strokeLine :: (TypeableFloat n, Renderable (Path V2 n) b) => Trail' Line V2 n -> QDiagram b V2 n Any

-- | A composition of strokeT and wrapLoop for conveniently
--   converting a loop directly into a diagram.
strokeLoop :: (TypeableFloat n, Renderable (Path V2 n) b) => Trail' Loop V2 n -> QDiagram b V2 n Any

-- | A convenience function for converting a Located Trail
--   directly into a diagram; strokeLocTrail = stroke . trailLike.
strokeLocTrail :: (TypeableFloat n, Renderable (Path V2 n) b) => Located (Trail V2 n) -> QDiagram b V2 n Any

-- | Deprecated synonym for strokeLocTrail.
strokeLocT :: (TypeableFloat n, Renderable (Path V2 n) b) => Located (Trail V2 n) -> QDiagram b V2 n Any

-- | A convenience function for converting a Located line directly
--   into a diagram; strokeLocLine = stroke . trailLike . mapLoc
--   wrapLine.
strokeLocLine :: (TypeableFloat n, Renderable (Path V2 n) b) => Located (Trail' Line V2 n) -> QDiagram b V2 n Any

-- | A convenience function for converting a Located loop directly
--   into a diagram; strokeLocLoop = stroke . trailLike . mapLoc
--   wrapLoop.
strokeLocLoop :: (TypeableFloat n, Renderable (Path V2 n) b) => Located (Trail' Loop V2 n) -> QDiagram b V2 n Any

-- | Enumeration of algorithms or "rules" for determining which points lie
--   in the interior of a (possibly self-intersecting) path.
data FillRule

-- | Interior points are those with a nonzero winding number.
--   See http://en.wikipedia.org/wiki/Nonzero-rule.
Winding :: FillRule

-- | Interior points are those where a ray extended infinitely in a
--   particular direction crosses the path an odd number of times. See
--   http://en.wikipedia.org/wiki/Even-odd_rule.
EvenOdd :: FillRule

-- | Specify the fill rule that should be used for determining which points
--   are inside a path.
fillRule :: HasStyle a => FillRule -> a -> a

-- | Lens onto the fill rule of a style.
_fillRule :: Lens' (Style V2 n) FillRule

-- | A record of options that control how a path is stroked.
--   StrokeOpts is an instance of Default, so a
--   StrokeOpts records can be created using with {
--   ... } notation.
data StrokeOpts a
StrokeOpts :: [[a]] -> FillRule -> StrokeOpts a
[_vertexNames] :: StrokeOpts a -> [[a]]
[_queryFillRule] :: StrokeOpts a -> FillRule

-- | Atomic names that should be assigned to the vertices of the path so
--   that they can be referenced later. If there are not enough names, the
--   extra vertices are not assigned names; if there are too many, the
--   extra names are ignored. Note that this is a list of lists of
--   names, since paths can consist of multiple trails. The first list of
--   names are assigned to the vertices of the first trail, the second list
--   to the second trail, and so on.
--   
--   The default value is the empty list.
vertexNames :: Lens (StrokeOpts a) (StrokeOpts a') [[a]] [[a']]

-- | The fill rule used for determining which points are inside the path.
--   The default is Winding. NOTE: for now, this only affects the
--   resulting diagram's Query, not how it will be drawn! To
--   set the fill rule determining how it is to be drawn, use the
--   fillRule function.
queryFillRule :: Lens' (StrokeOpts a) FillRule

-- | Find the intersect points of two objects that can be converted to a
--   path.
intersectPoints :: (InSpace V2 n t, SameSpace t s, ToPath t, ToPath s, OrderedField n) => t -> s -> [P2 n]

-- | Find the intersect points of two objects that can be converted to a
--   path within the given tolerance.
intersectPoints' :: (InSpace V2 n t, SameSpace t s, ToPath t, ToPath s, OrderedField n) => n -> t -> s -> [P2 n]

-- | Compute the intersect points between two paths.
intersectPointsP :: OrderedField n => Path V2 n -> Path V2 n -> [P2 n]

-- | Compute the intersect points between two paths within given tolerance.
intersectPointsP' :: OrderedField n => n -> Path V2 n -> Path V2 n -> [P2 n]

-- | Compute the intersect points between two located trails.
intersectPointsT :: OrderedField n => Located (Trail V2 n) -> Located (Trail V2 n) -> [P2 n]

-- | Compute the intersect points between two located trails within the
--   given tolerance.
intersectPointsT' :: OrderedField n => n -> Located (Trail V2 n) -> Located (Trail V2 n) -> [P2 n]

-- | Clip a diagram by the given path:
--   
--   
--   
- Only the parts of the diagram which lie in the interior of the
--   path will be drawn.
--   
- The envelope of the diagram is unaffected.
--   
clipBy :: (HasStyle a, V a ~ V2, N a ~ n, TypeableFloat n) => Path V2 n -> a -> a

-- | Clip a diagram to the given path setting its envelope to the pointwise
--   minimum of the envelopes of the diagram and path. The trace consists
--   of those parts of the original diagram's trace which fall within the
--   clipping path, or parts of the path's trace within the original
--   diagram.
clipTo :: (TypeableFloat n, Renderable (Path V2 n) b) => Path V2 n -> QDiagram b V2 n Any -> QDiagram b V2 n Any

-- | Clip a diagram to the clip path taking the envelope and trace of the
--   clip path.
clipped :: (TypeableFloat n, Renderable (Path V2 n) b) => Path V2 n -> QDiagram b V2 n Any -> QDiagram b V2 n Any
_Clip :: Iso (Clip n) (Clip n') [Path V2 n] [Path V2 n']

-- | Lens onto the Clip in a style. An empty list means no clipping.
_clip :: (Typeable n, OrderedField n) => Lens' (Style V2 n) [Path V2 n]

-- | Create a centered horizontal (L-R) line of the given length.
--   
--   
--   
--   hruleEx = vcat' (with & sep .~ 0.2) (map hrule [1..5])
--           # centerXY # pad 1.1
--   
hrule :: (InSpace V2 n t, TrailLike t) => n -> t

-- | Create a centered vertical (T-B) line of the given length.
--   
--   
--   
--   vruleEx = hcat' (with & sep .~ 0.2) (map vrule [1, 1.2 .. 2])
--           # centerXY # pad 1.1
--   
vrule :: (InSpace V2 n t, TrailLike t) => n -> t

-- | A circle of radius 1, with center at the origin.
unitCircle :: (TrailLike t, V t ~ V2, N t ~ n, RealFloat n) => t

-- | A circle of the given radius, centered at the origin. As a path, it
--   begins at (r,0).
circle :: (TrailLike t, V t ~ V2, N t ~ n, RealFloat n, Transformable t) => n -> t

-- | ellipse e constructs an ellipse with eccentricity e
--   by scaling the unit circle in the X direction. The eccentricity must
--   be within the interval [0,1).
ellipse :: (TrailLike t, V t ~ V2, N t ~ n, RealFloat n, Transformable t) => n -> t

-- | ellipseXY x y creates an axis-aligned ellipse, centered at
--   the origin, with radius x along the x-axis and radius
--   y along the y-axis.
ellipseXY :: (TrailLike t, V t ~ V2, N t ~ n, RealFloat n, Transformable t) => n -> n -> t

-- | Given a start direction d and a sweep angle s,
--   arc d s is the path of a radius one arc starting at
--   d and sweeping out the angle s counterclockwise (for
--   positive s). The resulting Trail is allowed to wrap around
--   and overlap itself.
arc :: (InSpace V2 n t, OrderedField n, TrailLike t) => Direction V2 n -> Angle n -> t

-- | Given a radus r, a start direction d and an angle
--   s, arc' r d s is the path of a radius
--   (abs r) arc starting at d and sweeping out the angle
--   s counterclockwise (for positive s). The origin of the arc is
--   its center.
--   
--   
--   
--   arc'Ex = mconcat [ arc' r xDir (1/4 @@ turn) | r <- [0.5,-1,1.5] ]
--          # centerXY # pad 1.1
--   
arc' :: (InSpace V2 n t, OrderedField n, TrailLike t) => n -> Direction V2 n -> Angle n -> t

-- | Like arcAngleCCW but clockwise.
arcCW :: (InSpace V2 n t, RealFloat n, TrailLike t) => Direction V2 n -> Direction V2 n -> t

-- | Given a start direction s and end direction e,
--   arcCCW s e is the path of a radius one arc counterclockwise
--   between the two directions. The origin of the arc is its center.
arcCCW :: (InSpace V2 n t, RealFloat n, TrailLike t) => Direction V2 n -> Direction V2 n -> t

-- | Create a circular wedge of the given radius, beginning at the given
--   direction and extending through the given angle.
--   
--   
--   
--   wedgeEx = hcat' (with & sep .~ 0.5)
--     [ wedge 1 xDir (1/4 @@ turn)
--     , wedge 1 (rotate (7/30 @@ turn) xDir) (4/30 @@ turn)
--     , wedge 1 (rotate (1/8 @@ turn) xDir) (3/4 @@ turn)
--     ]
--     # fc blue
--     # centerXY # pad 1.1
--   
wedge :: (InSpace V2 n t, OrderedField n, TrailLike t) => n -> Direction V2 n -> Angle n -> t

-- | arcBetween p q height creates an arc beginning at p
--   and ending at q, with its midpoint at a distance of abs
--   height away from the straight line from p to q.
--   A positive value of height results in an arc to the left of
--   the line from p to q; a negative value yields one to
--   the right.
--   
--   
--   
--   arcBetweenEx = mconcat
--     [ arcBetween origin (p2 (2,1)) ht | ht <- [-0.2, -0.1 .. 0.2] ]
--     # centerXY # pad 1.1
--   
arcBetween :: (TrailLike t, V t ~ V2, N t ~ n, RealFloat n) => Point V2 n -> Point V2 n -> n -> t

-- | Create an annular wedge of the given radii, beginning at the first
--   direction and extending through the given sweep angle. The radius of
--   the outer circle is given first.
--   
--   
--   
--   annularWedgeEx = hsep 0.50
--     [ annularWedge 1 0.5 xDir (1/4 @@ turn)
--     , annularWedge 1 0.3 (rotate (7/30 @@ turn) xDir) (4/30 @@ turn)
--     , annularWedge 1 0.7 (rotate (1/8 @@ turn) xDir) (3/4 @@ turn)
--     ]
--     # fc blue
--     # centerXY # pad 1.1
--   
annularWedge :: (TrailLike t, V t ~ V2, N t ~ n, RealFloat n) => n -> n -> Direction V2 n -> Angle n -> t

-- | Generate the polygon described by the given options.
polygon :: (InSpace V2 n t, TrailLike t, OrderedField n) => PolygonOpts n -> t

-- | Generate a polygon. See PolygonOpts for more information.
polyTrail :: OrderedField n => PolygonOpts n -> Located (Trail V2 n)

-- | Options for specifying a polygon.
data PolygonOpts n
PolygonOpts :: PolyType n -> PolyOrientation n -> Point V2 n -> PolygonOpts n
[_polyType] :: PolygonOpts n -> PolyType n
[_polyOrient] :: PolygonOpts n -> PolyOrientation n
[_polyCenter] :: PolygonOpts n -> Point V2 n

-- | Specification for the polygon's vertices.
polyType :: Lens' (PolygonOpts n) (PolyType n)

-- | Should a rotation be applied to the polygon in order to orient it in a
--   particular way?
polyOrient :: Lens' (PolygonOpts n) (PolyOrientation n)

-- | Should a translation be applied to the polygon in order to place the
--   center at a particular location?
polyCenter :: Lens' (PolygonOpts n) (Point V2 n)

-- | Method used to determine the vertices of a polygon.
data PolyType n

-- | A "polar" polygon.
--   
--   
--   
- The first argument is a list of central angles from
--   each vertex to the next.
--   
- The second argument is a list of radii from the origin to
--   each successive vertex.
--   
--   
--   To construct an n-gon, use a list of n-1 angles and
--   n radii. Extra angles or radii are ignored.
--   
--   Cyclic polygons (with all vertices lying on a circle) can be
--   constructed using a second argument of (repeat r).
PolyPolar :: [Angle n] -> [n] -> PolyType n

-- | A polygon determined by the distance between successive vertices and
--   the external angles formed by each three successive vertices. In other
--   words, a polygon specified by "turtle graphics": go straight ahead x1
--   units; turn by external angle a1; go straight ahead x2 units; turn by
--   external angle a2; etc. The polygon will be centered at the
--   centroid of its vertices.
--   
--   
--   
- The first argument is a list of vertex angles,
--   giving the external angle at each vertex from the previous vertex to
--   the next. The first angle in the list is the external angle at the
--   second vertex; the first edge always starts out heading in the
--   positive y direction from the first vertex.
--   
- The second argument is a list of distances between successive
--   vertices.
--   
--   
--   To construct an n-gon, use a list of n-2 angles and
--   n-1 edge lengths. Extra angles or lengths are ignored.
PolySides :: [Angle n] -> [n] -> PolyType n

-- | A regular polygon with the given number of sides (first argument) and
--   the given radius (second argument).
PolyRegular :: Int -> n -> PolyType n

-- | Determine how a polygon should be oriented.
data PolyOrientation n

-- | No special orientation; the first vertex will be at (1,0). This is the
--   default.
NoOrient :: PolyOrientation n

-- | Orient horizontally, so the bottommost edge is parallel to the
--   x-axis.
OrientH :: PolyOrientation n

-- | Orient vertically, so the leftmost edge is parallel to the
--   y-axis.
OrientV :: PolyOrientation n

-- | Orient so some edge is facing in the
--   direction of, that is, perpendicular to, the given
--   vector.
OrientTo :: (V2 n) -> PolyOrientation n

-- | Options for creating "star" polygons, where the edges connect possibly
--   non-adjacent vertices.
data StarOpts

-- | Specify the order in which the vertices should be connected by a
--   function that maps each vertex index to the index of the vertex that
--   should come next. Indexing of vertices begins at 0.
StarFun :: (Int -> Int) -> StarOpts

-- | Specify a star polygon by a "skip". A skip of 1 indicates a normal
--   polygon, where edges go between successive vertices. A skip of 2 means
--   that edges will connect every second vertex, skipping one in between.
--   Generally, a skip of n means that edges will connect every
--   nth vertex.
StarSkip :: Int -> StarOpts

-- | Create a generalized star polygon. The StarOpts
--   are used to determine in which order the given vertices should be
--   connected. The intention is that the second argument of type
--   [Point v] could be generated by a call to polygon,
--   regPoly, or the like, since a list of vertices is
--   TrailLike. But of course the list can be generated any way you
--   like. A Path v is returned (instead of any
--   TrailLike) because the resulting path may have more than one
--   component, for example if the vertices are to be connected in several
--   disjoint cycles.
star :: OrderedField n => StarOpts -> [Point V2 n] -> Path V2 n

-- | Create a regular polygon. The first argument is the number of sides,
--   and the second is the length of the sides. (Compare to the
--   polygon function with a PolyRegular option, which
--   produces polygons of a given radius).
--   
--   The polygon will be oriented with one edge parallel to the x-axis.
regPoly :: (InSpace V2 n t, TrailLike t, OrderedField n) => Int -> n -> t

-- | An equilateral triangle, with sides of the given length and base
--   parallel to the x-axis.
--   
triangle :: (InSpace V2 n t, TrailLike t, OrderedField n) => n -> t

-- | A synonym for triangle, provided for backwards compatibility.
eqTriangle :: (InSpace V2 n t, TrailLike t, OrderedField n) => n -> t

-- | A square with its center at the origin and sides of the given length,
--   oriented parallel to the axes.
--   
square :: (InSpace V2 n t, TrailLike t, OrderedField n) => n -> t

-- | A regular pentagon, with sides of the given length and base parallel
--   to the x-axis.
--   
pentagon :: (InSpace V2 n t, TrailLike t, OrderedField n) => n -> t

-- | A regular hexagon, with sides of the given length and base parallel to
--   the x-axis.
--   
hexagon :: (InSpace V2 n t, TrailLike t, OrderedField n) => n -> t

-- | A regular heptagon, with sides of the given length and base parallel
--   to the x-axis.
--   
heptagon :: (InSpace V2 n t, TrailLike t, OrderedField n) => n -> t

-- | A synonym for heptagon. It is, however, completely inferior,
--   being a base admixture of the Latin septum (seven) and the
--   Greek γωνία (angle).
septagon :: (InSpace V2 n t, TrailLike t, OrderedField n) => n -> t

-- | A regular octagon, with sides of the given length and base parallel to
--   the x-axis.
--   
octagon :: (InSpace V2 n t, TrailLike t, OrderedField n) => n -> t

-- | A regular nonagon, with sides of the given length and base parallel to
--   the x-axis.
--   
nonagon :: (InSpace V2 n t, TrailLike t, OrderedField n) => n -> t

-- | A regular decagon, with sides of the given length and base parallel to
--   the x-axis.
--   
decagon :: (InSpace V2 n t, TrailLike t, OrderedField n) => n -> t

-- | A regular hendecagon, with sides of the given length and base parallel
--   to the x-axis.
--   
hendecagon :: (InSpace V2 n t, TrailLike t, OrderedField n) => n -> t

-- | A regular dodecagon, with sides of the given length and base parallel
--   to the x-axis.
--   
dodecagon :: (InSpace V2 n t, TrailLike t, OrderedField n) => n -> t

-- | A square with its center at the origin and sides of length 1, oriented
--   parallel to the axes.
--   
unitSquare :: (InSpace V2 n t, TrailLike t, OrderedField n) => t

-- | rect w h is an axis-aligned rectangle of width w and
--   height h, centered at the origin.
--   
rect :: (InSpace V2 n t, TrailLike t, OrderedField n) => n -> n -> t

-- | roundedRect w h r generates a closed trail, or closed path
--   centered at the origin, of an axis-aligned rectangle with width
--   w, height h, and circular rounded corners of radius
--   r. If r is negative the corner will be cut out in a
--   reverse arc. If the size of r is larger than half the smaller
--   dimension of w and h, then it will be reduced to fit
--   in that range, to prevent the corners from overlapping. The trail or
--   path begins with the right edge and proceeds counterclockwise. If you
--   need to specify a different radius for each corner individually, use
--   roundedRect' instead.
--   
--   
--   
--   roundedRectEx = pad 1.1 . centerXY $ hcat' (with & sep .~ 0.2)
--     [ roundedRect  0.5 0.4 0.1
--     , roundedRect  0.5 0.4 (-0.1)
--     , roundedRect' 0.7 0.4 (with & radiusTL .~ 0.2
--                                  & radiusTR .~ -0.2
--                                  & radiusBR .~ 0.1)
--     ]
--   
roundedRect :: (InSpace V2 n t, TrailLike t, RealFloat n) => n -> n -> n -> t

-- | roundedRect' works like roundedRect but allows you
--   to set the radius of each corner indivually, using
--   RoundedRectOpts. The default corner radius is 0. Each radius
--   can also be negative, which results in the curves being reversed to be
--   inward instead of outward.
roundedRect' :: (InSpace V2 n t, TrailLike t, RealFloat n) => n -> n -> RoundedRectOpts n -> t
data RoundedRectOpts d
RoundedRectOpts :: d -> d -> d -> d -> RoundedRectOpts d
[_radiusTL] :: RoundedRectOpts d -> d
[_radiusTR] :: RoundedRectOpts d -> d
[_radiusBL] :: RoundedRectOpts d -> d
[_radiusBR] :: RoundedRectOpts d -> d
radiusTL :: Lens' (RoundedRectOpts d_a35SY) d_a35SY
radiusTR :: Lens' (RoundedRectOpts d_a35SY) d_a35SY
radiusBL :: Lens' (RoundedRectOpts d_a35SY) d_a35SY
radiusBR :: Lens' (RoundedRectOpts d_a35SY) d_a35SY

-- | arrowV v creates an arrow with the direction and norm of the
--   vector v (with its tail at the origin), using default
--   parameters.
arrowV :: (TypeableFloat n, Renderable (Path V2 n) b) => V2 n -> QDiagram b V2 n Any

-- | arrowV' v creates an arrow with the direction and norm of the
--   vector v (with its tail at the origin).
arrowV' :: (TypeableFloat n, Renderable (Path V2 n) b) => ArrowOpts n -> V2 n -> QDiagram b V2 n Any

-- | Create an arrow starting at s with length and direction determined by
--   the vector v.
arrowAt :: (TypeableFloat n, Renderable (Path V2 n) b) => Point V2 n -> V2 n -> QDiagram b V2 n Any
arrowAt' :: (TypeableFloat n, Renderable (Path V2 n) b) => ArrowOpts n -> Point V2 n -> V2 n -> QDiagram b V2 n Any

-- | arrowBetween s e creates an arrow pointing from s to
--   e with default parameters.
arrowBetween :: (TypeableFloat n, Renderable (Path V2 n) b) => Point V2 n -> Point V2 n -> QDiagram b V2 n Any

-- | arrowBetween' opts s e creates an arrow pointing from
--   s to e using the given options. In particular, it
--   scales and rotates arrowShaft to go between s and
--   e, taking head, tail, and gaps into account.
arrowBetween' :: (TypeableFloat n, Renderable (Path V2 n) b) => ArrowOpts n -> Point V2 n -> Point V2 n -> QDiagram b V2 n Any

-- | Connect two diagrams with a straight arrow.
connect :: (TypeableFloat n, Renderable (Path V2 n) b, IsName n1, IsName n2) => n1 -> n2 -> QDiagram b V2 n Any -> QDiagram b V2 n Any

-- | Connect two diagrams with an arbitrary arrow.
connect' :: (TypeableFloat n, Renderable (Path V2 n) b, IsName n1, IsName n2) => ArrowOpts n -> n1 -> n2 -> QDiagram b V2 n Any -> QDiagram b V2 n Any

-- | Connect two diagrams at point on the perimeter of the diagrams,
--   choosen by angle.
connectPerim :: (TypeableFloat n, Renderable (Path V2 n) b, IsName n1, IsName n2) => n1 -> n2 -> Angle n -> Angle n -> QDiagram b V2 n Any -> QDiagram b V2 n Any
connectPerim' :: (TypeableFloat n, Renderable (Path V2 n) b, IsName n1, IsName n2) => ArrowOpts n -> n1 -> n2 -> Angle n -> Angle n -> QDiagram b V2 n Any -> QDiagram b V2 n Any

-- | Draw an arrow from diagram named "n1" to diagram named "n2". The arrow
--   lies on the line between the centres of the diagrams, but is drawn so
--   that it stops at the boundaries of the diagrams, using traces to find
--   the intersection points.
connectOutside :: (TypeableFloat n, Renderable (Path V2 n) b, IsName n1, IsName n2) => n1 -> n2 -> QDiagram b V2 n Any -> QDiagram b V2 n Any
connectOutside' :: (TypeableFloat n, Renderable (Path V2 n) b, IsName n1, IsName n2) => ArrowOpts n -> n1 -> n2 -> QDiagram b V2 n Any -> QDiagram b V2 n Any

-- | arrow len creates an arrow of length len with
--   default parameters, starting at the origin and ending at the point
--   (len,0).
arrow :: (TypeableFloat n, Renderable (Path V2 n) b) => n -> QDiagram b V2 n Any

-- | arrow' opts len creates an arrow of length len using
--   the given options, starting at the origin and ending at the point
--   (len,0). In particular, it scales the given arrowShaft
--   so that the entire arrow has length len.
arrow' :: (TypeableFloat n, Renderable (Path V2 n) b) => ArrowOpts n -> n -> QDiagram b V2 n Any

-- | Straight line arrow shaft.
straightShaft :: OrderedField n => Trail V2 n
data ArrowOpts n
ArrowOpts :: ArrowHT n -> ArrowHT n -> Trail V2 n -> Measure n -> Measure n -> Style V2 n -> Measure n -> Style V2 n -> Measure n -> Style V2 n -> ArrowOpts n
[_arrowHead] :: ArrowOpts n -> ArrowHT n
[_arrowTail] :: ArrowOpts n -> ArrowHT n
[_arrowShaft] :: ArrowOpts n -> Trail V2 n
[_headGap] :: ArrowOpts n -> Measure n
[_tailGap] :: ArrowOpts n -> Measure n
[_headStyle] :: ArrowOpts n -> Style V2 n
[_headLength] :: ArrowOpts n -> Measure n
[_tailStyle] :: ArrowOpts n -> Style V2 n
[_tailLength] :: ArrowOpts n -> Measure n
[_shaftStyle] :: ArrowOpts n -> Style V2 n

-- | A shape to place at the head of the arrow.
arrowHead :: Lens' (ArrowOpts n) (ArrowHT n)

-- | A shape to place at the tail of the arrow.
arrowTail :: Lens' (ArrowOpts n) (ArrowHT n)

-- | The trail to use for the arrow shaft.
arrowShaft :: Lens' (ArrowOpts n) (Trail V2 n)

-- | Distance to leave between the head and the target point.
headGap :: Lens' (ArrowOpts n) (Measure n)

-- | Distance to leave between the starting point and the tail.
tailGap :: Lens' (ArrowOpts n) (Measure n)

-- | Set both the headGap and tailGap simultaneously.
gaps :: Traversal' (ArrowOpts n) (Measure n)

-- | Same as gaps, provided for backward compatiiblity.
gap :: Traversal' (ArrowOpts n) (Measure n)

-- | A lens for setting or modifying the texture of an arrowhead. For
--   example, one may write ... (with & headTexture .~ grad)
--   to get an arrow with a head filled with a gradient, assuming grad has
--   been defined. Or ... (with & headTexture .~ solid blue to
--   set the head color to blue. For more general control over the style of
--   arrowheads, see headStyle.
headTexture :: TypeableFloat n => Lens' (ArrowOpts n) (Texture n)

-- | Style to apply to the head. headStyle is modified by using
--   the lens combinator %~ to change the current style. For
--   example, to change an opaque black arrowhead to translucent orange:
--   (with & headStyle %~ fc orange . opacity 0.75).
headStyle :: Lens' (ArrowOpts n) (Style V2 n)

-- | A lens for setting or modifying the texture of an arrow tail. This is
--   *not* a valid lens (see committed).
tailTexture :: TypeableFloat n => Lens' (ArrowOpts n) (Texture n)

-- | Style to apply to the tail. See headStyle.
tailStyle :: Lens' (ArrowOpts n) (Style V2 n)

-- | A lens for setting or modifying the texture of an arrow shaft.
shaftTexture :: TypeableFloat n => Lens' (ArrowOpts n) (Texture n)

-- | Style to apply to the shaft. See headStyle.
shaftStyle :: Lens' (ArrowOpts n) (Style V2 n)

-- | The length from the start of the joint to the tip of the head.
headLength :: Lens' (ArrowOpts n) (Measure n)

-- | The length of the tail plus its joint.
tailLength :: Lens' (ArrowOpts n) (Measure n)

-- | Set both the headLength and tailLength
--   simultaneously.
lengths :: Traversal' (ArrowOpts n) (Measure n)

-- | Create a primitive text diagram from the given string, with center
--   alignment, equivalent to alignedText 0.5 0.5.
--   
--   Note that it takes up no space, as text size information is not
--   available.
text :: (TypeableFloat n, Renderable (Text n) b) => String -> QDiagram b V2 n Any

-- | Create a primitive text diagram from the given string, origin at the
--   top left corner of the text's bounding box, equivalent to
--   alignedText 0 1.
--   
--   Note that it takes up no space.
topLeftText :: (TypeableFloat n, Renderable (Text n) b) => String -> QDiagram b V2 n Any

-- | Create a primitive text diagram from the given string, with the origin
--   set to a point interpolated within the bounding box. The first
--   parameter varies from 0 (left) to 1 (right), and the second parameter
--   from 0 (bottom) to 1 (top). Some backends do not implement this and
--   instead snap to closest corner or the center.
--   
--   The height of this box is determined by the font's potential ascent
--   and descent, rather than the height of the particular string.
--   
--   Note that it takes up no space.
alignedText :: (TypeableFloat n, Renderable (Text n) b) => n -> n -> String -> QDiagram b V2 n Any

-- | Create a primitive text diagram from the given string, with the origin
--   set to be on the baseline, at the beginning (although not bounding).
--   This is the reference point of showText in the Cairo graphics library.
--   
--   Note that it takes up no space.
baselineText :: (TypeableFloat n, Renderable (Text n) b) => String -> QDiagram b V2 n Any

-- | Specify a font family to be used for all text within a diagram.
font :: HasStyle a => String -> a -> a

-- | Set all text in italics.
italic :: HasStyle a => a -> a

-- | Set all text using an oblique slant.
oblique :: HasStyle a => a -> a

-- | Set all text using a bold font weight.
bold :: HasStyle a => a -> a

-- | Set the font size, that is, the size of the font's em-square as
--   measured within the current local vector space. The default size is
--   1.
fontSize :: (N a ~ n, Typeable n, HasStyle a) => Measure n -> a -> a

-- | Lens onto the font name of a style.
_font :: (Typeable n, OrderedField n) => Lens' (Style v n) (Maybe String)
_fontSizeR :: (Typeable n, OrderedField n) => Lens' (Style v n) (Measured n (Recommend n))

-- | Lens to commit a font size. This is *not* a valid lens (see
--   commited.
_fontSize :: (Typeable n, OrderedField n) => Lens' (Style v n) (Measure n)

-- | A convenient synonym for 'fontSize (Output w)'.
fontSizeO :: (N a ~ n, Typeable n, Num n, HasStyle a) => n -> a -> a

-- | A convenient sysnonym for 'fontSize (Local w)'.
fontSizeL :: (N a ~ n, Typeable n, Num n, HasStyle a) => n -> a -> a

-- | A convenient synonym for 'fontSize (Normalized w)'.
fontSizeN :: (N a ~ n, Typeable n, Num n, HasStyle a) => n -> a -> a

-- | A convenient synonym for 'fontSize (Global w)'.
fontSizeG :: (N a ~ n, Typeable n, Num n, HasStyle a) => n -> a -> a

-- | An image primitive, the two ints are width followed by height. Will
--   typically be created by loadImageEmb or loadImageExt
--   which, will handle setting the width and height to the actual width
--   and height of the image.
data DImage :: * -> * -> *
DImage :: ImageData t -> Int -> Int -> Transformation V2 n -> DImage n t

-- | ImageData is either a JuicyPixels DynamicImage tagged
--   as Embedded or a reference tagged as External.
--   Additionally Native is provided for external libraries to hook
--   into.
data ImageData :: * -> *
ImageRaster :: DynamicImage -> ImageData Embedded
ImageRef :: FilePath -> ImageData External
ImageNative :: t -> ImageData (Native t)
data Embedded
data External
data Native (t :: *)

-- | Make a DImage into a Diagram.
image :: (TypeableFloat n, Typeable a, Renderable (DImage n a) b) => DImage n a -> QDiagram b V2 n Any

-- | Use JuicyPixels to read an image in any format and wrap it in a
--   DImage. The width and height of the image are set to their
--   actual values.
loadImageEmb :: Num n => FilePath -> IO (Either String (DImage n Embedded))

-- | Check that a file exists, and use JuicyPixels to figure out the right
--   size, but save a reference to the image instead of the raster data
loadImageExt :: Num n => FilePath -> IO (Either String (DImage n External))

-- | Make an "unchecked" image reference; have to specify a width and
--   height. Unless the aspect ratio of the external image is the w :: h,
--   then the image will be distorted.
uncheckedImageRef :: Num n => FilePath -> Int -> Int -> DImage n External

-- | Create an image "from scratch" by specifying the pixel data
raster :: Num n => (Int -> Int -> AlphaColour Double) -> Int -> Int -> DImage n Embedded

-- | Crate a diagram from raw raster data.
rasterDia :: (TypeableFloat n, Renderable (DImage n Embedded) b) => (Int -> Int -> AlphaColour Double) -> Int -> Int -> QDiagram b V2 n Any

-- | Create a transformation which performs a rotation about the local
--   origin by the given angle. See also rotate.
rotation :: Floating n => Angle n -> T2 n

-- | Rotate about the local origin by the given angle. Positive angles
--   correspond to counterclockwise rotation, negative to clockwise. The
--   angle can be expressed using any of the Isos on Angle.
--   For example, rotate (1/4 @@ turn), rotate (tau/4
--   @@ rad), and rotate (90 @@ deg) all represent the same
--   transformation, namely, a counterclockwise rotation by a right angle.
--   To rotate about some point other than the local origin, see
--   rotateAbout.
--   
--   Note that writing rotate (1/4), with no Angle
--   constructor, will yield an error since GHC cannot figure out which
--   sort of angle you want to use. In this common situation you can use
--   rotateBy, which interprets its argument as a number of turns.
rotate :: (InSpace V2 n t, Transformable t, Floating n) => Angle n -> t -> t

-- | A synonym for rotate, interpreting its argument in units of
--   turns; it can be more convenient to write rotateBy (1/4) than
--   rotate (1/4 @@ turn).
rotateBy :: (InSpace V2 n t, Transformable t, Floating n) => n -> t -> t

-- | Use an Angle to make an Iso between an object rotated
--   and unrotated. This us useful for performing actions under a
--   rotation:
--   
--   
--   under (rotated t) f = rotate (negated t) . f . rotate t
--   rotated t ## a      = rotate t a
--   a ^. rotated t      = rotate (-t) a
--   over (rotated t) f  = rotate t . f . rotate (negated t)
--   
rotated :: (InSpace V2 n a, Floating n, SameSpace a b, Transformable a, Transformable b) => Angle n -> Iso a b a b

-- | rotationAbout p is a rotation about the point p
--   (instead of around the local origin).
rotationAround :: Floating n => P2 n -> Angle n -> T2 n

-- | rotateAbout p is like rotate, except it rotates around
--   the point p instead of around the local origin.
rotateAround :: (InSpace V2 n t, Transformable t, Floating n) => P2 n -> Angle n -> t -> t

-- | The rotation that aligns the x-axis with the given direction.
rotationTo :: OrderedField n => Direction V2 n -> T2 n

-- | Rotate around the local origin such that the x axis aligns with the
--   given direction.
rotateTo :: (InSpace V2 n t, OrderedField n, Transformable t) => Direction V2 n -> t -> t

-- | Construct a transformation which scales by the given factor in the x
--   (horizontal) direction.
scalingX :: (Additive v, R1 v, Fractional n) => n -> Transformation v n

-- | Scale a diagram by the given factor in the x (horizontal) direction.
--   To scale uniformly, use scale.
scaleX :: (InSpace v n t, R2 v, Fractional n, Transformable t) => n -> t -> t

-- | Construct a transformation which scales by the given factor in the y
--   (vertical) direction.
scalingY :: (Additive v, R2 v, Fractional n) => n -> Transformation v n

-- | Scale a diagram by the given factor in the y (vertical) direction. To
--   scale uniformly, use scale.
scaleY :: (InSpace v n t, R2 v, Fractional n, Transformable t) => n -> t -> t

-- | Create a uniform scaling transformation.
scaling :: (Additive v, Fractional n) => n -> Transformation v n

-- | Scale uniformly in every dimension by the given scalar.
scale :: (InSpace v n a, Eq n, Fractional n, Transformable a) => n -> a -> a

-- | scaleToX w scales a diagram in the x (horizontal) direction
--   by whatever factor required to make its width w.
--   scaleToX should not be applied to diagrams with a width of 0,
--   such as vrule.
scaleToX :: (InSpace v n t, R2 v, Enveloped t, Transformable t) => n -> t -> t

-- | scaleToY h scales a diagram in the y (vertical) direction by
--   whatever factor required to make its height h.
--   scaleToY should not be applied to diagrams with a height of
--   0, such as hrule.
scaleToY :: (InSpace v n t, R2 v, Enveloped t, Transformable t) => n -> t -> t

-- | scaleUToX w scales a diagram uniformly by whatever
--   factor required to make its width w. scaleUToX
--   should not be applied to diagrams with a width of 0, such as
--   vrule.
scaleUToX :: (InSpace v n t, R1 v, Enveloped t, Transformable t) => n -> t -> t

-- | scaleUToY h scales a diagram uniformly by whatever
--   factor required to make its height h. scaleUToY
--   should not be applied to diagrams with a height of 0, such as
--   hrule.
scaleUToY :: (InSpace v n t, R2 v, Enveloped t, Transformable t) => n -> t -> t

-- | Construct a transformation which translates by the given distance in
--   the x (horizontal) direction.
translationX :: (Additive v, R1 v, Num n) => n -> Transformation v n

-- | Translate a diagram by the given distance in the x (horizontal)
--   direction.
translateX :: (InSpace v n t, R1 v, Transformable t) => n -> t -> t

-- | Construct a transformation which translates by the given distance in
--   the y (vertical) direction.
translationY :: (Additive v, R2 v, Num n) => n -> Transformation v n

-- | Translate a diagram by the given distance in the y (vertical)
--   direction.
translateY :: (InSpace v n t, R2 v, Transformable t) => n -> t -> t

-- | Create a translation.
translation :: v n -> Transformation v n

-- | Translate by a vector.
translate :: (Num (N t), Transformable t) => Vn t -> t -> t

-- | Construct a transformation which flips a diagram from left to right,
--   i.e. sends the point (x,y) to (-x,y).
reflectionX :: (Additive v, R1 v, Num n) => Transformation v n

-- | Flip a diagram from left to right, i.e. send the point (x,y) to
--   (-x,y).
reflectX :: (InSpace v n t, R1 v, Transformable t) => t -> t

-- | Construct a transformation which flips a diagram from top to bottom,
--   i.e. sends the point (x,y) to (x,-y).
reflectionY :: (Additive v, R2 v, Num n) => Transformation v n

-- | Flip a diagram from top to bottom, i.e. send the point (x,y) to
--   (x,-y).
reflectY :: (InSpace v n t, R2 v, Transformable t) => t -> t

-- | reflectionAbout p d is a reflection in the line determined by
--   the point p and direction d.
reflectionAbout :: OrderedField n => P2 n -> Direction V2 n -> T2 n

-- | reflectAbout p d reflects a diagram in the line determined by
--   the point p and direction d.
reflectAbout :: (InSpace V2 n t, OrderedField n, Transformable t) => P2 n -> Direction V2 n -> t -> t

-- | shearingX d is the linear transformation which is the
--   identity on y coordinates and sends (0,1) to (d,1).
shearingX :: Num n => n -> T2 n

-- | shearX d performs a shear in the x-direction which sends
--   (0,1) to (d,1).
shearX :: (InSpace V2 n t, Transformable t) => n -> t -> t

-- | shearingY d is the linear transformation which is the
--   identity on x coordinates and sends (1,0) to (1,d).
shearingY :: Num n => n -> T2 n

-- | shearY d performs a shear in the y-direction which sends
--   (1,0) to (1,d).
shearY :: (InSpace V2 n t, Transformable t) => n -> t -> t

-- | The parallel projection onto the plane x=0
parallelX0 :: (R1 v, Num n) => Deformation v v n

-- | The perspective division onto the plane x=1 along lines going through
--   the origin.
perspectiveX1 :: (R1 v, Functor v, Fractional n) => Deformation v v n

-- | The parallel projection onto the plane y=0
parallelY0 :: (R2 v, Num n) => Deformation v v n

-- | The perspective division onto the plane y=1 along lines going through
--   the origin.
perspectiveY1 :: (R2 v, Functor v, Floating n) => Deformation v v n

-- | The viewing transform for a viewer facing along the positive X axis. X
--   coördinates stay fixed, while Y coördinates are compressed with
--   increasing distance. asDeformation (translation unitX) <>
--   parallelX0 <> frustrumX = perspectiveX1
facingX :: (R1 v, Functor v, Fractional n) => Deformation v v n
facingY :: (R2 v, Functor v, Fractional n) => Deformation v v n

-- | Place two diagrams (or other objects) vertically adjacent to one
--   another, with the first diagram above the second. Since Haskell
--   ignores whitespace in expressions, one can thus write
--   
--   
--    c
--   ===
--    d
--   
--   
--   
--   to place c above d. The local origin of the
--   resulting combined diagram is the same as the local origin of the
--   first. (===) is associative and has mempty as an
--   identity. See the documentation of beside for more information.
(===) :: (InSpace V2 n a, Num n, Juxtaposable a, Semigroup a) => a -> a -> a

-- | Place two diagrams (or other juxtaposable objects) horizontally
--   adjacent to one another, with the first diagram to the left of the
--   second. The local origin of the resulting combined diagram is the same
--   as the local origin of the first. (|||) is associative and
--   has mempty as an identity. See the documentation of
--   beside for more information.
(|||) :: (InSpace V2 n a, Num n, Juxtaposable a, Semigroup a) => a -> a -> a

-- | Lay out a list of juxtaposable objects in a row from left to right, so
--   that their local origins lie along a single horizontal line, with
--   successive envelopes tangent to one another.
--   
--   
--   
- For more control over the spacing, see hcat'.
--   
- To align the diagrams vertically (or otherwise), use alignment
--   combinators (such as alignT or alignB) from
--   Diagrams.TwoD.Align before applying hcat.
--   
- For non-axis-aligned layout, see cat.
--   
hcat :: (InSpace V2 n a, Floating n, Juxtaposable a, HasOrigin a, Monoid' a) => [a] -> a

-- | A variant of hcat taking an extra CatOpts record to
--   control the spacing. See the cat' documentation for a
--   description of the possibilities. For the common case of setting just
--   a separation amount, see hsep.
hcat' :: (InSpace V2 n a, Floating n, Juxtaposable a, HasOrigin a, Monoid' a) => CatOpts n -> [a] -> a

-- | A convenient synonym for horizontal concatenation with separation:
--   hsep s === hcat' (with & sep .~ s).
hsep :: (InSpace V2 n a, Floating n, Juxtaposable a, HasOrigin a, Monoid' a) => n -> [a] -> a

-- | Lay out a list of juxtaposable objects in a column from top to bottom,
--   so that their local origins lie along a single vertical line, with
--   successive envelopes tangent to one another.
--   
--   
--   
- For more control over the spacing, see vcat'.
--   
- To align the diagrams horizontally (or otherwise), use alignment
--   combinators (such as alignL or alignR) from
--   Diagrams.TwoD.Align before applying vcat.
--   
- For non-axis-aligned layout, see cat.
--   
vcat :: (InSpace V2 n a, Floating n, Juxtaposable a, HasOrigin a, Monoid' a) => [a] -> a

-- | A variant of vcat taking an extra CatOpts record to
--   control the spacing. See the cat' documentation for a
--   description of the possibilities. For the common case of setting just
--   a separation amount, see vsep.
vcat' :: (InSpace V2 n a, Floating n, Juxtaposable a, HasOrigin a, Monoid' a) => CatOpts n -> [a] -> a

-- | A convenient synonym for vertical concatenation with separation:
--   vsep s === vcat' (with & sep .~ s).
vsep :: (InSpace V2 n a, Floating n, Juxtaposable a, HasOrigin a, Monoid' a) => n -> [a] -> a

-- | strutX w is an empty diagram with width w, height 0,
--   and a centered local origin. Note that strutX (-w) behaves
--   the same as strutX w.
strutX :: (Metric v, R1 v, OrderedField n, Monoid' m) => n -> QDiagram b v n m

-- | strutY h is an empty diagram with height h, width 0,
--   and a centered local origin. Note that strutY (-h) behaves
--   the same as strutY h.
strutY :: (Metric v, R2 v, OrderedField n, Monoid' m) => n -> QDiagram b v n m

-- | padX s "pads" a diagram in the x-direction, expanding its
--   envelope horizontally by a factor of s (factors between 0 and
--   1 can be used to shrink the envelope). Note that the envelope will
--   expand with respect to the local origin, so if the origin is not
--   centered horizontally the padding may appear "uneven". If this is not
--   desired, the origin can be centered (using centerX) before
--   applying padX.
padX :: (Metric v, R2 v, OrderedField n, Monoid' m) => n -> QDiagram b v n m -> QDiagram b v n m

-- | padY s "pads" a diagram in the y-direction, expanding its
--   envelope vertically by a factor of s (factors between 0 and 1
--   can be used to shrink the envelope). Note that the envelope will
--   expand with respect to the local origin, so if the origin is not
--   centered vertically the padding may appear "uneven". If this is not
--   desired, the origin can be centered (using centerY) before
--   applying padY.
padY :: (Metric v, R2 v, Monoid' m, OrderedField n) => n -> QDiagram b v n m -> QDiagram b v n m

-- | extrudeLeft s "extrudes" a diagram in the negative
--   x-direction, offsetting its envelope by the provided distance. When
--    s < 0 , the envelope is inset instead.
--   
--   See the documentation for extrudeEnvelope for more information.
extrudeLeft :: (OrderedField n, Monoid' m) => n -> QDiagram b V2 n m -> QDiagram b V2 n m

-- | extrudeRight s "extrudes" a diagram in the positive
--   x-direction, offsetting its envelope by the provided distance. When
--    s < 0 , the envelope is inset instead.
--   
--   See the documentation for extrudeEnvelope for more information.
extrudeRight :: (OrderedField n, Monoid' m) => n -> QDiagram b V2 n m -> QDiagram b V2 n m

-- | extrudeBottom s "extrudes" a diagram in the negative
--   y-direction, offsetting its envelope by the provided distance. When
--    s < 0 , the envelope is inset instead.
--   
--   See the documentation for extrudeEnvelope for more information.
extrudeBottom :: (OrderedField n, Monoid' m) => n -> QDiagram b V2 n m -> QDiagram b V2 n m

-- | extrudeTop s "extrudes" a diagram in the positive
--   y-direction, offsetting its envelope by the provided distance. When
--    s < 0 , the envelope is inset instead.
--   
--   See the documentation for extrudeEnvelope for more information.
extrudeTop :: (OrderedField n, Monoid' m) => n -> QDiagram b V2 n m -> QDiagram b V2 n m

-- | rectEnvelope p v sets the envelope of a diagram to a
--   rectangle whose lower-left corner is at p and whose
--   upper-right corner is at p .+^ v. Useful for selecting the
--   rectangular portion of a diagram which should actually be "viewed" in
--   the final render, if you don't want to see the entire diagram.
rectEnvelope :: (OrderedField n, Monoid' m) => Point V2 n -> V2 n -> QDiagram b V2 n m -> QDiagram b V2 n m

-- | Construct a bounding rectangle for an enveloped object, that is, the
--   smallest axis-aligned rectangle which encloses the object.
boundingRect :: (InSpace V2 n a, SameSpace a t, Enveloped t, Transformable t, TrailLike t, Monoid t, Enveloped a) => a -> t

-- | "Set the background color" of a diagram. That is, place a diagram atop
--   a bounding rectangle of the given color.
bg :: (TypeableFloat n, Renderable (Path V2 n) b) => Colour Double -> QDiagram b V2 n Any -> QDiagram b V2 n Any

-- | Similar to bg but makes the colored background rectangle larger
--   than the diagram. The first parameter is used to set how far the
--   background extends beyond the diagram.
bgFrame :: (TypeableFloat n, Renderable (Path V2 n) b) => n -> Colour Double -> QDiagram b V2 n Any -> QDiagram b V2 n Any

-- | Align along the left edge, i.e. translate the diagram in a horizontal
--   direction so that the local origin is on the left edge of the
--   envelope.
alignL :: (InSpace V2 n a, Fractional n, Alignable a, HasOrigin a) => a -> a

-- | Align along the right edge.
alignR :: (InSpace V2 n a, Fractional n, Alignable a, HasOrigin a) => a -> a

-- | Align along the top edge.
alignT :: (InSpace V2 n a, Fractional n, Alignable a, HasOrigin a) => a -> a

-- | Align along the bottom edge.
alignB :: (InSpace V2 n a, Fractional n, Alignable a, HasOrigin a) => a -> a
alignTL :: (InSpace V2 n a, Fractional n, Alignable a, HasOrigin a) => a -> a
alignTR :: (InSpace V2 n a, Fractional n, Alignable a, HasOrigin a) => a -> a
alignBL :: (InSpace V2 n a, Fractional n, Alignable a, HasOrigin a) => a -> a
alignBR :: (InSpace V2 n a, Fractional n, Alignable a, HasOrigin a) => a -> a

-- | alignX and snugX move the local origin horizontally
--   as follows:
--   
--   
--   
- alignX (-1) moves the local origin to the left edge of
--   the boundary;
--   
- align 1 moves the local origin to the right edge;
--   
- any other argument interpolates linearly between these. For
--   example, alignX 0 centers, alignX 2 moves the origin
--   one "radius" to the right of the right edge, and so on.
--   
- snugX works the same way.
--   
alignX :: (InSpace v n a, R1 v, Fractional n, Alignable a, HasOrigin a) => n -> a -> a

-- | Like alignX, but moving the local origin vertically, with an
--   argument of 1 corresponding to the top edge and (-1)
--   corresponding to the bottom edge.
alignY :: (InSpace v n a, R2 v, Fractional n, Alignable a, HasOrigin a) => n -> a -> a

-- | Center the local origin along the X-axis.
centerX :: (InSpace v n a, R1 v, Fractional n, Alignable a, HasOrigin a) => a -> a

-- | Center the local origin along the Y-axis.
centerY :: (InSpace v n a, R2 v, Fractional n, Alignable a, HasOrigin a) => a -> a

-- | Center along both the X- and Y-axes.
centerXY :: (InSpace v n a, R2 v, Fractional n, Alignable a, HasOrigin a) => a -> a
snugL :: (InSpace V2 n a, Fractional n, Alignable a, Traced a, HasOrigin a) => a -> a
snugR :: (InSpace V2 n a, Fractional n, Alignable a, Traced a, HasOrigin a) => a -> a
snugT :: (InSpace V2 n a, Fractional n, Alignable a, Traced a, HasOrigin a) => a -> a
snugB :: (InSpace V2 n a, Fractional n, Alignable a, Traced a, HasOrigin a) => a -> a
snugTL :: (InSpace V2 n a, Fractional n, Alignable a, Traced a, HasOrigin a) => a -> a
snugTR :: (InSpace V2 n a, Fractional n, Alignable a, Traced a, HasOrigin a) => a -> a
snugBL :: (InSpace V2 n a, Fractional n, Alignable a, Traced a, HasOrigin a) => a -> a
snugBR :: (InSpace V2 n a, Fractional n, Alignable a, Traced a, HasOrigin a) => a -> a

-- | See the documentation for alignX.
snugX :: (InSpace v n a, R1 v, Fractional n, Alignable a, Traced a, HasOrigin a) => n -> a -> a

-- | See the documentation for alignY.
snugY :: (InSpace v n a, R2 v, Fractional n, Alignable a, Traced a, HasOrigin a) => n -> a -> a
snugCenterX :: (InSpace v n a, R1 v, Fractional n, Alignable a, Traced a, HasOrigin a) => a -> a
snugCenterY :: (InSpace v n a, R2 v, Fractional n, Alignable a, Traced a, HasOrigin a) => a -> a
snugCenterXY :: (InSpace v n a, R2 v, Fractional n, Alignable a, Traced a, HasOrigin a) => a -> a

-- | Compute the width of an enveloped object.
--   
--   Note this is just diameter unitX.
width :: (InSpace V2 n a, Enveloped a) => a -> n

-- | Compute the height of an enveloped object.
height :: (InSpace V2 n a, Enveloped a) => a -> n

-- | Compute the absolute x-coordinate range of an enveloped object in the
--   form (lo,hi). Return Nothing for objects with an
--   empty envelope.
--   
--   Note this is just extent unitX.
extentX :: (InSpace v n a, R1 v, Enveloped a) => a -> Maybe (n, n)

-- | Compute the absolute y-coordinate range of an enveloped object in the
--   form (lo,hi). Return Nothing for objects with an
--   empty envelope.
extentY :: (InSpace v n a, R2 v, Enveloped a) => a -> Maybe (n, n)

-- | Make a SizeSpec from possibly-specified width and height.
mkSizeSpec2D :: Num n => Maybe n -> Maybe n -> SizeSpec V2 n

-- | Make a SizeSpec with only width defined.
mkWidth :: Num n => n -> SizeSpec V2 n

-- | Make a SizeSpec with only height defined.
mkHeight :: Num n => n -> SizeSpec V2 n

-- | Make a SizeSpec from a width and height.
dims2D :: n -> n -> SizeSpec V2 n

-- | A Texture is either a color SC, linear gradient LG, or
--   radial gradient RG. An object can have only one texture which
--   is determined by the Last semigroup structure.
data Texture n
SC :: SomeColor -> Texture n
LG :: (LGradient n) -> Texture n
RG :: (RGradient n) -> Texture n

-- | Convert a solid colour into a texture.
solid :: Color a => a -> Texture n

-- | The SpreadMethod determines what happens before
--   lGradStart and after lGradEnd. GradPad fills the
--   space before the start of the gradient with the color of the first
--   stop and the color after end of the gradient with the color of the
--   last stop. GradRepeat restarts the gradient and
--   GradReflect restarts the gradient with the stops in reverse
--   order.
data SpreadMethod
GradPad :: SpreadMethod
GradReflect :: SpreadMethod
GradRepeat :: SpreadMethod

-- | A gradient stop contains a color and fraction (usually between 0 and
--   1)
data GradientStop d
GradientStop :: SomeColor -> d -> GradientStop d
[_stopColor] :: GradientStop d -> SomeColor
[_stopFraction] :: GradientStop d -> d
_FillTexture :: Iso' (FillTexture n) (Recommend (Texture n))
fillTexture :: (InSpace V2 n a, Typeable n, Floating n, HasStyle a) => Texture n -> a -> a

-- | Commit a fill texture in a style. This is not a valid setter
--   because it doesn't abide the functor law (see committed).
_fillTexture :: (Typeable n, Floating n) => Lens' (Style V2 n) (Texture n)
getFillTexture :: FillTexture n -> Texture n
_LineTexture :: Iso (LineTexture n) (LineTexture n') (Texture n) (Texture n')
lineTexture :: (InSpace V2 n a, Typeable n, Floating n, HasStyle a) => Texture n -> a -> a
_lineTexture :: (Floating n, Typeable n) => Lens' (Style V2 n) (Texture n)
lineTextureA :: (InSpace V2 n a, Typeable n, Floating n, HasStyle a) => LineTexture n -> a -> a
getLineTexture :: LineTexture n -> Texture n

-- | The fraction for stop.
stopFraction :: Lens' (GradientStop n) n

-- | A color for the stop.
stopColor :: Lens' (GradientStop n) SomeColor

-- | A convenient function for making gradient stops from a list of
--   triples. (An opaque color, a stop fraction, an opacity).
mkStops :: [(Colour Double, d, Double)] -> [GradientStop d]

-- | Linear Gradient
data LGradient n
LGradient :: [GradientStop n] -> Point V2 n -> Point V2 n -> Transformation V2 n -> SpreadMethod -> LGradient n
[_lGradStops] :: LGradient n -> [GradientStop n]
[_lGradStart] :: LGradient n -> Point V2 n
[_lGradEnd] :: LGradient n -> Point V2 n
[_lGradTrans] :: LGradient n -> Transformation V2 n
[_lGradSpreadMethod] :: LGradient n -> SpreadMethod
_LG :: Prism' (Texture n_a46yH) (LGradient n_a46yH)

-- | A list of stops (colors and fractions).
lGradStops :: Lens' (LGradient n) [GradientStop n]

-- | A transformation to be applied to the gradient. Usually this field
--   will start as the identity transform and capture the transforms that
--   are applied to the gradient.
lGradTrans :: Lens' (LGradient n) (Transformation V2 n)

-- | The starting point for the first gradient stop. The coordinates are in
--   local units and the default is (-0.5, 0).
lGradStart :: Lens' (LGradient n) (Point V2 n)

-- | The ending point for the last gradient stop.The coordinates are in
--   local units and the default is (0.5, 0).
lGradEnd :: Lens' (LGradient n) (Point V2 n)

-- | For setting the spread method.
lGradSpreadMethod :: Lens' (LGradient n) SpreadMethod

-- | A default is provided so that linear gradients can easily be created
--   using lenses. For example, lg = defaultLG & lGradStart .~
--   (0.25 ^& 0.33). Note that no default value is provided for
--   lGradStops, this must be set before the gradient value is
--   used, otherwise the object will appear transparent.
defaultLG :: Fractional n => Texture n

-- | Make a linear gradient texture from a stop list, start point, end
--   point, and SpreadMethod. The lGradTrans field is set to
--   the identity transfrom, to change it use the lGradTrans lens.
mkLinearGradient :: Num n => [GradientStop n] -> Point V2 n -> Point V2 n -> SpreadMethod -> Texture n

-- | Radial Gradient
data RGradient n
RGradient :: [GradientStop n] -> Point V2 n -> n -> Point V2 n -> n -> Transformation V2 n -> SpreadMethod -> RGradient n
[_rGradStops] :: RGradient n -> [GradientStop n]
[_rGradCenter0] :: RGradient n -> Point V2 n
[_rGradRadius0] :: RGradient n -> n
[_rGradCenter1] :: RGradient n -> Point V2 n
[_rGradRadius1] :: RGradient n -> n
[_rGradTrans] :: RGradient n -> Transformation V2 n
[_rGradSpreadMethod] :: RGradient n -> SpreadMethod

-- | A list of stops (colors and fractions).
rGradStops :: Lens' (RGradient n) [GradientStop n]

-- | The center point of the inner circle.
rGradCenter0 :: Lens' (RGradient n) (Point V2 n)

-- | The radius of the inner cirlce in local coordinates.
rGradRadius0 :: Lens' (RGradient n) n

-- | The center of the outer circle.
rGradCenter1 :: Lens' (RGradient n) (Point V2 n)

-- | The radius of the outer circle in local coordinates.
rGradRadius1 :: Lens' (RGradient n) n

-- | A transformation to be applied to the gradient. Usually this field
--   will start as the identity transform and capture the transforms that
--   are applied to the gradient.
rGradTrans :: Lens' (RGradient n) (Transformation V2 n)

-- | For setting the spread method.
rGradSpreadMethod :: Lens' (RGradient n) SpreadMethod

-- | A default is provided so that radial gradients can easily be created
--   using lenses. For example, rg = defaultRG & rGradRadius1 .~
--   0.25. Note that no default value is provided for
--   rGradStops, this must be set before the gradient value is
--   used, otherwise the object will appear transparent.
defaultRG :: Fractional n => Texture n
_RG :: Prism' (Texture n_a46yH) (RGradient n_a46yH)

-- | Make a radial gradient texture from a stop list, radius, start point,
--   end point, and SpreadMethod. The rGradTrans field is set
--   to the identity transfrom, to change it use the rGradTrans
--   lens.
mkRadialGradient :: Num n => [GradientStop n] -> Point V2 n -> n -> Point V2 n -> n -> SpreadMethod -> Texture n

-- | Set the fill color. This function is polymorphic in the color type (so
--   it can be used with either Colour or AlphaColour), but
--   this can sometimes create problems for type inference, so the
--   fc and fcA variants are provided with more concrete
--   types.
fillColor :: (InSpace V2 n a, Color c, Typeable n, Floating n, HasStyle a) => c -> a -> a
_SC :: Prism' (Texture n_a46yH) SomeColor

-- | Prism onto an AlphaColour Double of a SC texture.
_AC :: Prism' (Texture n) (AlphaColour Double)

-- | A synonym for fillColor, specialized to Colour
--   Double (i.e. opaque colors). See comment after fillColor
--   about backends.
fc :: (InSpace V2 n a, Floating n, Typeable n, HasStyle a) => Colour Double -> a -> a

-- | A synonym for fillColor, specialized to AlphaColour
--   Double (i.e. colors with transparency). See comment after
--   fillColor about backends.
fcA :: (InSpace V2 n a, Floating n, Typeable n, HasStyle a) => AlphaColour Double -> a -> a

-- | Set a "recommended" fill color, to be used only if no explicit calls
--   to fillColor (or fc, or fcA) are used. See
--   comment after fillColor about backends.
recommendFillColor :: (InSpace V2 n a, Color c, Typeable n, Floating n, HasStyle a) => c -> a -> a

-- | Set the line (stroke) color. This function is polymorphic in the color
--   type (so it can be used with either Colour or
--   AlphaColour), but this can sometimes create problems for type
--   inference, so the lc and lcA variants are provided with
--   more concrete types.
lineColor :: (InSpace V2 n a, Color c, Typeable n, Floating n, HasStyle a) => c -> a -> a

-- | A synonym for lineColor, specialized to Colour
--   Double (i.e. opaque colors). See comment in lineColor
--   about backends.
lc :: (InSpace V2 n a, Typeable n, Floating n, HasStyle a) => Colour Double -> a -> a

-- | A synonym for lineColor, specialized to AlphaColour
--   Double (i.e. colors with transparency). See comment in
--   lineColor about backends.
lcA :: (InSpace V2 n a, Typeable n, Floating n, HasStyle a) => AlphaColour Double -> a -> a

-- | Mark the origin of a diagram by placing a red dot 1/50th its size.
showOrigin :: (TypeableFloat n, Renderable (Path V2 n) b, Monoid' m) => QDiagram b V2 n m -> QDiagram b V2 n m

-- | Mark the origin of a diagram, with control over colour and scale of
--   marker dot.
showOrigin' :: (TypeableFloat n, Renderable (Path V2 n) b, Monoid' m) => OriginOpts n -> QDiagram b V2 n m -> QDiagram b V2 n m
data OriginOpts n
OriginOpts :: Colour Double -> n -> n -> OriginOpts n
[_oColor] :: OriginOpts n -> Colour Double
[_oScale] :: OriginOpts n -> n
[_oMinSize] :: OriginOpts n -> n
oColor :: Lens' (OriginOpts n_a4IYd) (Colour Double)
oScale :: Lens' (OriginOpts n_a4IYd) n_a4IYd
oMinSize :: Lens' (OriginOpts n_a4IYd) n_a4IYd

-- | Mark the envelope with an approximating cubic spline using 32 points,
--   medium line width and red line color.
showEnvelope :: (Enum n, TypeableFloat n, Renderable (Path V2 n) b) => QDiagram b V2 n Any -> QDiagram b V2 n Any

-- | Mark the envelope with an approximating cubic spline with control over
--   the color, line width and number of points.
showEnvelope' :: (Enum n, TypeableFloat n, Renderable (Path V2 n) b) => EnvelopeOpts n -> QDiagram b V2 n Any -> QDiagram b V2 n Any
data EnvelopeOpts n
EnvelopeOpts :: Colour Double -> Measure n -> Int -> EnvelopeOpts n
[_eColor] :: EnvelopeOpts n -> Colour Double
[_eLineWidth] :: EnvelopeOpts n -> Measure n
[_ePoints] :: EnvelopeOpts n -> Int
eColor :: Lens' (EnvelopeOpts n_a4IYZ) (Colour Double)
eLineWidth :: Lens (EnvelopeOpts n_a4IYZ) (EnvelopeOpts n_a4J1c) (Measure n_a4IYZ) (Measure n_a4J1c)
ePoints :: Lens' (EnvelopeOpts n_a4IYZ) Int

-- | Mark the trace of a diagram by placing 64 red dots 1/100th its size
--   along the trace.
showTrace :: (Enum n, TypeableFloat n, Renderable (Path V2 n) b) => QDiagram b V2 n Any -> QDiagram b V2 n Any

-- | Mark the trace of a diagram, with control over colour and scale of
--   marker dot and the number of points on the trace.
showTrace' :: (Enum n, TypeableFloat n, Renderable (Path V2 n) b) => TraceOpts n -> QDiagram b V2 n Any -> QDiagram b V2 n Any
data TraceOpts n
TraceOpts :: Colour Double -> n -> n -> Int -> TraceOpts n
[_tColor] :: TraceOpts n -> Colour Double
[_tScale] :: TraceOpts n -> n
[_tMinSize] :: TraceOpts n -> n
[_tPoints] :: TraceOpts n -> Int
tColor :: Lens' (TraceOpts n_a4J1B) (Colour Double)
tScale :: Lens' (TraceOpts n_a4J1B) n_a4J1B
tMinSize :: Lens' (TraceOpts n_a4J1B) n_a4J1B
tPoints :: Lens' (TraceOpts n_a4J1B) Int
showLabels :: (TypeableFloat n, Renderable (Text n) b, Semigroup m) => QDiagram b V2 n m -> QDiagram b V2 n Any

-- | This module only contains exports defined in diagrams-lib or
--   diagrams-core. This module can be used if you want to avoid
--   some potential conflicts with other modules, but importing
--   Diagrams.Prelude (which includes re-exports from other
--   packages) is often more convenient.
module Diagrams

-- | A module to re-export most of the functionality of the diagrams core
--   and standard library.
module Diagrams.Prelude

-- | A functor with application, providing operations to
--   
--   
--   
- embed pure expressions (pure), and
--   
- sequence computations and combine their results
--   (<*>).
--   
--   
--   A minimal complete definition must include implementations of these
--   functions satisfying the following laws:
--   
--   
--   
- identity 
pure id <*>
--   v = v

--   
- composition 
pure (.) <*> u
--   <*> v <*> w = u <*> (v
--   <*> w)

--   
- homomorphism 
pure f <*>
--   pure x = pure (f x)

--   
- interchange 
u <*> pure y =
--   pure ($ y) <*> u

--   
--   
--   The other methods have the following default definitions, which may be
--   overridden with equivalent specialized implementations:
--   
--   
--   
- 
u *> v = pure (const id)
--   <*> u <*> v

--   
- 
u <* v = pure const <*>
--   u <*> v

--   
--   
--   As a consequence of these laws, the Functor instance for
--   f will satisfy
--   
--   
--   
- 
fmap f x = pure f <*> x

--   
--   
--   If f is also a Monad, it should satisfy
--   
--   
--   
- 
pure = return

--   
- 
(<*>) = ap

--   
--   
--   (which implies that pure and <*> satisfy the
--   applicative functor laws).
class Functor f => Applicative (f :: * -> *)

-- | Lift a value.
pure :: Applicative f => a -> f a

-- | Sequential application.
(<*>) :: Applicative f => f (a -> b) -> f a -> f b

-- | Sequence actions, discarding the value of the first argument.
(*>) :: Applicative f => f a -> f b -> f b

-- | Sequence actions, discarding the value of the second argument.
(<*) :: Applicative f => f a -> f b -> f a

-- | Sequence actions, discarding the value of the first argument.
(*>) :: Applicative f => forall a b. f a -> f b -> f b

-- | Sequence actions, discarding the value of the second argument.
(<*) :: Applicative f => forall a b. f a -> f b -> f a

-- | An infix synonym for fmap.
--   
--   
Examples
--   
--   Convert from a Maybe Int to a
--   Maybe String using show:
--   
--   
--   >>> show <$> Nothing
--   Nothing
--   
--   >>> show <$> Just 3
--   Just "3"
--   
--   
--   Convert from an Either Int Int to
--   an Either Int String using
--   show:
--   
--   
--   >>> show <$> Left 17
--   Left 17
--   
--   >>> show <$> Right 17
--   Right "17"
--   
--   
--   Double each element of a list:
--   
--   
--   >>> (*2) <$> [1,2,3]
--   [2,4,6]
--   
--   
--   Apply even to the second element of a pair:
--   
--   
--   >>> even <$> (2,2)
--   (2,True)
--   
(<$>) :: Functor f => (a -> b) -> f a -> f b

-- | Replace all locations in the input with the same value. The default
--   definition is fmap . const, but this may be
--   overridden with a more efficient version.
(<$) :: Functor f => forall a b. a -> f b -> f a

-- | Lift a function to actions. This function may be used as a value for
--   fmap in a Functor instance.
liftA :: Applicative f => (a -> b) -> f a -> f b

-- | Lift a binary function to actions.
liftA2 :: Applicative f => (a -> b -> c) -> f a -> f b -> f c

-- | Lift a ternary function to actions.
liftA3 :: Applicative f => (a -> b -> c -> d) -> f a -> f b -> f c -> f d
