-- 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 <a>Diagrams</a> module, and refer to the tutorials and
--   documentation on the diagrams website,
--   <a>http://projects.haskell.org/diagrams</a>.
@package diagrams-lib
@version 1.3.0.8


-- | Diagrams may have <i>attributes</i> 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 <i>semigroup</i> structure, that is,
--   an associative binary operation for combining two attributes into one.
--   Unless otherwise noted, all the attributes defined here use the
--   <a>Last</a> 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

-- | <tt>SurfaceColor</tt> 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))

-- | <tt>Diffuse</tt> 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
--   <tt>SurfaceColor</tt> Attribute. For physical reasonableness,
--   <tt>Diffuse</tt> should have a value between 0 and 1; this is not
--   checked.
newtype Diffuse
Diffuse :: (Last Double) -> Diffuse

-- | Isomorphism between <a>Diffuse</a> and <a>Double</a>
_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)

-- | <tt>Ambient</tt> is an ad-hoc representation of indirect lighting. The
--   product of <tt>Ambient</tt> and <tt>SurfaceColor</tt> is added to the
--   light leaving an object due to diffuse and specular terms.
--   <tt>Ambient</tt> 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 <tt>Diffuse</tt> 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
--   <a>Specular</a>, setting this will do nothing.
highlightIntensity :: Traversal' (Style v n) Double

-- | Traversal over the highlight size in a style. If the style has no
--   <a>Specular</a>, 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 <i>cubic spline</i> 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
--   <tt>splitFills</tt>.
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
--   <tt>PolygonOpts</tt> in <a>Diagrams.TwoD.Shapes</a> for an example).
--   Such record types are made instances of the <a>Default</a> class,
--   which provides a single record structure (<a>def</a>) collecting the
--   "default" arguments to the function. <tt>with</tt> is a synonym for
--   <a>def</a>, which provides nice-looking syntax for simulating
--   optional, named arguments in Haskell. For example,
--   
--   <pre>
--   polygon with {sides = 7, edgeSkip = 2}
--   
--   </pre>
--   
--   calls the <tt>polygon</tt> function with a single argument (note that
--   record update binds more tightly than function application!), namely,
--   <a>with</a> (the record of default arguments) where the <tt>sides</tt>
--   and <tt>edgeSkip</tt> fields have been updated.
with :: Default d => d

-- | <tt>applyAll</tt> 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, <tt>applyAll [f1, f2, f3] a == f1 . f2 . f3 $ a</tt>.
applyAll :: [a -> a] -> a -> a

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

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

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

-- | The circle constant, the ratio of a circle's circumference to its
--   <i>radius</i>. Note that <tt>pi = tau/2</tt>.
--   
--   For more information and a well-reasoned argument why we should all be
--   using tau instead of pi, see <i>The Tau Manifesto</i>,
--   <a>http://tauday.com/</a>.
--   
--   To hear what it sounds like (and to easily memorize the first 30
--   digits or so), try <a>http://youtu.be/3174T-3-59Q</a>.
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:
--   
--   <ul>
--   <li>Test given FilePaths if they point directly to a database or
--   contain a cabal config file (or any parent directory containing a
--   config file).</li>
--   <li>Same test for <tt>DIAGRAMS_SANDBOX</tt> environment value</li>
--   <li>Environment values of <tt>GHC_PACKAGE_PATH</tt>, <tt>HSENV</tt>
--   and <tt>PACKAGE_DB_FOR_GHC</tt> that point to a database.</li>
--   <li>Test for config file (cabal.sandbox.config) in the current
--   directory and its parents.</li>
--   </ul>
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 <i>balanced</i> fold over a list.
--   For example,
--   
--   <pre>
--   foldB (+) z [a,b,c,d,e,f] == ((a+b) + (c+d)) + (e+f)
--   
--   </pre>
foldB :: (a -> a -> a) -> a -> [a] -> a


-- | Points in space. For more tools for working with points and vectors,
--   see <a>Linear.Affine</a>.
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 <i>n</i> points is their sum divided by
--   <i>n</i>.
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

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

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

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

-- | The degree measure of an <a>Angle</a> <tt>a</tt> can be accessed as
--   <tt>a <a>^.</a> deg</tt>. A new <a>Angle</a> can be defined in degrees
--   as <tt>180 @@ deg</tt>.
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 <tt>Angle</tt>.
sinA :: Floating n => Angle n -> n

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

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

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

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

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

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

-- | Similar to <a>atan2A</a> but without the <a>RealFloat</a> 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
--   <a>_theta</a>.
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 <a>_phi</a>. <a>_phi</a> 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 <tt>Direction</tt> and a magnitude. So we
--   can think of a <tt>Direction</tt> as a vector that has forgotten its
--   magnitude. <tt>Direction</tt>s can be used with <a>fromDirection</a>
--   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)

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

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

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

-- | Synonym for <a>fromDirection</a>.
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

-- | <tt>dirBetween p q</tt> returns the directions from <tt>p</tt> to
--   <tt>q</tt>
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 <tt>Coordinates</tt> class can be
--   constructed using <a>^&amp;</a> (for example, a three-dimensional
--   vector could be constructed by <tt>1 ^&amp; 6 ^&amp; 3</tt>), and
--   deconstructed using <a>coords</a>. A common pattern is to use
--   <a>coords</a> in conjunction with the <tt>ViewPatterns</tt> extension,
--   like so:
--   
--   <pre>
--   foo :: Vector3 -&gt; ...
--   foo (coords -&gt; x :&amp; y :&amp; z) = ...
--   </pre>
class Coordinates c where type family FinalCoord c :: * type family PrevDim c :: * type family Decomposition c :: * pr = (^&)

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

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

-- | Decompose a value of type <tt>c</tt> into its constituent coordinates,
--   stored in a nested <tt>(:&amp;)</tt> 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
--   
--   <pre>
--   &gt;&gt;&gt; pure 1 :: V2 Int
--   V2 1 1
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; V2 1 2 + V2 3 4
--   V2 4 6
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; V2 1 2 * V2 3 4
--   V2 3 8
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; sum (V2 1 2)
--   3
--   </pre>
data V2 a :: * -> *
V2 :: SrictNotUnpackeda -> SrictNotUnpackeda -> V2 a

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

-- | <pre>
--   &gt;&gt;&gt; V1 2 ^._x
--   2
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; V1 2 &amp; _x .~ 3
--   V1 3
--   </pre>
_x :: (R1 t, Functor f) => (a -> f a) -> t a -> f (t a)

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

-- | <pre>
--   &gt;&gt;&gt; V2 1 2 ^._y
--   2
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; V2 1 2 &amp; _y .~ 3
--   V2 1 3
--   </pre>
_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
--   <tt>&amp;</tt>.
r2 :: (n, n) -> V2 n

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

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

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

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

-- | Convert a 2D point back into a pair of coordinates. See also
--   <tt>coords</tt>.
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 <a>_r</a> 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 <a>Direction</a> pointing in the X direction.
xDir :: (R1 v, Additive v, Num n) => Direction v n

-- | A <a>Direction</a> 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
--   <a>xDir</a>.
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
--   
--   <pre>
--   &gt;&gt;&gt; perp $ V2 10 20
--   V2 (-20) 10
--   </pre>
perp :: Num a => V2 a -> V2 a

-- | <tt>leftTurn v1 v2</tt> tests whether the direction of <tt>v2</tt> is
--   a left turn from <tt>v1</tt> (that is, if the direction of <tt>v2</tt>
--   can be obtained from that of <tt>v1</tt> by adding an angle 0 &lt;=
--   theta &lt;= 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 <a>r3</a>.
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 <a>r3</a>.
mkP3 :: n -> n -> n -> P3 n
r3Iso :: Iso' (V3 n) (n, n, n)
p3Iso :: Iso' (P3 n) (n, n, n)

-- | <tt>project u v</tt> computes the projection of <tt>v</tt> onto
--   <tt>u</tt>.
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 <a>_x</a>.
class R1 (t :: * -> *)

-- | <pre>
--   &gt;&gt;&gt; V1 2 ^._x
--   2
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; V1 2 &amp; _x .~ 3
--   V1 3
--   </pre>
_x :: (R1 t, Functor f) => (a -> f a) -> t a -> f (t a)

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

-- | <pre>
--   &gt;&gt;&gt; V2 1 2 ^._y
--   2
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; V2 1 2 &amp; _y .~ 3
--   V2 1 3
--   </pre>
_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: <a>_x</a>,
--   <a>_y</a>, and <a>_z</a>. (It may have more)
class R2 t => R3 (t :: * -> *)

-- | <pre>
--   &gt;&gt;&gt; V3 1 2 3 ^. _z
--   3
--   </pre>
_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 <tt>PointLight</tt> radiates uniformly in all directions from a
--   given point.
data PointLight n
PointLight :: (Point V3 n) -> (Colour Double) -> PointLight n

-- | A <tt>ParallelLight</tt> 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 <a>Direction</a> pointing in the X direction.
xDir :: (R1 v, Additive v, Num n) => Direction v n

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

-- | A <a>Direction</a> 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. <a>cone</a> and
--   <a>cylinder</a> 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 <a>Transformation</a>s and matricies.
module Diagrams.Transform.Matrix

-- | Build a matrix from a <a>Transformation</a>, 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 <a>T2</a> 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 <a>T3</a> 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 <a>T2</a> 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 <a>T3</a> 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,
--   <a>http://hackage.haskell.org/package/graphics-drawingcombinators</a>.
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 <a>True</a> points in a diagram (<i>i.e.</i>
--   points "inside" the diagram); <a>False</a> points will be set to
--   <a>mempty</a>.
value :: Monoid m => m -> QDiagram b v n Any -> QDiagram b v n m

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

-- | Set all the query values of a diagram to <a>False</a>.
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. <tt>AName</tt> is just an existential wrapper around
--   things which are <a>Typeable</a>, <a>Ord</a> and <a>Show</a>.
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
--   <a>Typeable</a> (to facilitate extracting them from existential
--   wrappers), <a>Ord</a> (for comparison and efficient storage) and
--   <a>Show</a>.
--   
--   To make an instance of <a>IsName</a>, you need not define any methods,
--   just declare it.
--   
--   WARNING: it is not recommended to use
--   <tt>GeneralizedNewtypeDeriving</tt> in conjunction with
--   <tt>IsName</tt>, since in that case the underlying type and the
--   <tt>newtype</tt> will be considered equivalent when comparing names.
--   For example:
--   
--   <pre>
--   newtype WordN = WordN Int deriving (Show, Ord, Eq, Typeable, IsName)
--   
--   </pre>
--   
--   is unlikely to work as intended, since <tt>(1 :: Int)</tt> and
--   <tt>(WordN 1)</tt> will be considered equal as names. Instead, use
--   
--   <pre>
--   newtype WordN = WordN Int deriving (Show, Ord, Eq, Typeable, IsName)
--   instance IsName WordN
--   
--   </pre>
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 <tt>toName a1 &lt;&gt; toName
--   a2 &lt;&gt; toName a3</tt> you can just write <tt>a1 .&gt; a2 .&gt;
--   a3</tt>.
(.>) :: (IsName a1, IsName a2) => a1 -> a2 -> Name

-- | Instances of <a>Qualifiable</a> 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 <tt>Subdiagram</tt> 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 <a>pointDiagram</a> (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
--   <tt>mkSubdiagram . pointDiagram</tt>, 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.
--   <tt>getSub</tt> 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 <i>with respect to</i> 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 <a>SubMap</a> is a map associating names to subdiagrams. There can
--   be multiple associations for any given name.
data SubMap b (v :: * -> *) n m :: * -> (* -> *) -> * -> * -> *

-- | Construct a <a>SubMap</a> 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 <tt>d' = d # named x</tt>, then
--   <tt>lookupName x d' == Just d'</tt> (instead of <tt>Just d</tt>).
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 <i>e.g.</i>
--   <a>Diagrams.TwoD.Transform</a>.
module Diagrams.Transform

-- | General (affine) transformations, represented by an invertible linear
--   map, its <i>transpose</i>, and a vector representing a translation
--   component.
--   
--   By the <i>transpose</i> 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 <i>normal vectors</i> transform according to L's inverse
--   transpose. (For a more detailed explanation and proof, see
--   <a>https://wiki.haskell.org/Diagrams/Dev/Transformations</a>.) This is
--   exactly what we need when transforming bounding functions, which are
--   defined in terms of <i>perpendicular</i> (i.e. normal) hyperplanes.
--   
--   For more general, non-invertible transformations, see
--   <tt>Diagrams.Deform</tt> (in <tt>diagrams-lib</tt>).
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 <tt>t</tt> 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 <a>moveOriginTo</a>, i.e. we
--   should have
--   
--   <pre>
--   moveTo (origin .^+ v) === moveOriginTo (origin .^- v)
--   
--   </pre>
--   
--   For types which are also <tt>Transformable</tt>, this is essentially
--   the same as <tt>translate</tt>, i.e.
--   
--   <pre>
--   moveTo (origin .^+ v) === translate v
--   
--   </pre>
moveTo :: (InSpace v n t, HasOrigin t) => Point v n -> t -> t

-- | A flipped variant of <a>moveTo</a>, provided for convenience. Useful
--   when writing a function which takes a point as an argument, such as
--   when using <tt>withName</tt> 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. <tt>conjugate t1 t2</tt> is
--   the transformation which performs first <tt>t1</tt>, then <tt>t2</tt>,
--   then the inverse of <tt>t1</tt>.
conjugate :: (Additive v, Num n, Functor v) => Transformation v n -> Transformation v n -> Transformation v n

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

-- | Use a <a>Transformation</a> to make an <a>Iso</a> between an object
--   transformed and untransformed. This is useful for carrying out
--   functions <a>under</a> another transform:
--   
--   <pre>
--   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
--   </pre>
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 <a>Iso</a> between an object translated and
--   untranslated.
--   
--   <pre>
--   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)
--   </pre>
translated :: (InSpace v n a, SameSpace a b, Transformable a, Transformable b) => v n -> Iso a b a b

-- | Use a <a>Point</a> to make an <a>Iso</a> between an object moved to
--   and from that point:
--   
--   <pre>
--   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
--   </pre>
movedTo :: (InSpace v n a, SameSpace a b, HasOrigin a, HasOrigin b) => Point v n -> Iso a b a b

-- | Use a <a>Transformation</a> to make an <a>Iso</a> between an object
--   transformed and untransformed. We have
--   
--   <pre>
--   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
--   </pre>
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 <tt>Transformable</tt> instead of
--   having a separate class for <a>HasOrigin</a>; indeed, for types which
--   are instances of both we should have the identity
--   
--   <pre>
--   moveOriginTo (origin .^+ v) === translate (negated v)
--   
--   </pre>
--   
--   The reason is that some things (e.g. vectors, <tt>Trail</tt>s) 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 <tt>translate</tt>
--   (for types which are also <tt>Transformable</tt>); 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 <a>rotate</a>.
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 <a>Iso</a>s on <a>Angle</a>.
--   For example, <tt>rotate (1/4 @@ <a>turn</a>)</tt>, <tt>rotate (tau/4
--   @@ rad)</tt>, and <tt>rotate (90 @@ deg)</tt> all represent the same
--   transformation, namely, a counterclockwise rotation by a right angle.
--   To rotate about some point other than the local origin, see
--   <tt>rotateAbout</tt>.
--   
--   Note that writing <tt>rotate (1/4)</tt>, with no <a>Angle</a>
--   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
--   <a>rotateBy</a>, 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 <a>rotate</a>, interpreting its argument in units of
--   turns; it can be more convenient to write <tt>rotateBy (1/4)</tt> than
--   <tt><a>rotate</a> (1/4 @@ <a>turn</a>)</tt>.
rotateBy :: (InSpace V2 n t, Transformable t, Floating n) => n -> t -> t

-- | Use an <a>Angle</a> to make an <a>Iso</a> between an object rotated
--   and unrotated. This us useful for performing actions <a>under</a> a
--   rotation:
--   
--   <pre>
--   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)
--   </pre>
rotated :: (InSpace V2 n a, Floating n, SameSpace a b, Transformable a, Transformable b) => Angle n -> Iso a b a b

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

-- | <tt>rotateAbout p</tt> is like <a>rotate</a>, except it rotates around
--   the point <tt>p</tt> 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 <a>scale</a>.
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 <a>scale</a>.
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

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

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

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

-- | <tt>scaleUToY h</tt> scales a diagram <i>uniformly</i> by whatever
--   factor required to make its height <tt>h</tt>. <tt>scaleUToY</tt>
--   should not be applied to diagrams with a height of 0, such as
--   <tt>hrule</tt>.
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

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

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

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

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

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

-- | <tt>shearY d</tt> performs a shear in the y-direction which sends
--   <tt>(1,0)</tt> to <tt>(1,d)</tt>.
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 <a>aboutZ</a>, but rotates about the X axis, bringing positive
--   y-values towards the positive z-axis.
aboutX :: Floating n => Angle n -> Transformation V3 n

-- | Like <a>aboutZ</a>, 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
--   <a>Angle</a>. For example, <tt>aboutZ (1/4 @@ <a>turn</a>)</tt>,
--   <tt>aboutZ (tau/4 @@ <a>rad</a>)</tt>, and <tt>aboutZ (90 @@
--   <a>deg</a>)</tt> all represent the same transformation, namely, a
--   counterclockwise rotation by a right angle. For more general
--   rotations, see <a>rotationAbout</a>.
--   
--   Note that writing <tt>aboutZ (1/4)</tt>, 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

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

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

-- | <tt>pointAt about initial final</tt> produces a rotation which brings
--   the direction <tt>initial</tt> to point in the direction
--   <tt>final</tt> by first panning around <tt>about</tt>, then tilting
--   about the axis perpendicular to <tt>about</tt> and <tt>final</tt>. 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 <a>pointAt</a>, 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 <a>scale</a>.
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 <a>scale</a>.
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 <a>scale</a>.
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

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

-- | <tt>reflectAcross p v</tt> reflects a diagram across the plane though
--   the point <tt>p</tt> and the vector <tt>v</tt>. This also works as a
--   2D transform where <tt>v</tt> is the normal to the line passing
--   through point <tt>p</tt>.
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 <tt>ScaleInv</tt> wrapper creates two-dimensional
--   <i>scale-invariant</i> 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 <i>non-uniform</i>
--   scales (<i>e.g.</i> <tt>scaleX 2 . scaleY 3</tt>) 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>i.e.</i> the local origin) and a unit vector (indicating the
--   <i>direction</i>) along with a scale-invariant object. A
--   transformation to be applied is decomposed into rotational and
--   translational components as follows:
--   
--   <ul>
--   <li>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.</li>
--   <li>The vector from the location to the image of the location under
--   the transformation determines the translational component.</li>
--   </ul>
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 <i>empty</i> 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" (<i>e.g.</i> 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,
--   <i>e.g.</i> segments and trails.
module Diagrams.Parametric

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

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

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

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

-- | Type class for parametric functions with a bounded domain. The default
--   bounds are <tt>[0,1]</tt>.
--   
--   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

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

-- | <a>domainUpper</a> 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

-- | <a>atStart</a> is the value at the start of the domain. That is,
--   
--   <pre>
--   atStart x = x `atParam` domainLower x
--   </pre>
--   
--   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)

-- | <a>atEnd</a> is the value at the end of the domain. That is,
--   
--   <pre>
--   atEnd x = x `atParam` domainUpper x
--   </pre>
--   
--   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 <a>splitAtParam</a> or <a>section</a>, plus
--   <a>reverseDomain</a>.
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))

-- | <a>splitAtParam</a> splits an object <tt>p</tt> into two new objects
--   <tt>(l,r)</tt> at the parameter <tt>t</tt>, where <tt>l</tt>
--   corresponds to the portion of <tt>p</tt> for parameter values from
--   <tt>0</tt> to <tt>t</tt> and <tt>r</tt> for to that from <tt>t</tt> to
--   <tt>1</tt>. The following property should hold:
--   
--   <pre>
--   prop_splitAtParam f t u =
--     | u &lt; 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
--   </pre>
--   
--   where <tt>(???) = (^+^)</tt> if the codomain is a vector type, or
--   <tt>const flip</tt> if the codomain is a point type. Stated more
--   intuitively, all this is to say that the parameterization scales
--   linearly with splitting.
--   
--   <a>splitAtParam</a> can also be used with parameters outside the range
--   of the domain. For example, using the parameter <tt>2</tt> with a path
--   (where the domain is the default <tt>[0,1]</tt>) gives two result
--   paths where the first is the original path extended to the parameter
--   2, and the second result path travels <i>backwards</i> 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:
--   
--   <pre>
--   prop_section x l u t =
--     let s = section x l u
--     in     domainBounds x == domainBounds x
--         &amp;&amp; (x `atParam` lerp l u t) == (s `atParam` t)
--   </pre>
--   
--   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

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

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

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

-- | <tt><a>arcLengthToParam</a> eps s l</tt> converts the absolute arc
--   length <tt>l</tt>, measured from the start of the domain, to a
--   parameter on the object <tt>s</tt>. The true arc length at the
--   parameter returned is guaranteed to be within <tt>eps</tt> of the
--   requested arc length.
--   
--   This should work for <i>any</i> 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 <a>stdTolerance</a>, or <tt>1e-6</tt>.
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 <a>AdjustOpts</a>.
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>i.e.</i> things with a concrete location:
--   intuitively, <tt>Located a ~ (a, Point)</tt>. Wrapping a
--   translationally invariant thing (<i>e.g.</i> a <tt>Segment</tt> or
--   <tt>Trail</tt>) in <tt>Located</tt> pins it down to a particular
--   location and makes it no longer translationally invariant.
module Diagrams.Located

-- | "Located" things, <i>i.e.</i> things with a concrete location:
--   intuitively, <tt>Located a ~ (Point, a)</tt>. Wrapping a
--   translationally invariant thing (<i>e.g.</i> a <tt>Segment</tt> or
--   <tt>Trail</tt>) in <a>Located</a> pins it down to a particular
--   location and makes it no longer translationally invariant.
--   
--   <tt>Located</tt> is intentionally abstract. To construct
--   <tt>Located</tt> values, use <a>at</a>. To destruct, use
--   <a>viewLoc</a>, <a>unLoc</a>, or <a>loc</a>. To map, use
--   <a>mapLoc</a>.
--   
--   Much of the utility of having a concrete type for the <tt>Located</tt>
--   concept lies in the type class instances we can give it. The
--   <a>HasOrigin</a>, <a>Transformable</a>, <a>Enveloped</a>,
--   <a>Traced</a>, and <tt>TrailLike</tt> 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 <tt>Located</tt> value.
[loc] :: Located a -> Point (V a) (N a)

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

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

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

-- | <a>Located</a> is not a <tt>Functor</tt>, 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.
--   <a>mapLoc</a> has an extra constraint specifying that the vector space
--   must stay the same.
--   
--   (Technically, one can say that for every vector space <tt>v</tt>,
--   <tt>Located</tt> is a little-f (endo)functor on the category of types
--   with associated vector space <tt>v</tt>; but that is not covered by
--   the standard <tt>Functor</tt> class.)
mapLoc :: SameSpace a b => (a -> b) -> Located a -> Located b

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

-- | Lens onto the location of something <a>Located</a>.
_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 <i>segment</i> is a translation-invariant, atomic path. Currently,
--   there are two types: linear (<i>i.e.</i> just a straight line to the
--   endpoint) and cubic Bézier curves (<i>i.e.</i> 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
--   <a>Diagrams.Trail</a>, <a>Diagrams.TrailLike</a>, and
--   <a>Diagrams.Path</a> 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 <i>offset</i> of a segment is the vector from its starting point
--   to its end. The offset for an <i>open</i> segment is determined by the
--   context, <i>i.e.</i> its endpoint is not fixed. The offset for a
--   <i>closed</i> segment is stored explicitly, <i>i.e.</i> 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 <i>not</i> the same as the
--   length of the curve itself; for that, see <a>arcLength</a>.
segOffset :: Segment Closed v n -> v n

-- | The atomic constituents of the concrete representation currently used
--   for trails are <i>segments</i>, currently limited to single straight
--   lines or cubic Bézier curves. Segments are <i>translationally
--   invariant</i>, 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

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

-- | <tt>bezier3 c1 c2 x</tt> 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
--   <tt>c1</tt>, <tt>c2</tt>, and <tt>x</tt>.
bezier3 :: v n -> v n -> v n -> Segment Closed v n

-- | <tt>bézier3</tt> is the same as <tt>bezier3</tt>, 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 <tt>v1</tt> and <tt>v2</tt> to form a loop.
openCubic :: v n -> v n -> Segment Open v n

-- | <tt>FixedSegment</tt>s are like <a>Segment</a>s except that they have
--   absolute locations. <tt>FixedSegment v</tt> is isomorphic to
--   <tt>Located (Segment Closed v)</tt>, as witnessed by <a>mkFixedSeg</a>
--   and <a>fromFixedSeg</a>, but <tt>FixedSegment</tt> 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 <a>FixedSegment</a> from a located <a>Segment</a>.
mkFixedSeg :: (Num n, Additive v) => Located (Segment Closed v n) -> FixedSegment v n

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

-- | Use a <a>FixedSegment</a> to make an <a>Iso</a> 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 <tt>Trail</tt>.
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 <tt>10e-6</tt>. 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)

-- | <tt>SegMeasure</tt> 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
--   
--   <ul>
--   <li><pre>Segment Closed V2 -&gt; Double -&gt; V2 Double</pre></li>
--   <li><pre>Trail' Line V2 -&gt; Double -&gt; V2 Double</pre></li>
--   <li><pre>Located (Trail V2) -&gt; Double -&gt; V2 Double</pre></li>
--   </ul>
--   
--   See the instances listed for the <a>Tangent</a> 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
--   
--   <ul>
--   <li><pre>Segment Closed V2 Double -&gt; Double -&gt; V2
--   Double</pre></li>
--   <li><pre>Trail' Line V2 Double -&gt; Double -&gt; V2 Double</pre></li>
--   <li><pre>Located (Trail V2 Double) -&gt; Double -&gt; V2
--   Double</pre></li>
--   </ul>
--   
--   See the instances listed for the <a>Tangent</a> 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
--   <a>Parametric</a> and <a>EndValues</a> 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 <i>trails</i>, 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:
--   
--   <ul>
--   <li>The <tt>TrailLike</tt> class (<a>Diagrams.TrailLike</a>) exposes a
--   generic API for building a wide range of things out of trails.</li>
--   <li><tt>Path</tt>s (<a>Diagrams.Path</a>) are collections of
--   <a>Located</a> (<a>Diagrams.Located</a>) trails.</li>
--   <li>Trails are composed of <a>Segment</a>s (see
--   <a>Diagrams.Segment</a>), though most users should not need to work
--   with segments directly.</li>
--   </ul>
module Diagrams.Trail

-- | Intuitively, a trail is a single, continuous path through space.
--   However, a trail has no fixed starting point; it merely specifies
--   <i>how</i> to move through space, not <i>where</i>. 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 <i>translation-invariant</i>; applying a translation to a
--   trail has no effect.
--   
--   A <tt><a>Located</a> Trail</tt>, 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
--   <a>Diagrams.Located</a> module for help working with <a>Located</a>
--   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 <a>Located</a> trail is
--   a continuous function from [0,1] to <i>points</i> in some
--   <i>affine</i> space.)
--   
--   There are two types of trails:
--   
--   <ul>
--   <li>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 <i>drawn</i> 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 <tt>Monoid</tt> instance where
--   <tt>mappend</tt> corresponds to concatenation, <i>i.e.</i> chaining
--   one line after the other.</li>
--   <li>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 <tt>Monoid</tt> instance.</li>
--   </ul>
--   
--   To convert between lines and loops, see <a>glueLine</a>,
--   <a>closeLine</a>, and <a>cutLoop</a>.
--   
--   To construct trails, see <a>emptyTrail</a>, <a>trailFromSegments</a>,
--   <a>trailFromVertices</a>, <a>trailFromOffsets</a>, and friends. You
--   can also get any type of trail from any function which returns a
--   <tt>TrailLike</tt> (<i>e.g.</i> functions in
--   <a>Diagrams.TwoD.Shapes</a>, and many others; see
--   <a>Diagrams.TrailLike</a>).
--   
--   To extract information from trails, see <a>withLine</a>,
--   <a>isLoop</a>, <a>trailSegments</a>, <a>trailOffsets</a>,
--   <a>trailVertices</a>, 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 <a>glueLine</a> to turn it into a loop.
--   
--   
--   <pre>
--   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)]
--   </pre>
--   
--   <tt>glueLine</tt> is left inverse to <a>cutLoop</a>, that is,
--   
--   <pre>
--   glueLine . cutLoop === id
--   
--   </pre>
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.
--   
--   <tt>closeLine</tt> does not have any particularly nice theoretical
--   properties, but can be useful <i>e.g.</i> 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 <a>glueLine</a>, one would first have to
--   duplicate the initial vertex, like
--   
--   <pre>
--   <a>glueLine</a> . <a>lineFromVertices</a> $ ps ++ [head ps]
--   </pre>
--   
--   Using <tt>closeLine</tt>, however, one can simply
--   
--   <pre>
--   closeLine . lineFromVertices $ ps
--   </pre>
--   
--   
--   <pre>
--   closeLineEx = pad 1.1 . centerXY . hcat' (with &amp; sep .~ 1)
--     $ [almostClosed # strokeLine, almostClosed # closeLine # strokeLoop]
--   </pre>
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.
--   
--   <tt>cutLoop</tt> is right inverse to <a>glueLine</a>, that is,
--   
--   <pre>
--   glueLine . cutLoop === id
--   
--   </pre>
cutLoop :: (Metric v, OrderedField n) => Trail' Loop v n -> Trail' Line v n

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

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

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

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

-- | Convert a line into a <a>Trail</a>. This is the same as
--   <a>wrapTrail</a>, 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 <a>Trail</a>. This is the same as
--   <a>wrapTrail</a>, 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 <tt>Trail</tt>, 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 <tt>Trail</tt> 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 <a>cutLoop</a>, the
--   transformation applied, and then glued back into a loop with
--   <a>glueLine</a>. That is,
--   
--   <pre>
--   onLine f === onTrail f (glueLine . f . cutLoop)
--   
--   </pre>
--   
--   Note that there is no corresponding <tt>onLoop</tt> 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

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

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

-- | <tt>cutTrail</tt> is a variant of <a>cutLoop</a> for <a>Trail</a>; it
--   is the is the identity on lines and performs <a>cutLoop</a> 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 <a>emptyLine</a>.
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 <tt>v</tt>,
--   
--   <pre>
--   lineFromVertices === lineFromVertices . <a>translate</a> v
--   </pre>
--   
--   If you want to retain the position information, you should instead use
--   the more general <tt>fromVertices</tt> function to construct, say, a
--   <tt><a>Located</a> (<a>Trail'</a> <a>Line</a> v)</tt> or a
--   <tt><a>Located</a> (<a>Trail</a> v)</tt>.
--   
--   
--   <pre>
--   import Diagrams.Coordinates
--   lineFromVerticesEx = pad 1.1 . centerXY . strokeLine
--     $ lineFromVertices [origin, 0 ^&amp; 1, 1 ^&amp; 2, 5 ^&amp; 1]
--   </pre>
lineFromVertices :: (Metric v, OrderedField n) => [Point v n] -> Trail' Line v n

-- | <tt>trailFromVertices === <a>wrapTrail</a> .
--   <a>lineFromVertices</a></tt>, for conveniently constructing a
--   <tt>Trail</tt> instead of a <tt>Trail' Line</tt>.
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 <tt>fromOffsets</tt>.
--   
--   
--   <pre>
--   import Diagrams.Coordinates
--   lineFromOffsetsEx = strokeLine $ lineFromOffsets [ 2 ^&amp; 1, 2 ^&amp; (-1), 2 ^&amp; 0.5 ]
--   </pre>
lineFromOffsets :: (Metric v, OrderedField n) => [v n] -> Trail' Line v n

-- | <tt>trailFromOffsets === <a>wrapTrail</a> .
--   <a>lineFromOffsets</a></tt>, for conveniently constructing a
--   <tt>Trail</tt> instead of a <tt>Trail' Line</tt>.
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

-- | <tt>trailFromSegments === <a>wrapTrail</a> .
--   <a>lineFromSegments</a></tt>, for conveniently constructing a
--   <tt>Trail</tt> instead of a <tt>Trail'</tt>.
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 <a>Trail'</a>, 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 <a>Trail</a>, 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 <tt>Trail</tt> 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 <a>cutLoop</a>. That is,
--   
--   <pre>
--   withLine f === <a>withTrail</a> f (f . <a>cutLoop</a>)
--   </pre>
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 <a>cutLoop</a> 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
--   
--   <pre>
--   trailOffset === sumV . trailOffsets
--   
--   </pre>
--   
--   but is more efficient.
--   
--   
--   <pre>
--   trailOffsetEx = (strokeLine almostClosed &lt;&gt; showOffset) # centerXY # pad 1.1
--     where showOffset = fromOffsets [trailOffset (wrapLine almostClosed)]
--                      # strokeP # lc red
--   </pre>
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 <tt>loopOffset</tt> 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>i.e.</i> the
--   points where one segment ends and the next begins. Note that for
--   loops, the starting point will <i>not</i> be repeated at the end. If
--   you want this behavior, you can use <a>cutTrail</a> to make the loop
--   into a line first, which happens to repeat the same point at the start
--   and end, <i>e.g.</i> with <tt>trailPoints . mapLoc cutTrail</tt>.
--   
--   Note that it does not make sense to ask for the points of a
--   <a>Trail</a> by itself; if you want the points of a trail with the
--   first point at, say, the origin, you can use <tt>trailPoints . (`at`
--   origin)</tt>.
--   
--   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 <a>trailVertices</a>.
--   
--   This function is not re-exported from <a>Diagrams.Prelude</a>; to use
--   it, import <a>Diagrams.Trail</a>.
trailPoints :: (Metric v, OrderedField n) => Located (Trail v n) -> [Point v n]

-- | Extract the segment join points of a concretely located line. See
--   <a>trailPoints</a> 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 <a>lineVertices</a>.
--   
--   This function is not re-exported from <a>Diagrams.Prelude</a>; to use
--   it, import <a>Diagrams.Trail</a>.
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
--   <a>trailPoints</a> 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 <a>lineVertices</a>.
--   
--   This function is not re-exported from <a>Diagrams.Prelude</a>; to use
--   it, import <a>Diagrams.Trail</a>.
loopPoints :: (Metric v, OrderedField n) => Located (Trail' Loop v n) -> [Point v n]

-- | Extract the vertices of a concretely located trail. Here a
--   <i>vertex</i> is defined as a non-differentiable point on the trail,
--   <i>i.e.</i> a sharp corner. (Vertices are thus a subset of the places
--   where segments join; if you want all joins between segments, see
--   <a>trailPoints</a>.) 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 <i>not</i> be repeated
--   at the end. If you want this behavior, you can use <a>cutTrail</a> to
--   make the loop into a line first, which happens to repeat the same
--   vertex at the start and end, <i>e.g.</i> with <tt>trailVertices .
--   mapLoc cutTrail</tt>.
--   
--   It does not make sense to ask for the vertices of a <a>Trail</a> by
--   itself; if you want the vertices of a trail with the first vertex at,
--   say, the origin, you can use <tt>trailVertices . (`at` origin)</tt>.
trailVertices' :: (Metric v, OrderedField n) => n -> Located (Trail v n) -> [Point v n]

-- | Extract the vertices of a concretely located line. See
--   <a>trailVertices</a> 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 <a>trailVertices</a>
--   for more information.
loopVertices' :: (Metric v, OrderedField n) => n -> Located (Trail' Loop v n) -> [Point v n]

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

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

-- | Same as <a>loopVertices'</a>, 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).
--   <tt>reverseTrail</tt> is an involution, that is,
--   
--   <pre>
--   reverseTrail . reverseTrail === id
--   
--   </pre>
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.
--   <tt>reverseLocTrail</tt> is an involution, <i>i.e.</i>
--   
--   <pre>
--   reverseLocTrail . reverseLocTrail === id
--   
--   </pre>
reverseLocTrail :: (Metric v, OrderedField n) => Located (Trail v n) -> Located (Trail v n)

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

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

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

-- | Reverse a concretely located loop. See <a>reverseLocTrail</a>. 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 <tt>SegTree</tt> 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 (<i>e.g.</i>, 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
--   <a>SegMeasure</a> (<i>e.g.</i> <tt>SegMeasure</tt> itself,
--   <tt>Segment</tt>, <tt>SegTree</tt>, <tt>Trail</tt>s...)
numSegs :: (OrderedField n, Num c, Metric v, Measured (SegMeasure v n) a) => a -> c

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

-- | A newtype wrapper around trails which exists solely for its
--   <a>Parametric</a>, <a>DomainBounds</a> and <a>EndValues</a> instances.
--   The idea is that if <tt>tr</tt> is a trail, you can write, <i>e.g.</i>
--   
--   <pre>
--   getSegment tr <a>atParam</a> 0.6
--   
--   </pre>
--   
--   or
--   
--   <pre>
--   atStart (getSegment tr)
--   
--   </pre>
--   
--   to get the segment at parameter 0.6 or the first segment in the trail,
--   respectively.
--   
--   The codomain for <a>GetSegment</a>, <i>i.e.</i> the result you get
--   from calling <a>atParam</a>, <a>atStart</a>, or <a>atEnd</a>, is
--   <tt>Maybe (v, Segment Closed v, AnIso' n n)</tt>. <tt>Nothing</tt>
--   results if the trail is empty; otherwise, you get:
--   
--   <ul>
--   <li>the offset from the start of the trail to the beginning of the
--   segment,</li>
--   <li>the segment itself, and</li>
--   <li>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
--   <a>cloneIso</a> on the <tt>AnIso'</tt> value to get a real isomorphism
--   you can use.</li>
--   </ul>
newtype GetSegment t
GetSegment :: t -> GetSegment t

-- | Create a <a>GetSegment</a> wrapper around a trail, after which you can
--   call <a>atParam</a>, <a>atStart</a>, or <a>atEnd</a> 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
--   
--   
--   <pre>
--   {-# LANGUAGE GADTs #-}
--   
--   import Diagrams.TwoD.Curvature
--   import Data.Monoid.Inf
--   import Diagrams.Coordinates
--   
--   segmentA :: Segment Closed V2 Double
--   segmentA = Cubic (12 ^&amp; 0) (8 ^&amp; 10) (OffsetClosed (20 ^&amp; 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
--           &lt;&gt; showCurvature segmentA t
--            # withEnvelope (curveA :: D V2 Double)
--            # lc red
--   
--   showCurvature :: Segment Closed V2 Double -&gt; Double -&gt; 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) ^&amp; 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
--                    &lt;&gt; strokeP (origin ~~ (origin .+^ vpr)))
--                     # moveTo (origin .+^ atParam bez t)
--         where
--           vpr = signorm vp ^* r
--   </pre>
curvature :: RealFloat n => Segment Closed V2 n -> n -> PosInf n

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

-- | With <tt>squaredCurvature</tt> we can compute values in spaces that do
--   not support <a>sqrt</a> 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 <tt>squaredCurvature</tt>
squaredRadiusOfCurvature :: RealFloat n => Segment Closed V2 n -> n -> PosInf n


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

-- | A type class for trail-like things, <i>i.e.</i> things which can be
--   constructed from a concretely located <a>Trail</a>. Instances include
--   lines, loops, trails, paths, lists of vertices, two-dimensional
--   <a>Diagram</a>s, and <a>Located</a> variants of all the above.
--   
--   Usually, type variables with <a>TrailLike</a> constraints are used as
--   the <i>output</i> types of functions, like
--   
--   <pre>
--   foo :: (TrailLike t) =&gt; ... -&gt; t
--   
--   </pre>
--   
--   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 <a>trailLike</a> directly; more typically, one would use one of
--   the provided functions like <a>fromOffsets</a>, <a>fromVertices</a>,
--   <a>fromSegments</a>, or <a>~~</a>.
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.
--   
--   
--   <pre>
--   fromSegmentsEx = fromSegments
--     [ straight (r2 (1,1))
--     , bézier3  (r2 (1,1)) unitX unit_Y
--     , straight unit_X
--     ]
--     # centerXY # pad 1.1
--   </pre>
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.
--   
--   
--   <pre>
--   fromOffsetsEx = fromOffsets
--     [ unitX
--     , unitX # rotateBy (1/6)
--     , unitX # rotateBy (-1/6)
--     , unitX
--     ]
--     # centerXY # pad 1.1
--   </pre>
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.
--   
--   
--   <pre>
--   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
--   </pre>
fromVertices :: TrailLike t => [Point (V t) (N t)] -> t

-- | Create a linear trail between two given points.
--   
--   
--   <pre>
--   twiddleEx
--     = mconcat ((~~) &lt;$&gt; hexagon 1 &lt;*&gt; hexagon 1)
--     # centerXY # pad 1.1
--   </pre>
(~~) :: (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.
--   
--   
--   <pre>
--   explodeTrailEx
--     = pentagon 1
--     # explodeTrail  -- generate a list of diagrams
--     # zipWith lc [orange, green, yellow, red, blue]
--     # mconcat # centerXY # pad 1.1
--   </pre>
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 <a>Active</a> (from the
--   <tt>active</tt> package). In particular, this module defines
--   
--   <ul>
--   <li>An instance of <a>V</a> for <a>Active</a>: <tt><a>V</a>
--   (<a>Active</a> a) = <a>V</a> a</tt></li>
--   <li><a>HasOrigin</a>, <a>Transformable</a>, and <a>HasStyle</a>
--   instances for <a>Active</a> which all work pointwise.</li>
--   <li>A <a>TrailLike</a> instance for <tt><a>Active</a> p</tt> where
--   <tt>p</tt> is also <a>TrailLike</a>, which simply lifts a pathlike
--   thing to a constant active value.</li>
--   <li>A <a>Juxtaposable</a> instance for <tt><a>Active</a> a</tt> where
--   <tt>a</tt> is also <a>Juxtaposable</a>. An active value can be
--   juxtaposed against another by doing the juxtaposition pointwise over
--   time. The era of <tt>juxtapose v a1 a2</tt> will be the same as the
--   era of <tt>a2</tt>, unless <tt>a2</tt> is constant, in which case it
--   will be the era of <tt>a1</tt>. (Note that <tt>juxtapose v a1 a2</tt>
--   and <tt>liftA2 (juxtapose v) a1 a2</tt> therefore have different
--   semantics: the second is an active value whose era is the
--   <i>combination</i> of the eras of <tt>a1</tt> and <tt>a2</tt>).</li>
--   <li>An <tt>Alignable</tt> instance for <tt><a>Active</a> a</tt> where
--   <tt>a</tt> is also <tt>Alignable</tt>; the active value is aligned
--   pointwise over time.</li>
--   </ul>
module Diagrams.Animation.Active

-- | An active value can be juxtaposed against another by doing the
--   juxtaposition pointwise over time. The era of <tt>juxtapose v a1
--   a2</tt> will be the same as the era of <tt>a2</tt>, unless <tt>a2</tt>
--   is constant, in which case it will be the era of <tt>a1</tt>. (Note
--   that <tt>juxtapose v a1 a2</tt> and <tt>liftA2 (juxtapose v) a1
--   a2</tt> therefore have different semantics: the second is an active
--   value whose era is the <i>combination</i> of the eras of <tt>a1</tt>
--   and <tt>a2</tt>).
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 <i>cubic spline</i> is a smooth, connected sequence of cubic curves
--   passing through a given sequence of points. This module provides the
--   <a>cubicSpline</a> 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
--   <a>Diagrams.CubicSpline.Internal</a>.
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.
--   
--   
--   <pre>
--   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))
--                &lt;&gt; cubicSpline closed pts
--   cubicSplineEx = (mkPath False ||| strutX 2 ||| mkPath True)
--                 # centerXY # pad 1.1
--   </pre>
--   
--   For more information, see
--   <a>http://mathworld.wolfram.com/CubicSpline.html</a>.
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 <tt>d</tt> and a sweep angle <tt>s</tt>,
--   <tt><a>arc</a> d s</tt> is the path of a radius one arc starting at
--   <tt>d</tt> and sweeping out the angle <tt>s</tt> counterclockwise (for
--   positive s). The resulting <tt>Trail</tt> 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 <tt>r</tt>, a start direction <tt>d</tt> and an angle
--   <tt>s</tt>, <tt><a>arc'</a> r d s</tt> is the path of a radius
--   <tt>(abs r)</tt> arc starting at <tt>d</tt> and sweeping out the angle
--   <tt>s</tt> counterclockwise (for positive s). The origin of the arc is
--   its center.
--   
--   
--   <pre>
--   arc'Ex = mconcat [ arc' r xDir (1/4 @@ turn) | r &lt;- [0.5,-1,1.5] ]
--          # centerXY # pad 1.1
--   </pre>
arc' :: (InSpace V2 n t, OrderedField n, TrailLike t) => n -> Direction V2 n -> Angle n -> t

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

-- | Given a start direction <tt>s</tt> and end direction <tt>e</tt>,
--   <tt>arcCCW s e</tt> 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 <tt>arcAngleCCW</tt> but clockwise.
arcCW :: (InSpace V2 n t, RealFloat n, TrailLike t) => Direction V2 n -> Direction V2 n -> t

-- | <tt>bezierFromSweep s</tt> constructs a series of <a>Cubic</a>
--   segments that start in the positive y direction and sweep counter
--   clockwise through the angle <tt>s</tt>. If <tt>s</tt> is negative, it
--   will start in the negative y direction and sweep clockwise. When
--   <tt>s</tt> is less than 0.0001 the empty list results. If the sweep is
--   greater than <tt>fullTurn</tt> 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.
--   
--   
--   <pre>
--   wedgeEx = hcat' (with &amp; 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
--   </pre>
wedge :: (InSpace V2 n t, OrderedField n, TrailLike t) => n -> Direction V2 n -> Angle n -> t

-- | <tt>arcBetween p q height</tt> creates an arc beginning at <tt>p</tt>
--   and ending at <tt>q</tt>, with its midpoint at a distance of <tt>abs
--   height</tt> away from the straight line from <tt>p</tt> to <tt>q</tt>.
--   A positive value of <tt>height</tt> results in an arc to the left of
--   the line from <tt>p</tt> to <tt>q</tt>; a negative value yields one to
--   the right.
--   
--   
--   <pre>
--   arcBetweenEx = mconcat
--     [ arcBetween origin (p2 (2,1)) ht | ht &lt;- [-0.2, -0.1 .. 0.2] ]
--     # centerXY # pad 1.1
--   </pre>
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.
--   
--   
--   <pre>
--   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
--   </pre>
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

-- | <tt>ellipse e</tt> constructs an ellipse with eccentricity <tt>e</tt>
--   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

-- | <tt>ellipseXY x y</tt> creates an axis-aligned ellipse, centered at
--   the origin, with radius <tt>x</tt> along the x-axis and radius
--   <tt>y</tt> 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 <a>FixedSegment</a> from a point.
closestPoint :: OrderedField n => FixedSegment V2 n -> P2 n -> [P2 n]

-- | Get the closest point(s) on a <a>FixedSegment</a> 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 <a>FixedSegment</a>.
closestDistance :: OrderedField n => FixedSegment V2 n -> P2 n -> [n]

-- | Get the closest distance(s) from a point to a <a>FixedSegment</a>
--   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.
--   
--   
--   <pre>
--   sqNewEnv =
--       circle 1 # fc green
--       |||
--       (    c # dashingG [0.1,0.1] 0 # lc white
--         &lt;&gt; square 2 # withEnvelope (c :: D V2 Double) # fc blue
--       )
--   c = circle 0.8
--   withEnvelopeEx = sqNewEnv # centerXY # pad 1.5
--   </pre>
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

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

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

-- | <tt>pad s</tt> "pads" a diagram, expanding its envelope by a factor of
--   <tt>s</tt> (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., <tt>centerXY</tt> for 2D diagrams) before applying <tt>pad</tt>.
pad :: (Metric v, OrderedField n, Monoid' m) => n -> QDiagram b v n m -> QDiagram b v n m

-- | <tt>frame s</tt> increases the envelope of a diagram by and absolute
--   amount <tt>s</tt>, s is in the local units of the diagram. This
--   function is similar to <tt>pad</tt>, 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

-- | <tt>extrudeEnvelope v d</tt> 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

-- | <tt>intrudeEnvelope v d</tt> 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 <tt>
--   diameter v d &lt; 0 </tt>.
intrudeEnvelope :: (Metric v, OrderedField n, Monoid' m) => v n -> QDiagram b v n m -> QDiagram b v n m

-- | A convenient synonym for <a>mappend</a> 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

-- | <tt>beneath</tt> is just a convenient synonym for <tt><a>flip</a>
--   <a>atop</a></tt>; that is, <tt>d1 `beneath` d2</tt> is the diagram
--   with <tt>d2</tt> superimposed on top of <tt>d1</tt>.
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>i.e.</i> 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).
--   
--   
--   <pre>
--   besideEx = beside (r2 (20,30))
--                     (circle 1 # fc orange)
--                     (circle 1.5 # fc purple)
--              # showOrigin
--              # centerXY # pad 1.1
--   </pre>
--   
--   Note that <tt>beside v</tt> is associative, so objects under
--   <tt>beside v</tt> form a semigroup for any given vector <tt>v</tt>. In
--   fact, they also form a monoid: <a>mempty</a> is clearly a right
--   identity (<tt>beside v d1 mempty === d1</tt>), and there should also
--   be a special case to make it a left identity, as described above.
--   
--   In older versions of diagrams, <tt>beside</tt> 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 <tt>beside'</tt> denotes the
--   old semantics,
--   
--   <pre>
--   beside' v x1 x2 = beside v (x1 # align v) x2
--   </pre>
--   
--   To get something like <tt>beside v x1 x2</tt> whose local origin is
--   identified with that of <tt>x2</tt> instead of <tt>x1</tt>, use
--   <tt>beside (negateV v) x2 x1</tt>.
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 <tt>d</tt>
--   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
--   <a>beside</a> for more information.
atDirection :: (InSpace v n a, Metric v, Floating n, Juxtaposable a, Semigroup a) => Direction v n -> a -> a -> a

-- | <tt>appends x ys</tt> appends each of the objects in <tt>ys</tt> to
--   the object <tt>x</tt> in the corresponding direction. Note that each
--   object in <tt>ys</tt> is positioned beside <tt>x</tt> <i>without</i>
--   reference to the other objects in <tt>ys</tt>, so this is not the same
--   as iterating <a>beside</a>.
--   
--   
--   <pre>
--   appendsEx = appends c (zip (iterateN 6 (rotateBy (1/6)) unitX) (repeat c))
--               # centerXY # pad 1.1
--     where c = circle 1
--   </pre>
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.
--   
--   
--   <pre>
--   positionEx = position (zip (map mkPoint [-3, -2.8 .. 3]) (repeat spot))
--     where spot      = circle 0.2 # fc black
--           mkPoint :: Double -&gt; P2 Double
--           mkPoint x = p2 (x,x*x)
--   </pre>
position :: (InSpace v n a, HasOrigin a, Monoid' a) => [(Point v n, a)] -> a

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

-- | <tt>cat v</tt> positions a list of objects so that their local origins
--   lie along a line in the direction of <tt>v</tt>. 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 <a>cat'</a>, 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 <a>cat</a>, but taking an extra <a>CatOpts</a> arguments allowing
--   the user to specify
--   
--   <ul>
--   <li>The spacing method: catenation (uniform spacing between envelopes)
--   or distribution (uniform spacing between local origins). The default
--   is catenation.</li>
--   <li>The amount of separation between successive diagram
--   envelopes/origins (depending on the spacing method). The default is
--   0.</li>
--   </ul>
--   
--   <a>CatOpts</a> is an instance of <a>Default</a>, so <a>with</a> may be
--   used for the second argument, as in <tt>cat' (1,2) (with &amp; sep .~
--   2)</tt>.
--   
--   Note that <tt>cat' v (with &amp; catMethod .~ Distrib) ===
--   mconcat</tt> (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 <a>cat'</a>.
data CatOpts n

-- | Which <a>CatMethod</a> 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 <tt>catMethod = Cat</tt>, this is the distance
--   between <i>envelopes</i>; when <tt>catMethod = Distrib</tt>, this is
--   the distance between <i>origins</i>.
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 <i>envelopes</i> will be consistent; the distance
--   between <i>origins</i> 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
--   <i>origins</i> 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
--   <a>Diagrams.Core.Envelope</a> for internal implementation details.
module Diagrams.Envelope

-- | Every diagram comes equipped with an <i>envelope</i>. What is an
--   envelope?
--   
--   Consider first the idea of a <i>bounding box</i>. 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 <i>every</i>
--   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 <i>extensional</i> representation of such a
--   "bounding region". Instead of storing some sort of direct
--   representation, we store a <i>function</i> 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 <tt>v</tt>, the envelope computes a scalar
--   <tt>s</tt> such that
--   
--   <ul>
--   <li>for every point <tt>u</tt> inside the diagram, if the projection
--   of <tt>(u - origin)</tt> onto <tt>v</tt> is <tt>s' *^ v</tt>, then
--   <tt>s' &lt;= s</tt>.</li>
--   <li><tt>s</tt> is the smallest such scalar.</li>
--   </ul>
--   
--   There is also a special "empty envelope".
--   
--   The idea for envelopes came from Sebastian Setzer; see
--   <a>http://byorgey.wordpress.com/2009/10/28/collecting-attributes/#comment-2030</a>.
--   See also Brent Yorgey, <i>Monoids: Theme and Variations</i>, published
--   in the 2012 Haskell Symposium:
--   <a>http://www.cis.upenn.edu/~byorgey/pub/monoid-pearl.pdf</a>; video:
--   <a>http://www.youtube.com/watch?v=X-8NCkD2vOw</a>.
data Envelope (v :: * -> *) n :: (* -> *) -> * -> *

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

-- | Lens onto the <a>Envelope</a> of a <a>QDiagram</a>.
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.
--   
--   
--   <pre>
--   sqNewEnv =
--       circle 1 # fc green
--       |||
--       (    c # dashingG [0.1,0.1] 0 # lc white
--         &lt;&gt; square 2 # withEnvelope (c :: D V2 Double) # fc blue
--       )
--   c = circle 0.8
--   withEnvelopeEx = sqNewEnv # centerXY # pad 1.5
--   </pre>
withEnvelope :: (InSpace v n a, Metric v, OrderedField n, Monoid' m, Enveloped a) => a -> QDiagram b v n m -> QDiagram b v n m

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

-- | <tt>pad s</tt> "pads" a diagram, expanding its envelope by a factor of
--   <tt>s</tt> (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., <tt>centerXY</tt> for 2D diagrams) before applying <tt>pad</tt>.
pad :: (Metric v, OrderedField n, Monoid' m) => n -> QDiagram b v n m -> QDiagram b v n m

-- | <tt>extrudeEnvelope v d</tt> 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

-- | <tt>intrudeEnvelope v d</tt> 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 <tt>
--   diameter v d &lt; 0 </tt>.
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 <tt>Nothing</tt> 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 <tt>Nothing</tt> 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 <a>Diagrams.Core.Trace</a> for internal implementation
--   details.
module Diagrams.Trace

-- | Every diagram comes equipped with a <i>trace</i>. 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 <tt>p</tt>
--   and direction vector is <tt>v</tt>, and one of the output scalars is
--   <tt>s</tt>, then there is an intersection at the point <tt>p .+^ (s *^
--   v)</tt>.
--   
data Trace (v :: * -> *) n :: (* -> *) -> * -> *

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

-- | Lens onto the <a>Trace</a> of a <a>QDiagram</a>.
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 <tt>p</tt> to the "smallest"
--   boundary intersection along the given vector <tt>v</tt>. The
--   "smallest" boundary intersection is defined as the one given by <tt>p
--   .+^ (s *^ v)</tt> for the smallest (most negative) value of
--   <tt>s</tt>. Return <tt>Nothing</tt> if there is no intersection. See
--   also <a>traceP</a>.
--   
--   See also <a>rayTraceV</a> which uses the smallest <i>positive</i>
--   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 <tt>p</tt> and vector <tt>v</tt>. The "smallest" boundary
--   point is defined as the one given by <tt>p .+^ (s *^ v)</tt> for the
--   smallest (most negative) value of <tt>s</tt>. Return <tt>Nothing</tt>
--   if there is no such boundary point. See also <a>traceV</a>.
--   
--   See also <a>rayTraceP</a> which uses the smallest <i>positive</i>
--   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 <a>traceV</a>, 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 <a>traceP</a>, 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 <a>boundaryFromMay</a>.
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 <tt>Nothing</tt> 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 <i>alignment</i> of an object refers to the position of its local
--   origin with respect to its envelope. This module defines the
--   <a>Alignable</a> class for things which can be aligned, as well as a
--   default implementation in terms of <a>HasOrigin</a> and
--   <a>Enveloped</a>, 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

-- | <tt>alignBy v d a</tt> moves the origin of <tt>a</tt> along the vector
--   <tt>v</tt>. If <tt>d = 1</tt>, the origin is moved to the edge of the
--   boundary in the direction of <tt>v</tt>; if <tt>d = -1</tt>, it moves
--   to the edge of the boundary in the direction of the negation of
--   <tt>v</tt>. Other values of <tt>d</tt> interpolate linearly (so for
--   example, <tt>d = 0</tt> centers the origin along the direction of
--   <tt>v</tt>).
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 <a>alignBy</a> for types with
--   <a>HasOrigin</a> and <tt>AdditiveGroup</tt> 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 <tt>boundary</tt>
--   argument to <a>alignBy'</a>.
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

-- | <tt>align v</tt> aligns an enveloped object along the edge in the
--   direction of <tt>v</tt>. That is, it moves the local origin in the
--   direction of <tt>v</tt> 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

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

-- | <tt>center</tt> 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 <tt>alignBy</tt> specialized to use <tt>traceBoundary</tt>
snugBy :: (InSpace v n a, Fractional n, Alignable a, Traced a, HasOrigin a) => v n -> n -> a -> a

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

-- | Like <tt>center</tt> 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 <i>paths</i>, which are collections of concretely
--   located <a>Trail</a>s. Many drawing systems (cairo, svg, ...) have a
--   similar notion of "path". Note that paths with multiple trails are
--   necessary for being able to draw <i>e.g.</i> filled objects with holes
--   in them.
module Diagrams.Path

-- | A <i>path</i> is a (possibly empty) list of <a>Located</a>
--   <a>Trail</a>s. Hence, unlike trails, paths are not translationally
--   invariant, and they form a monoid under <i>superposition</i> (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 <a>Path</a>.
pathTrails :: Path v n -> [Located (Trail v n)]

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

-- | <a>toPath</a> takes something that can be converted to <a>Path</a> and
--   returns the <a>Path</a>.
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
--   <a>trailLike</a>, 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 <i>point</i> is any place where two
--   segments join; see also <a>pathVertices</a> and <a>trailPoints</a>.
--   
--   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
--   <a>pathVertices</a>.
--   
--   This function is not re-exported from <a>Diagrams.Prelude</a>; to use
--   it, import <a>Diagrams.Path</a>.
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 <i>vertex</i> is defined as
--   a non-differentiable point on the trail, <i>i.e.</i> a sharp corner.
--   (Vertices are thus a subset of the places where segments join; if you
--   want all joins between segments, see <a>pathPoints</a>.) The tolerance
--   determines how close the tangents of two segments must be at their
--   endpoints to consider the transition point to be differentiable. See
--   <a>trailVertices</a> for more information.
pathVertices' :: (Metric v, OrderedField n) => n -> Path v n -> [[Point v n]]

-- | Like <a>pathVertices'</a>, 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
--   <a>trailOffset</a>).
pathOffsets :: (Metric v, OrderedField n) => Path v n -> [v n]

-- | Compute the <i>centroid</i> of a path (<i>i.e.</i> the average
--   location of its <i>vertices</i>; see <a>pathVertices</a>).
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 <a>FixedSegment</a>s.
fixPath :: (Metric v, OrderedField n) => Path v n -> [[FixedSegment v n]]

-- | Scale a path using its centroid (see <a>pathCentroid</a>) 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
--   <a>explodeTrail</a>).
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
--   <tt>True</tt>, 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

-- | <tt>Deformations</tt> are a superset of the affine transformations
--   represented by the <a>Transformation</a> type. In general they are not
--   invertible. <tt>Deformation</tt>s include projective transformations.
--   <tt>Deformation</tt> 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

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

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

-- | <tt>asDeformation</tt> converts a <a>Transformation</a> to a
--   <a>Deformation</a> by discarding the inverse transform. This allows
--   reusing <tt>Transformation</tt>s in the construction of
--   <tt>Deformation</tt>s.
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. <tt>asDeformation (translation unitX) &lt;&gt;
--   parallelX0 &lt;&gt; frustrumX = perspectiveX1</tt>
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. <tt>asDeformation (translation unitX) &lt;&gt;
--   parallelX0 &lt;&gt; frustrumX = perspectiveX1</tt>
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 <a>ToPath</a> object into a diagram. The resulting diagram
--   has the names 0, 1, ... assigned to each of the path's vertices.
--   
--   See also <a>stroke'</a>, 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 <a>stroke</a> that takes an extra record of options to
--   customize its behaviour. In particular:
--   
--   <ul>
--   <li>Names can be assigned to the path's vertices</li>
--   </ul>
--   
--   <a>StrokeOpts</a> is an instance of <a>Default</a>, so <tt>stroke'
--   (<tt>with</tt> &amp; ... )</tt> 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

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

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

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

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

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

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

-- | A composition of <a>stroke'</a> and <a>pathFromTrail</a> 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 <a>strokeTrail'</a>.
strokeT' :: (TypeableFloat n, Renderable (Path V2 n) b, IsName a) => StrokeOpts a -> Trail V2 n -> QDiagram b V2 n Any

-- | A composition of <a>strokeT</a> and <a>wrapLine</a> 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 <a>strokeT</a> and <a>wrapLoop</a> 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 <tt>Located Trail</tt>
--   directly into a diagram; <tt>strokeLocTrail = stroke . trailLike</tt>.
strokeLocTrail :: (TypeableFloat n, Renderable (Path V2 n) b) => Located (Trail V2 n) -> QDiagram b V2 n Any

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

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

-- | A convenience function for converting a <tt>Located</tt> loop directly
--   into a diagram; <tt>strokeLocLoop = stroke . trailLike . mapLoc
--   wrapLoop</tt>.
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 <i>winding</i> <i>number</i>.
--   See <a>http://en.wikipedia.org/wiki/Nonzero-rule</a>.
Winding :: FillRule

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

-- | Extract the fill rule from a <tt>FillRuleA</tt> 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.
--   <tt>StrokeOpts</tt> is an instance of <a>Default</a>, so a
--   <tt>StrokeOpts</tt> records can be created using <tt><tt>with</tt> {
--   ... }</tt> 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 <i>list of lists</i> 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 <a>Winding</a>. NOTE: for now, this only affects the
--   resulting diagram's <a>Query</a>, <i>not</i> how it will be drawn! To
--   set the fill rule determining how it is to be drawn, use the
--   <a>fillRule</a> function.
queryFillRule :: Lens' (StrokeOpts a) FillRule

-- | Test whether the given point is inside the given path, by testing
--   whether the point's <i>winding number</i> is nonzero. Note that
--   <tt>False</tt> is <i>always</i> 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 <tt>False</tt> is <i>always</i> 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

-- | <tt>Clip</tt> tracks the accumulated clipping paths applied to a
--   diagram. Note that the semigroup structure on <tt>Clip</tt> 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:
--   
--   <ul>
--   <li>Only the parts of the diagram which lie in the interior of the
--   path will be drawn.</li>
--   <li>The envelope of the diagram is unaffected.</li>
--   </ul>
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 <a>Transformation</a>s these are not restricted to
--   the same space. In practice these are used for projections in
--   <a>Diagrams.ThreeD.Projection</a>. Unless you want to work with
--   projections you're probably better off using <a>Transform</a>.
--   
--   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 <a>LinearMap</a> 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 <a>Transformation</a> 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
--   <a>Linear.Projection</a>.
--   
--   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 <a>AffineMap</a> 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 <a>AffineMap</a> 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.
--   
--   <ul>
--   <li>The first argument is a list of <i>central</i> <i>angles</i> from
--   each vertex to the next.</li>
--   <li>The second argument is a list of <i>radii</i> from the origin to
--   each successive vertex.</li>
--   </ul>
--   
--   To construct an <i>n</i>-gon, use a list of <i>n-1</i> angles and
--   <i>n</i> radii. Extra angles or radii are ignored.
--   
--   Cyclic polygons (with all vertices lying on a circle) can be
--   constructed using a second argument of <tt>(repeat r)</tt>.
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
--   <i>centroid</i> of its vertices.
--   
--   <ul>
--   <li>The first argument is a list of <i>vertex</i> <i>angles</i>,
--   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
--   <i>second</i> vertex; the first edge always starts out heading in the
--   positive y direction from the first vertex.</li>
--   <li>The second argument is a list of distances between successive
--   vertices.</li>
--   </ul>
--   
--   To construct an <i>n</i>-gon, use a list of <i>n-2</i> angles and
--   <i>n-1</i> 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 <i>horizontally</i>, so the bottommost edge is parallel to the
--   x-axis.
OrientH :: PolyOrientation n

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

-- | Orient so some edge is <i>facing</i> <i>in</i> <i>the</i>
--   <i>direction</i> <i>of</i>, 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 <a>PolygonOpts</a> 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 <a>PolyPolar</a>.
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 <a>PolySides</a>.
polySidesTrail :: OrderedField n => [Angle n] -> [n] -> Located (Trail V2 n)

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

-- | Generate a transformation to orient a trail. <tt>orient v t</tt>
--   generates the smallest rotation such that one of the segments adjacent
--   to the vertex furthest in the direction of <tt>v</tt> is perpendicular
--   to <tt>v</tt>.
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 <i>n</i> means that edges will connect every
--   <i>n</i>th vertex.
StarSkip :: Int -> StarOpts

-- | Create a generalized <i>star</i> <i>polygon</i>. The <a>StarOpts</a>
--   are used to determine in which order the given vertices should be
--   connected. The intention is that the second argument of type
--   <tt>[Point v]</tt> could be generated by a call to <a>polygon</a>,
--   <tt>regPoly</tt>, or the like, since a list of vertices is
--   <a>TrailLike</a>. But of course the list can be generated any way you
--   like. A <tt><a>Path</a> <tt>v</tt></tt> is returned (instead of any
--   <a>TrailLike</a>) 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

-- | <tt>orbits f n</tt> computes the graph of <tt>f</tt> on the integers
--   mod <tt>n</tt>.
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.
--   
--   
--   <pre>
--   hruleEx = vcat' (with &amp; sep .~ 0.2) (map hrule [1..5])
--           # centerXY # pad 1.1
--   </pre>
hrule :: (InSpace V2 n t, TrailLike t) => n -> t

-- | Create a centered vertical (T-B) line of the given length.
--   
--   
--   <pre>
--   vruleEx = hcat' (with &amp; sep .~ 0.2) (map vrule [1, 1.2 .. 2])
--           # centerXY # pad 1.1
--   </pre>
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 <i>length</i> of the sides. (Compare to the
--   <a>polygon</a> function with a <a>PolyRegular</a> option, which
--   produces polygons of a given <i>radius</i>).
--   
--   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 <a>triangle</a>, 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 <a>heptagon</a>. It is, however, completely inferior,
--   being a base admixture of the Latin <i>septum</i> (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

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

-- | <tt>roundedRect w h r</tt> generates a closed trail, or closed path
--   centered at the origin, of an axis-aligned rectangle with width
--   <tt>w</tt>, height <tt>h</tt>, and circular rounded corners of radius
--   <tt>r</tt>. If <tt>r</tt> is negative the corner will be cut out in a
--   reverse arc. If the size of <tt>r</tt> is larger than half the smaller
--   dimension of <tt>w</tt> and <tt>h</tt>, 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
--   <a>roundedRect'</a> instead.
--   
--   
--   <pre>
--   roundedRectEx = pad 1.1 . centerXY $ hcat' (with &amp; sep .~ 0.2)
--     [ roundedRect  0.5 0.4 0.1
--     , roundedRect  0.5 0.4 (-0.1)
--     , roundedRect' 0.7 0.4 (with &amp; radiusTL .~ 0.2
--                                  &amp; radiusTR .~ -0.2
--                                  &amp; radiusBR .~ 0.1)
--     ]
--   </pre>
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

-- | <tt>roundedRect'</tt> works like <tt>roundedRect</tt> but allows you
--   to set the radius of each corner indivually, using
--   <tt>RoundedRectOpts</tt>. 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 (<i>e.g.</i> 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 <tt>Maybe</tt>.
data BoundingBox v n

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

-- | Create a bounding box from a point that is component-wise
--   <tt>(&lt;=)</tt> than the other. If this is not the case, then
--   <tt>mempty</tt> 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
--   <a>Nothing</a> 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 <a>Nothing</a> 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 <tt>BoundingBox</tt>. If
--   the bounding box is empty, then the result is also <tt>mempty</tt>.
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 <i>strictly</i> 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 <i>strictly</i> 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 <i>strictly</i> 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 <tt>mappend</tt>.
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 <tt>Nothing</tt> 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 <a>SizeSpec</a> is a way of specifying a size without needed lengths
--   for all the dimensions.
data SizeSpec v n

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

-- | Make a <a>SizeSpec</a> 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)

-- | <tt>specToSize n spec</tt> extracts a size from a <a>SizeSpec</a>
--   <tt>sz</tt>. 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. <a>absolute</a>) then <tt>n</tt> is used.
specToSize :: (Foldable v, Functor v, Num n, Ord n) => n -> SizeSpec v n -> v n

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

-- | Return the <a>Transformation</a> calcuated from <a>requiredScale</a>.
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 <a>boxFit</a>.
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 <a>BoundingBox</a> in the given
--   <a>SizeSpec</a>. 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 <tt>diameter unitX</tt>.
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 <tt>(lo,hi)</tt>. Return <tt>Nothing</tt> for objects with an
--   empty envelope.
--   
--   Note this is just <tt>extent unitX</tt>.
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 <tt>(lo,hi)</tt>. Return <tt>Nothing</tt> for objects with an
--   empty envelope.
extentY :: (InSpace v n a, R2 v, Enveloped a) => a -> Maybe (n, n)

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

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

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

-- | Make a <a>SizeSpec</a> 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 <tt>(lo,hi)</tt>. Return <tt>Nothing</tt> for objects with an
--   empty envelope.
--   
--   Note this is just <tt>extent unitX</tt>.
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 <tt>(lo,hi)</tt>. Return <tt>Nothing</tt> 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 <tt>(lo,hi)</tt>. Return <tt>Nothing</tt> for objects with an
--   empty envelope.
extentZ :: (InSpace v n a, R3 v, Enveloped a) => a -> Maybe (n, n)

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

-- | Make a <a>SizeSpec</a> 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 <tt>active</tt> package, which defines the <a>Active</a>
--   type.
--   
--   XXX more documentation and examples should go here
module Diagrams.Animation

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

-- | A value of type <tt>Animation b v</tt> is an animation (a time-varying
--   diagram with start and end times) in vector space <tt>v</tt> that can
--   be rendered by backspace <tt>b</tt>.
--   
--   Note that <tt>Animation</tt> is actually a synonym for
--   <tt>QAnimation</tt> where the type of the monoidal annotations has
--   been fixed to <a>Any</a> (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, <i>e.g.</i> 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
--   <tt>|||</tt>.
--   
--   By default, 30 samples per time unit are used; to adjust this number
--   see <a>animEnvelope'</a>.
--   
--   See also <a>animRect</a> 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 <a>animEnvelope</a>, 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

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

-- | Like <a>animRect</a>, 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
--   <a>Diagrams.Align</a> 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. <tt>map <tt>alignTop</tt></tt>), and then put them
--   together with their local origins along a horizontal line (using e.g.
--   <tt>hcat</tt> from <a>Diagrams.TwoD.Combinators</a>).
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

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

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

-- | Like <a>alignX</a>, but moving the local origin vertically, with an
--   argument of <tt>1</tt> corresponding to the top edge and <tt>(-1)</tt>
--   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 <a>alignY</a>.
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
--   <a>Diagrams.Align</a> 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. <tt>map <a>alignZMax</a></tt>), and then put them together
--   with their local origins along a line (using e.g. <tt>cat</tt> from
--   <a>Diagrams.Combinators</a>).
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

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

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

-- | Like <a>alignX</a>, but moving the local origin vertically, with an
--   argument of <tt>1</tt> corresponding to the top edge and <tt>(-1)</tt>
--   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 <a>alignY</a>.
snugY :: (InSpace v n a, R2 v, Fractional n, Alignable a, Traced a, HasOrigin a) => n -> a -> a

-- | Like <a>alignX</a>, but moving the local origin in the Z direction,
--   with an argument of <tt>1</tt> corresponding to the top edge and
--   <tt>(-1)</tt> 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 <a>alignZ</a>.
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:
--   
--   <ul>
--   <li><a>Diagrams.ThreeD.Types</a> defines basic types for
--   two-dimensional diagrams, including types representing the 3D
--   Euclidean vector space and various systems of representing
--   directions.</li>
--   <li><a>Diagrams.ThreeD.Transform</a> defines R^3-specific
--   transformations such as rotation by an angle, and scaling,
--   translation, and reflection in the X, Y, and Z directions.
--   <a>Diagrams.ThreeD.Deform</a> defines several R^3-specific non-affine
--   transformations, such as projections.</li>
--   <li><a>Diagrams.ThreeD.Shapes</a> defines three-dimensional solids,
--   e.g. spheres and cubes.</li>
--   <li><a>Diagrams.ThreeD.Vector</a> defines some special 3D vectors and
--   functions for converting between vectors and directions.</li>
--   <li><a>Diagrams.ThreeD.Light</a> and <a>Diagrams.ThreeD.Camera</a>
--   define types needed for rendering 3D geometry to (2D) images.</li>
--   <li><a>Diagrams.ThreeD.Align</a> defines many alignment combinators
--   specialized to three dimensions.</li>
--   <li><a>Diagrams.ThreeD.Attributes</a> defines 3D-specific attributes
--   such as surface color, diffuse reflectance, and specular
--   highlights.</li>
--   </ul>
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 <a>arrowheadDart</a>.
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 <i>attributes</i> 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 <i>semigroup</i> structure, that is,
--   an associative binary operation for combining two attributes into one.
--   Unless otherwise noted, all the attributes defined here use the
--   <a>Last</a> 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 <a>LineWidth</a> 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 <a>lineWidth</a>.
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 <a>Dashing</a> 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 <a>Color</a> type class encompasses color representations which
--   can be used by the Diagrams library. Instances are provided for both
--   the <a>Colour</a> and <a>AlphaColour</a> types from the
--   <a>Data.Colour</a> 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 <a>Colour</a> drops
--   the alpha channel.
fromAlphaColour :: Color c => AlphaColour Double -> c

-- | An existential wrapper for instances of the <a>Color</a> class.
data SomeColor
SomeColor :: c -> SomeColor

-- | Isomorphism between <a>SomeColor</a> and <a>AlphaColour</a>
--   <a>Double</a>.
_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
--   <tt>Opacity</tt> attribute. The opacity is a value between 1
--   (completely opaque, the default) and 0 (completely transparent).
--   Opacity is multiplicative, that is, <tt><a>opacity</a> o1 .
--   <a>opacity</a> o2 === <a>opacity</a> (o1 * o2)</tt>. In other words,
--   for example, <tt>opacity 0.8</tt> 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 <a>Opacity</a>) by the given value. For
--   example, <tt>opacity 0.8</tt> 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.

-- | <i>Deprecated: Renamed to colorToSRGBA.</i>
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 <a>LineJoinMiter</a> 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 <a>LineJoinMiter</a>.
lineMiterLimit :: HasStyle a => Double -> a -> a

-- | Apply a <a>LineMiterLimit</a> 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 <a>Recommend</a>.
_Recommend :: Prism' (Recommend a) a

-- | Prism onto a <a>Commit</a>.
_Commit :: Prism' (Recommend a) a

-- | Lens onto the value inside either a <a>Recommend</a> or <a>Commit</a>.
--   Unlike <a>committed</a>, 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

-- | <a>Commit</a> a value for any <a>Recommend</a>. This is *not* a valid
--   <a>Iso</a> because the resulting <tt>Recommend b</tt> is always a
--   <a>Commit</a>. This is useful because it means any <a>Recommend</a>
--   styles set with a lens will not be accidentally overridden. If you
--   want a valid lens onto a recommend value use <a>_recommend</a>.
--   
--   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
--   <a>http://projects.haskell.org/diagrams/doc/cmdline.html</a>.
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 <a>DiagramOpts</a>. Width is option
--   <tt>--width</tt> or <tt>-w</tt>. Height is option <tt>--height</tt> or
--   <tt>-h</tt> (note we change help to be <tt>-?</tt> due to this).
--   Output is option <tt>--output</tt> or <tt>-o</tt>.
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 <a>DiagramMultiOpts</a>. Selection is option
--   <tt>--selection</tt> or <tt>-S</tt>. List is <tt>--list</tt> or
--   <tt>-L</tt>.
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 <a>DiagramAnimOpts</a> Frames per unit is
--   <tt>--fpu</tt> or <tt>-f</tt>.
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 <a>DiagramLoopOpts</a> Loop is <tt>--loop</tt>
--   or <tt>-l</tt>. Source is <tt>--src</tt> or <tt>-s</tt>. Interval is
--   <tt>-i</tt> 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 <a>Parseable</a> instance. Notice that we do <i>not</i>
--   want as many instances as <a>Read</a> 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 <tt>"0x"</tt> or
--   <tt>"#"</tt> 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, <tt>"0xfc4"</tt> is the same as
--   <tt>"0xffcc44"</tt>. 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 <a>Parseable</a>.
--   
--   Backends are expected to create <tt>Mainable</tt> 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 <tt>Diagram Postscript R2</tt>, <tt>[Diagram
--   Postscript R2]</tt>, <tt>Animation Postscript R2</tt>, and
--   <tt>[(String,Diagram Postscript R2)]</tt>. We can consider these as
--   the base cases for the function instance.
--   
--   The associated type <a>MainOpts</a> describes the options which need
--   to be parsed from the command-line and passed to <tt>mainRender</tt>.
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 <tt>d</tt> argument should only be needed to fix the type
--   <tt>d</tt>. 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 <tt>main</tt>. For instance an
--   expected user program would take the following form.
--   
--   <pre>
--   import Diagrams.Prelude
--   import Diagrams.Backend.TheBestBackend.CmdLine
--   
--   d :: Diagram B R2
--   d = ...
--   
--   main = mainWith d
--   </pre>
--   
--   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 <tt>d</tt> is an
--   instance of <a>ToResult</a> we get a type <tt><a>Args</a> d</tt> that
--   is a type of <i>all</i> the arguments at once, and a type
--   <tt><a>ResultOf</a> d</tt> 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

-- | <tt>defaultAnimMainRender</tt> is an implementation of
--   <a>mainRender</a> 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 <tt>foo/blah.ext</tt>, the
--   frames will be saved in <tt>foo/blah001.ext</tt>,
--   <tt>foo/blah002.ext</tt>, 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, <i>e.g.</i> <tt>ffmpeg</tt>).
--   
--   Of course, this is a rather crude method of rendering animations; more
--   sophisticated methods will likely be added in the future.
--   
--   The <tt>fpu</tt> option from <a>DiagramAnimOpts</a> 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 <tt>MainOpts (QDiagram b v
--   n Any) ~ DiagramOpts</tt> then this lens will simply be <a>output</a>.
--   For a backend supporting looping it will most likely be <tt>_1 .
--   output</tt>. This lens is required because the implementation works by
--   modifying the output field and running the base <tt>mainRender</tt>.
--   Typically a backend can write its <tt>Animation B V</tt> instance as
--   
--   <pre>
--   instance Mainable (Animation B V) where
--       type MainOpts (Animation B V) = (DiagramOpts, DiagramAnimOpts)
--       mainRender = defaultAnimMainRender output
--   
--   </pre>
--   
--   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 ()

-- | <tt>defaultMultiMainRender</tt> is an implementation of
--   <a>mainRender</a> where instead of a single diagram it takes a list of
--   diagrams paired with names as input. The generated executable then
--   takes a <tt>--selection</tt> option specifying the name of the diagram
--   that should be rendered. The list of available diagrams may also be
--   printed by passing the option <tt>--list</tt>.
--   
--   Typically a backend can write its <tt>[(String,QDiagram b v n
--   Any)]</tt> instance as
--   
--   <pre>
--   instance Mainable [(String,QDiagram b v n Any)] where
--       type MainOpts [(String,QDiagram b v n Any)] = (DiagramOpts, DiagramMultiOpts)
--       mainRender = defaultMultiMainRender
--   
--   </pre>
--   
--   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 <i>attributes</i> which affect the way they are
--   rendered. This module defines <i>Textures</i> (Gradients and Colors)
--   in two dimensions. Like the attributes defined in the
--   Diagrams.Attributes module, all attributes defined here use the
--   <a>Last</a> or <a>Recommend</a> <i>semigroup</i> structure.
--   <tt>FillColor</tt> and <tt>LineColor</tt> 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 <a>SC</a>, linear gradient <a>LG</a>, or
--   radial gradient <a>RG</a>. An object can have only one texture which
--   is determined by the <a>Last</a> 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 <a>AlphaColour</a> <a>Double</a> of a <a>SC</a> 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, <tt>lg = defaultLG &amp; lGradStart .~
--   (0.25 ^&amp; 0.33)</tt>. Note that no default value is provided for
--   <tt>lGradStops</tt>, 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, <tt>rg = defaultRG &amp; rGradRadius1 .~
--   0.25</tt>. Note that no default value is provided for
--   <tt>rGradStops</tt>, 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 <a>SpreadMethod</a> determines what happens before
--   <a>lGradStart</a> and after <a>lGradEnd</a>. <a>GradPad</a> 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. <a>GradRepeat</a> restarts the gradient and
--   <a>GradReflect</a> 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
--   <a>local</a> 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
--   <a>local</a> 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 <a>SpreadMethod</a>. The <a>lGradTrans</a> field is set to
--   the identity transfrom, to change it use the <a>lGradTrans</a> 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 <a>local</a> 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 <a>local</a> 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 <a>SpreadMethod</a>. The <a>rGradTrans</a> field is set
--   to the identity transfrom, to change it use the <a>rGradTrans</a>
--   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 <a>Last</a>.
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 <a>Colour</a> or
--   <a>AlphaColour</a>), but this can sometimes create problems for type
--   inference, so the <a>lc</a> and <a>lcA</a> 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 <a>lineColor</a>, specialized to <tt><a>Colour</a>
--   Double</tt> (i.e. opaque colors). See comment in <a>lineColor</a>
--   about backends.
lc :: (InSpace V2 n a, Typeable n, Floating n, HasStyle a) => Colour Double -> a -> a

-- | A synonym for <a>lineColor</a>, specialized to <tt><a>AlphaColour</a>
--   Double</tt> (i.e. colors with transparency). See comment in
--   <a>lineColor</a> 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 <i>not</i> a valid setter
--   because it doesn't abide the functor law (see <a>committed</a>).
_fillTexture :: (Typeable n, Floating n) => Lens' (Style V2 n) (Texture n)

-- | Lens onto the <a>Recommend</a> 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 <a>Colour</a> or <a>AlphaColour</a>), but
--   this can sometimes create problems for type inference, so the
--   <a>fc</a> and <a>fcA</a> 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 <a>fillColor</a>, specialized to <tt><a>Colour</a>
--   Double</tt> (i.e. opaque colors). See comment after <a>fillColor</a>
--   about backends.
fc :: (InSpace V2 n a, Floating n, Typeable n, HasStyle a) => Colour Double -> a -> a

-- | A synonym for <a>fillColor</a>, specialized to <tt><a>AlphaColour</a>
--   Double</tt> (i.e. colors with transparency). See comment after
--   <a>fillColor</a> 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 <a>fillColor</a> (or <a>fc</a>, or <a>fcA</a>) are used. See
--   comment after <a>fillColor</a> 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
--   lines<i>non-closed paths as well as loops</i>closed 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:
--   <a>http://projects.haskell.org/diagrams/doc/arrow.html</a>.
module Diagrams.TwoD.Arrow

-- | <tt>arrowV v</tt> creates an arrow with the direction and norm of the
--   vector <tt>v</tt> (with its tail at the origin), using default
--   parameters.
arrowV :: (TypeableFloat n, Renderable (Path V2 n) b) => V2 n -> QDiagram b V2 n Any

-- | <tt>arrowV' v</tt> creates an arrow with the direction and norm of the
--   vector <tt>v</tt> (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

-- | <tt>arrowBetween s e</tt> creates an arrow pointing from <tt>s</tt> to
--   <tt>e</tt> with default parameters.
arrowBetween :: (TypeableFloat n, Renderable (Path V2 n) b) => Point V2 n -> Point V2 n -> QDiagram b V2 n Any

-- | <tt>arrowBetween' opts s e</tt> creates an arrow pointing from
--   <tt>s</tt> to <tt>e</tt> using the given options. In particular, it
--   scales and rotates <tt>arrowShaft</tt> to go between <tt>s</tt> and
--   <tt>e</tt>, 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

-- | <tt>arrow len</tt> creates an arrow of length <tt>len</tt> with
--   default parameters, starting at the origin and ending at the point
--   <tt>(len,0)</tt>.
arrow :: (TypeableFloat n, Renderable (Path V2 n) b) => n -> QDiagram b V2 n Any

-- | <tt>arrow' opts len</tt> creates an arrow of length <tt>len</tt> using
--   the given options, starting at the origin and ending at the point
--   <tt>(len,0)</tt>. In particular, it scales the given <a>arrowShaft</a>
--   so that the entire arrow has length <tt>len</tt>.
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 <tt>headGap</tt> and <tt>tailGap</tt> 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 <tt>... (with &amp; headTexture .~ grad)</tt>
--   to get an arrow with a head filled with a gradient, assuming grad has
--   been defined. Or <tt>... (with &amp; headTexture .~ solid blue</tt> to
--   set the head color to blue. For more general control over the style of
--   arrowheads, see <a>headStyle</a>.
headTexture :: TypeableFloat n => Lens' (ArrowOpts n) (Texture n)

-- | Style to apply to the head. <tt>headStyle</tt> is modified by using
--   the lens combinator <tt>%~</tt> to change the current style. For
--   example, to change an opaque black arrowhead to translucent orange:
--   <tt>(with &amp; headStyle %~ fc orange . opacity 0.75)</tt>.
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 <a>committed</a>).
tailTexture :: TypeableFloat n => Lens' (ArrowOpts n) (Texture n)

-- | Style to apply to the tail. See <a>headStyle</a>.
tailStyle :: Lens' (ArrowOpts n) (Style V2 n)

-- | The length of the tail plus its joint.
tailLength :: Lens' (ArrowOpts n) (Measure n)

-- | Set both the <tt>headLength</tt> and <tt>tailLength</tt>
--   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 <a>headStyle</a>.
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 <a>Diagrams.Combinators</a>.
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
--   
--   <pre>
--    c
--   ===
--    d
--   
--   </pre>
--   
--   to place <tt>c</tt> above <tt>d</tt>. The local origin of the
--   resulting combined diagram is the same as the local origin of the
--   first. <tt>(===)</tt> is associative and has <a>mempty</a> as an
--   identity. See the documentation of <a>beside</a> 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. <tt>(|||)</tt> is associative and
--   has <a>mempty</a> as an identity. See the documentation of
--   <a>beside</a> 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.
--   
--   <ul>
--   <li>For more control over the spacing, see <a>hcat'</a>.</li>
--   <li>To align the diagrams vertically (or otherwise), use alignment
--   combinators (such as <a>alignT</a> or <a>alignB</a>) from
--   <a>Diagrams.TwoD.Align</a> before applying <a>hcat</a>.</li>
--   <li>For non-axis-aligned layout, see <a>cat</a>.</li>
--   </ul>
hcat :: (InSpace V2 n a, Floating n, Juxtaposable a, HasOrigin a, Monoid' a) => [a] -> a

-- | A variant of <a>hcat</a> taking an extra <a>CatOpts</a> record to
--   control the spacing. See the <a>cat'</a> documentation for a
--   description of the possibilities. For the common case of setting just
--   a separation amount, see <a>hsep</a>.
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:
--   <tt>hsep s === hcat' (with &amp; sep .~ s)</tt>.
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.
--   
--   <ul>
--   <li>For more control over the spacing, see <a>vcat'</a>.</li>
--   <li>To align the diagrams horizontally (or otherwise), use alignment
--   combinators (such as <a>alignL</a> or <a>alignR</a>) from
--   <a>Diagrams.TwoD.Align</a> before applying <a>vcat</a>.</li>
--   <li>For non-axis-aligned layout, see <a>cat</a>.</li>
--   </ul>
vcat :: (InSpace V2 n a, Floating n, Juxtaposable a, HasOrigin a, Monoid' a) => [a] -> a

-- | A variant of <a>vcat</a> taking an extra <a>CatOpts</a> record to
--   control the spacing. See the <a>cat'</a> documentation for a
--   description of the possibilities. For the common case of setting just
--   a separation amount, see <a>vsep</a>.
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:
--   <tt>vsep s === vcat' (with &amp; sep .~ s)</tt>.
vsep :: (InSpace V2 n a, Floating n, Juxtaposable a, HasOrigin a, Monoid' a) => n -> [a] -> a

-- | <tt>strutR2 v</tt> is a two-dimensional diagram which produces no
--   output, but with respect to alignment, envelope, <i>and trace</i> acts
--   like a 1-dimensional segment oriented along the vector <tt>v</tt>,
--   with local origin at its center. If you don't care about the trace
--   then there's no difference between <tt>strutR2</tt> and the more
--   general <a>strut</a>.
strutR2 :: (RealFloat n, Monoid' m) => V2 n -> QDiagram b V2 n m

-- | <tt>strutX w</tt> is an empty diagram with width <tt>w</tt>, height 0,
--   and a centered local origin. Note that <tt>strutX (-w)</tt> behaves
--   the same as <tt>strutX w</tt>.
strutX :: (Metric v, R1 v, OrderedField n, Monoid' m) => n -> QDiagram b v n m

-- | <tt>strutY h</tt> is an empty diagram with height <tt>h</tt>, width 0,
--   and a centered local origin. Note that <tt>strutY (-h)</tt> behaves
--   the same as <tt>strutY h</tt>.
strutY :: (Metric v, R2 v, OrderedField n, Monoid' m) => n -> QDiagram b v n m

-- | <tt>padX s</tt> "pads" a diagram in the x-direction, expanding its
--   envelope horizontally by a factor of <tt>s</tt> (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 <a>centerX</a>) before
--   applying <tt>padX</tt>.
padX :: (Metric v, R2 v, OrderedField n, Monoid' m) => n -> QDiagram b v n m -> QDiagram b v n m

-- | <tt>padY s</tt> "pads" a diagram in the y-direction, expanding its
--   envelope vertically by a factor of <tt>s</tt> (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 <a>centerY</a>) before
--   applying <tt>padY</tt>.
padY :: (Metric v, R2 v, Monoid' m, OrderedField n) => n -> QDiagram b v n m -> QDiagram b v n m

-- | <tt>extrudeLeft s</tt> "extrudes" a diagram in the negative
--   x-direction, offsetting its envelope by the provided distance. When
--   <tt> s &lt; 0 </tt>, the envelope is inset instead.
--   
--   See the documentation for <a>extrudeEnvelope</a> for more information.
extrudeLeft :: (OrderedField n, Monoid' m) => n -> QDiagram b V2 n m -> QDiagram b V2 n m

-- | <tt>extrudeRight s</tt> "extrudes" a diagram in the positive
--   x-direction, offsetting its envelope by the provided distance. When
--   <tt> s &lt; 0 </tt>, the envelope is inset instead.
--   
--   See the documentation for <a>extrudeEnvelope</a> for more information.
extrudeRight :: (OrderedField n, Monoid' m) => n -> QDiagram b V2 n m -> QDiagram b V2 n m

-- | <tt>extrudeBottom s</tt> "extrudes" a diagram in the negative
--   y-direction, offsetting its envelope by the provided distance. When
--   <tt> s &lt; 0 </tt>, the envelope is inset instead.
--   
--   See the documentation for <a>extrudeEnvelope</a> for more information.
extrudeBottom :: (OrderedField n, Monoid' m) => n -> QDiagram b V2 n m -> QDiagram b V2 n m

-- | <tt>extrudeTop s</tt> "extrudes" a diagram in the positive
--   y-direction, offsetting its envelope by the provided distance. When
--   <tt> s &lt; 0 </tt>, the envelope is inset instead.
--   
--   See the documentation for <a>extrudeEnvelope</a> for more information.
extrudeTop :: (OrderedField n, Monoid' m) => n -> QDiagram b V2 n m -> QDiagram b V2 n m

-- | <tt>rectEnvelope p v</tt> sets the envelope of a diagram to a
--   rectangle whose lower-left corner is at <tt>p</tt> and whose
--   upper-right corner is at <tt>p .+^ v</tt>. 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 <a>bg</a> 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 <tt>image img # scaleUToX 1</tt>, where
--   <tt>img</tt> is a value of type <tt>DImage n e</tt>, created with a
--   function like <a>loadImageEmb</a>, <a>loadImageExt</a>, or
--   <a>raster</a>.
module Diagrams.TwoD.Image

-- | An image primitive, the two ints are width followed by height. Will
--   typically be created by <tt>loadImageEmb</tt> or <tt>loadImageExt</tt>
--   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

-- | <a>ImageData</a> is either a JuicyPixels <tt>DynamicImage</tt> tagged
--   as <a>Embedded</a> or a reference tagged as <a>External</a>.
--   Additionally <a>Native</a> 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 <a>DImage</a> into a <a>Diagram</a>.
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
--   <a>DImage</a>. 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 <a>Text</a> 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 <a>FontSize</a> attribute.
--   
--   This constructor should not be used directly. Use <a>text</a>,
--   <a>alignedText</a> or <a>baselineText</a>.
data Text n
Text :: (T2 n) -> (TextAlignment n) -> String -> Text n

-- | <tt>TextAlignment</tt> 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 <tt><a>alignedText</a> 0.5 0.5</tt>.
--   
--   Note that it <i>takes up no space</i>, 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
--   <tt><a>alignedText</a> 0 1</tt>.
--   
--   Note that it <i>takes up no space</i>.
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 <i>takes up no space</i>.
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 <i>takes up no space</i>.
baselineText :: (TypeableFloat n, Renderable (Text n) b) => String -> QDiagram b V2 n Any

-- | Make a text from a <a>TextAlignment</a>.
mkText :: (TypeableFloat n, Renderable (Text n) b) => TextAlignment n -> String -> QDiagram b V2 n Any

-- | The <tt>Font</tt> attribute specifies the name of a font family. Inner
--   <tt>Font</tt> attributes override outer ones.
newtype Font
Font :: (Last String) -> Font
_Font :: Iso' Font String

-- | Extract the font family name from a <tt>Font</tt> 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 <tt>FontSize</tt> attribute specifies the size of a font's
--   em-square. Inner <tt>FontSize</tt> attributes override outer ones.
newtype FontSize n
FontSize :: (Recommend (Last n)) -> FontSize n
_FontSize :: Iso' (FontSize n) (Recommend n)

-- | Extract the size from a <tt>FontSize</tt> attribute.
getFontSize :: FontSize n -> n

-- | Apply a <a>FontSize</a> 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
--   <tt>1</tt>.
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
--   <tt>commited</tt>.
_fontSize :: (Typeable n, OrderedField n) => Lens' (Style v n) (Measure n)
_fontSizeU :: (Typeable n, OrderedField n) => Lens' (Style v n) (Maybe n)

-- | The <tt>FontSlantA</tt> attribute specifies the slant (normal, italic,
--   or oblique) that should be used for all text within a diagram. Inner
--   <tt>FontSlantA</tt> attributes override outer ones.
data FontSlant
FontSlantNormal :: FontSlant
FontSlantItalic :: FontSlant
FontSlantOblique :: FontSlant

-- | Extract the font slant from a <tt>FontSlantA</tt> attribute.
getFontSlant :: FontSlant -> FontSlant

-- | Specify the slant (normal, italic, or oblique) that should be used for
--   all text within a diagram. See also <a>italic</a> and <a>oblique</a>
--   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 <tt>FontWeightA</tt> attribute specifies the weight (normal or
--   bold) that should be used for all text within a diagram. Inner
--   <tt>FontWeightA</tt> 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 <a>bold</a> 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, <i>etc.</i>
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):
--   
--   <ul>
--   <li><a>LineWidth</a>: 0.01</li>
--   <li><tt>LineTexture</tt>: solid black</li>
--   <li><a>LineCap</a>: LineCapButt</li>
--   <li><a>LineJoin</a>: miter</li>
--   <li><tt>MiterLimit</tt>: 10</li>
--   </ul>
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)

-- | <tt>adjustDia2D</tt> provides a useful default implementation of the
--   <a>adjustDia</a> method from the <a>Backend</a> 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:
--   
--   <ul>
--   <li>Set default attributes (see <a>setDefault2DAttributes</a>)</li>
--   <li>Scale and translate the diagram to fit within the requested size
--   (see <tt>adjustDiaSize2D</tt>)</li>
--   </ul>
--   
--   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
--   <a>http://projects.haskell.org/diagrams/doc/manual.html#offsets-of-segments-trails-and-paths</a>.
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 <a>offsetSegment</a>.
offsetEpsilon :: Lens' (OffsetOpts d) d

-- | Offset a <a>Trail</a> with the default options and a given radius. See
--   <a>offsetTrail'</a>.
offsetTrail :: RealFloat n => n -> Located (Trail V2 n) -> Located (Trail V2 n)

-- | Offset a <a>Trail</a> with options and by a given radius. This
--   generates a new trail that is always radius <tt>r</tt> away from the
--   given <a>Trail</a> (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 <a>offsetTrail'</a> 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 <a>Path</a> with the default options and given radius. See
--   <a>offsetPath'</a>.
offsetPath :: RealFloat n => n -> Path V2 n -> Path V2 n

-- | Offset a <a>Path</a> by applying <a>offsetTrail'</a> to each trail in
--   the path.
offsetPath' :: RealFloat n => OffsetOpts n -> n -> Path V2 n -> Path V2 n

-- | Options for specifying how a <a>Trail</a> 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 <a>offsetSegment</a>.
expandEpsilon :: Lens' (ExpandOpts d) d

-- | Expand a <a>Trail</a> with the given radius and default options. See
--   <a>expandTrail'</a>.
expandTrail :: RealFloat n => n -> Located (Trail V2 n) -> Path V2 n

-- | Expand a <a>Trail</a> with the given options and radius <tt>r</tt>
--   around a given <a>Trail</a>. Expanding can be thought of as generating
--   the loop that, when filled, represents stroking the trail with a
--   radius <tt>r</tt> brush.
--   
--   The cap styles applied to an outside corner can be seen here (with the
--   original trail in white and the result of <a>expandTrail'</a> 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 <a>Path</a> with the given radius and default options. See
--   <a>expandPath'</a>.
expandPath :: RealFloat n => n -> Path V2 n -> Path V2 n

-- | Expand a <a>Path</a> using <a>expandTrail'</a> 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:
--   
--   <ul>
--   <li><a>Diagrams.TwoD.Types</a> defines basic types for two-dimensional
--   diagrams, including types representing the 2D Euclidean vector space
--   and various systems of angle measurement.</li>
--   <li><a>Diagrams.TwoD.Align</a> defines alignment combinators
--   specialized to two dimensions (see <a>Diagrams.Align</a> for more
--   general alignment).</li>
--   <li><a>Diagrams.TwoD.Combinators</a> defines ways of combining
--   diagrams specialized to two dimensions (see also
--   <a>Diagrams.Combinators</a> for more general combining).</li>
--   <li><a>Diagrams.TwoD.Attributes</a> defines attributes specific to two
--   dimensions, *e.g.* fill color, line color, and gradients.</li>
--   <li><a>Diagrams.TwoD.Transform</a> defines R^2-specific
--   transformations such as rotation by an angle, and scaling,
--   translation, and reflection in the X and Y directions.</li>
--   <li><a>Diagrams.TwoD.Deform</a> defines some non-affine
--   transformations specific to two dimensions, *e.g.* parallel and
--   perspective projections.</li>
--   <li><a>Diagrams.TwoD.Ellipse</a> defines circles and ellipses.</li>
--   <li><a>Diagrams.TwoD.Arc</a> defines circular arcs.</li>
--   <li><a>Diagrams.TwoD.Path</a> exports various operations on
--   two-dimensional paths when viewed as regions of the plane.</li>
--   <li><a>Diagrams.TwoD.Polygons</a> defines general algorithms for
--   drawing various types of polygons.</li>
--   <li><a>Diagrams.TwoD.Shapes</a> defines other two-dimensional shapes,
--   e.g. various polygons.</li>
--   <li><a>Diagrams.TwoD.Arrow</a> contains tools for drawing arrows
--   between things, and <a>Diagrams.TwoD.Arrowheads</a> defines a
--   collection of arrowheads.</li>
--   <li><a>Diagrams.TwoD.Text</a> defines primitive text diagrams.</li>
--   <li><a>Diagrams.TwoD.Image</a> allows importing external images into
--   diagrams.</li>
--   <li><a>Diagrams.TwoD.Vector</a> defines some special 2D vectors and
--   functions for converting between vectors and angles.</li>
--   <li><a>Diagrams.TwoD.Size</a> defines functions for working with the
--   size of 2D objects.</li>
--   <li><a>Diagrams.TwoD.Model</a> defines some aids for visualizing
--   diagrams' internal model (local origins, envelopes, etc.)</li>
--   </ul>
module Diagrams.TwoD

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

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

-- | <pre>
--   &gt;&gt;&gt; V1 2 ^._x
--   2
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; V1 2 &amp; _x .~ 3
--   V1 3
--   </pre>
_x :: (R1 t, Functor f) => (a -> f a) -> t a -> f (t a)

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

-- | <pre>
--   &gt;&gt;&gt; V2 1 2 ^._y
--   2
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; V2 1 2 &amp; _y .~ 3
--   V2 1 3
--   </pre>
_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
--   <tt>&amp;</tt>.
r2 :: (n, n) -> V2 n

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

-- | Curried form of <a>r2</a>.
mkR2 :: n -> n -> V2 n

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

-- | Convert a 2D point back into a pair of coordinates. See also
--   <tt>coords</tt>.
unp2 :: P2 n -> (n, n)

-- | Curried form of <a>p2</a>.
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
--   
--   <pre>
--   &gt;&gt;&gt; perp $ V2 10 20
--   V2 (-20) 10
--   </pre>
perp :: Num a => V2 a -> V2 a

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

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

-- | A <a>Direction</a> 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
--   <i>radius</i>. Note that <tt>pi = tau/2</tt>.
--   
--   For more information and a well-reasoned argument why we should all be
--   using tau instead of pi, see <i>The Tau Manifesto</i>,
--   <a>http://tauday.com/</a>.
--   
--   To hear what it sounds like (and to easily memorize the first 30
--   digits or so), try <a>http://youtu.be/3174T-3-59Q</a>.
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
--   <a>xDir</a>.
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 <a>_r</a> 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 <a>ToPath</a> object into a diagram. The resulting diagram
--   has the names 0, 1, ... assigned to each of the path's vertices.
--   
--   See also <a>stroke'</a>, 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 <a>stroke</a> that takes an extra record of options to
--   customize its behaviour. In particular:
--   
--   <ul>
--   <li>Names can be assigned to the path's vertices</li>
--   </ul>
--   
--   <a>StrokeOpts</a> is an instance of <a>Default</a>, so <tt>stroke'
--   (<tt>with</tt> &amp; ... )</tt> 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

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

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

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

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

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

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

-- | A composition of <a>stroke'</a> and <a>pathFromTrail</a> 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 <a>strokeTrail'</a>.
strokeT' :: (TypeableFloat n, Renderable (Path V2 n) b, IsName a) => StrokeOpts a -> Trail V2 n -> QDiagram b V2 n Any

-- | A composition of <a>strokeT</a> and <a>wrapLine</a> 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 <a>strokeT</a> and <a>wrapLoop</a> 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 <tt>Located Trail</tt>
--   directly into a diagram; <tt>strokeLocTrail = stroke . trailLike</tt>.
strokeLocTrail :: (TypeableFloat n, Renderable (Path V2 n) b) => Located (Trail V2 n) -> QDiagram b V2 n Any

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

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

-- | A convenience function for converting a <tt>Located</tt> loop directly
--   into a diagram; <tt>strokeLocLoop = stroke . trailLike . mapLoc
--   wrapLoop</tt>.
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 <i>winding</i> <i>number</i>.
--   See <a>http://en.wikipedia.org/wiki/Nonzero-rule</a>.
Winding :: FillRule

-- | Interior points are those where a ray extended infinitely in a
--   particular direction crosses the path an odd number of times. See
--   <a>http://en.wikipedia.org/wiki/Even-odd_rule</a>.
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.
--   <tt>StrokeOpts</tt> is an instance of <a>Default</a>, so a
--   <tt>StrokeOpts</tt> records can be created using <tt><tt>with</tt> {
--   ... }</tt> 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 <i>list of lists</i> 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 <a>Winding</a>. NOTE: for now, this only affects the
--   resulting diagram's <a>Query</a>, <i>not</i> how it will be drawn! To
--   set the fill rule determining how it is to be drawn, use the
--   <a>fillRule</a> 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:
--   
--   <ul>
--   <li>Only the parts of the diagram which lie in the interior of the
--   path will be drawn.</li>
--   <li>The envelope of the diagram is unaffected.</li>
--   </ul>
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.
--   
--   
--   <pre>
--   hruleEx = vcat' (with &amp; sep .~ 0.2) (map hrule [1..5])
--           # centerXY # pad 1.1
--   </pre>
hrule :: (InSpace V2 n t, TrailLike t) => n -> t

-- | Create a centered vertical (T-B) line of the given length.
--   
--   
--   <pre>
--   vruleEx = hcat' (with &amp; sep .~ 0.2) (map vrule [1, 1.2 .. 2])
--           # centerXY # pad 1.1
--   </pre>
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

-- | <tt>ellipse e</tt> constructs an ellipse with eccentricity <tt>e</tt>
--   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

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

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

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

-- | Given a start direction <tt>s</tt> and end direction <tt>e</tt>,
--   <tt>arcCCW s e</tt> 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.
--   
--   
--   <pre>
--   wedgeEx = hcat' (with &amp; 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
--   </pre>
wedge :: (InSpace V2 n t, OrderedField n, TrailLike t) => n -> Direction V2 n -> Angle n -> t

-- | <tt>arcBetween p q height</tt> creates an arc beginning at <tt>p</tt>
--   and ending at <tt>q</tt>, with its midpoint at a distance of <tt>abs
--   height</tt> away from the straight line from <tt>p</tt> to <tt>q</tt>.
--   A positive value of <tt>height</tt> results in an arc to the left of
--   the line from <tt>p</tt> to <tt>q</tt>; a negative value yields one to
--   the right.
--   
--   
--   <pre>
--   arcBetweenEx = mconcat
--     [ arcBetween origin (p2 (2,1)) ht | ht &lt;- [-0.2, -0.1 .. 0.2] ]
--     # centerXY # pad 1.1
--   </pre>
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.
--   
--   
--   <pre>
--   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
--   </pre>
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 <a>PolygonOpts</a> 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.
--   
--   <ul>
--   <li>The first argument is a list of <i>central</i> <i>angles</i> from
--   each vertex to the next.</li>
--   <li>The second argument is a list of <i>radii</i> from the origin to
--   each successive vertex.</li>
--   </ul>
--   
--   To construct an <i>n</i>-gon, use a list of <i>n-1</i> angles and
--   <i>n</i> radii. Extra angles or radii are ignored.
--   
--   Cyclic polygons (with all vertices lying on a circle) can be
--   constructed using a second argument of <tt>(repeat r)</tt>.
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
--   <i>centroid</i> of its vertices.
--   
--   <ul>
--   <li>The first argument is a list of <i>vertex</i> <i>angles</i>,
--   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
--   <i>second</i> vertex; the first edge always starts out heading in the
--   positive y direction from the first vertex.</li>
--   <li>The second argument is a list of distances between successive
--   vertices.</li>
--   </ul>
--   
--   To construct an <i>n</i>-gon, use a list of <i>n-2</i> angles and
--   <i>n-1</i> 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 <i>horizontally</i>, so the bottommost edge is parallel to the
--   x-axis.
OrientH :: PolyOrientation n

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

-- | Orient so some edge is <i>facing</i> <i>in</i> <i>the</i>
--   <i>direction</i> <i>of</i>, 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 <i>n</i> means that edges will connect every
--   <i>n</i>th vertex.
StarSkip :: Int -> StarOpts

-- | Create a generalized <i>star</i> <i>polygon</i>. The <a>StarOpts</a>
--   are used to determine in which order the given vertices should be
--   connected. The intention is that the second argument of type
--   <tt>[Point v]</tt> could be generated by a call to <a>polygon</a>,
--   <tt>regPoly</tt>, or the like, since a list of vertices is
--   <a>TrailLike</a>. But of course the list can be generated any way you
--   like. A <tt><a>Path</a> <tt>v</tt></tt> is returned (instead of any
--   <a>TrailLike</a>) 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 <i>length</i> of the sides. (Compare to the
--   <a>polygon</a> function with a <a>PolyRegular</a> option, which
--   produces polygons of a given <i>radius</i>).
--   
--   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 <a>triangle</a>, 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 <a>heptagon</a>. It is, however, completely inferior,
--   being a base admixture of the Latin <i>septum</i> (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

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

-- | <tt>roundedRect w h r</tt> generates a closed trail, or closed path
--   centered at the origin, of an axis-aligned rectangle with width
--   <tt>w</tt>, height <tt>h</tt>, and circular rounded corners of radius
--   <tt>r</tt>. If <tt>r</tt> is negative the corner will be cut out in a
--   reverse arc. If the size of <tt>r</tt> is larger than half the smaller
--   dimension of <tt>w</tt> and <tt>h</tt>, 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
--   <a>roundedRect'</a> instead.
--   
--   
--   <pre>
--   roundedRectEx = pad 1.1 . centerXY $ hcat' (with &amp; sep .~ 0.2)
--     [ roundedRect  0.5 0.4 0.1
--     , roundedRect  0.5 0.4 (-0.1)
--     , roundedRect' 0.7 0.4 (with &amp; radiusTL .~ 0.2
--                                  &amp; radiusTR .~ -0.2
--                                  &amp; radiusBR .~ 0.1)
--     ]
--   </pre>
roundedRect :: (InSpace V2 n t, TrailLike t, RealFloat n) => n -> n -> n -> t

-- | <tt>roundedRect'</tt> works like <tt>roundedRect</tt> but allows you
--   to set the radius of each corner indivually, using
--   <tt>RoundedRectOpts</tt>. 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

-- | <tt>arrowV v</tt> creates an arrow with the direction and norm of the
--   vector <tt>v</tt> (with its tail at the origin), using default
--   parameters.
arrowV :: (TypeableFloat n, Renderable (Path V2 n) b) => V2 n -> QDiagram b V2 n Any

-- | <tt>arrowV' v</tt> creates an arrow with the direction and norm of the
--   vector <tt>v</tt> (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

-- | <tt>arrowBetween s e</tt> creates an arrow pointing from <tt>s</tt> to
--   <tt>e</tt> with default parameters.
arrowBetween :: (TypeableFloat n, Renderable (Path V2 n) b) => Point V2 n -> Point V2 n -> QDiagram b V2 n Any

-- | <tt>arrowBetween' opts s e</tt> creates an arrow pointing from
--   <tt>s</tt> to <tt>e</tt> using the given options. In particular, it
--   scales and rotates <tt>arrowShaft</tt> to go between <tt>s</tt> and
--   <tt>e</tt>, 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

-- | <tt>arrow len</tt> creates an arrow of length <tt>len</tt> with
--   default parameters, starting at the origin and ending at the point
--   <tt>(len,0)</tt>.
arrow :: (TypeableFloat n, Renderable (Path V2 n) b) => n -> QDiagram b V2 n Any

-- | <tt>arrow' opts len</tt> creates an arrow of length <tt>len</tt> using
--   the given options, starting at the origin and ending at the point
--   <tt>(len,0)</tt>. In particular, it scales the given <a>arrowShaft</a>
--   so that the entire arrow has length <tt>len</tt>.
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 <tt>headGap</tt> and <tt>tailGap</tt> 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 <tt>... (with &amp; headTexture .~ grad)</tt>
--   to get an arrow with a head filled with a gradient, assuming grad has
--   been defined. Or <tt>... (with &amp; headTexture .~ solid blue</tt> to
--   set the head color to blue. For more general control over the style of
--   arrowheads, see <a>headStyle</a>.
headTexture :: TypeableFloat n => Lens' (ArrowOpts n) (Texture n)

-- | Style to apply to the head. <tt>headStyle</tt> is modified by using
--   the lens combinator <tt>%~</tt> to change the current style. For
--   example, to change an opaque black arrowhead to translucent orange:
--   <tt>(with &amp; headStyle %~ fc orange . opacity 0.75)</tt>.
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 <a>committed</a>).
tailTexture :: TypeableFloat n => Lens' (ArrowOpts n) (Texture n)

-- | Style to apply to the tail. See <a>headStyle</a>.
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 <a>headStyle</a>.
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 <tt>headLength</tt> and <tt>tailLength</tt>
--   simultaneously.
lengths :: Traversal' (ArrowOpts n) (Measure n)

-- | Create a primitive text diagram from the given string, with center
--   alignment, equivalent to <tt><a>alignedText</a> 0.5 0.5</tt>.
--   
--   Note that it <i>takes up no space</i>, 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
--   <tt><a>alignedText</a> 0 1</tt>.
--   
--   Note that it <i>takes up no space</i>.
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 <i>takes up no space</i>.
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 <i>takes up no space</i>.
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
--   <tt>1</tt>.
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
--   <tt>commited</tt>.
_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 <tt>loadImageEmb</tt> or <tt>loadImageExt</tt>
--   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

-- | <a>ImageData</a> is either a JuicyPixels <tt>DynamicImage</tt> tagged
--   as <a>Embedded</a> or a reference tagged as <a>External</a>.
--   Additionally <a>Native</a> 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 <a>DImage</a> into a <a>Diagram</a>.
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
--   <a>DImage</a>. 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 <a>rotate</a>.
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 <a>Iso</a>s on <a>Angle</a>.
--   For example, <tt>rotate (1/4 @@ <a>turn</a>)</tt>, <tt>rotate (tau/4
--   @@ rad)</tt>, and <tt>rotate (90 @@ deg)</tt> all represent the same
--   transformation, namely, a counterclockwise rotation by a right angle.
--   To rotate about some point other than the local origin, see
--   <tt>rotateAbout</tt>.
--   
--   Note that writing <tt>rotate (1/4)</tt>, with no <a>Angle</a>
--   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
--   <a>rotateBy</a>, 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 <a>rotate</a>, interpreting its argument in units of
--   turns; it can be more convenient to write <tt>rotateBy (1/4)</tt> than
--   <tt><a>rotate</a> (1/4 @@ <a>turn</a>)</tt>.
rotateBy :: (InSpace V2 n t, Transformable t, Floating n) => n -> t -> t

-- | Use an <a>Angle</a> to make an <a>Iso</a> between an object rotated
--   and unrotated. This us useful for performing actions <a>under</a> a
--   rotation:
--   
--   <pre>
--   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)
--   </pre>
rotated :: (InSpace V2 n a, Floating n, SameSpace a b, Transformable a, Transformable b) => Angle n -> Iso a b a b

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

-- | <tt>rotateAbout p</tt> is like <a>rotate</a>, except it rotates around
--   the point <tt>p</tt> 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 <a>scale</a>.
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 <a>scale</a>.
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

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

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

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

-- | <tt>scaleUToY h</tt> scales a diagram <i>uniformly</i> by whatever
--   factor required to make its height <tt>h</tt>. <tt>scaleUToY</tt>
--   should not be applied to diagrams with a height of 0, such as
--   <tt>hrule</tt>.
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

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

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

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

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

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

-- | <tt>shearY d</tt> performs a shear in the y-direction which sends
--   <tt>(1,0)</tt> to <tt>(1,d)</tt>.
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. <tt>asDeformation (translation unitX) &lt;&gt;
--   parallelX0 &lt;&gt; frustrumX = perspectiveX1</tt>
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
--   
--   <pre>
--    c
--   ===
--    d
--   
--   </pre>
--   
--   to place <tt>c</tt> above <tt>d</tt>. The local origin of the
--   resulting combined diagram is the same as the local origin of the
--   first. <tt>(===)</tt> is associative and has <a>mempty</a> as an
--   identity. See the documentation of <a>beside</a> 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. <tt>(|||)</tt> is associative and
--   has <a>mempty</a> as an identity. See the documentation of
--   <a>beside</a> 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.
--   
--   <ul>
--   <li>For more control over the spacing, see <a>hcat'</a>.</li>
--   <li>To align the diagrams vertically (or otherwise), use alignment
--   combinators (such as <a>alignT</a> or <a>alignB</a>) from
--   <a>Diagrams.TwoD.Align</a> before applying <a>hcat</a>.</li>
--   <li>For non-axis-aligned layout, see <a>cat</a>.</li>
--   </ul>
hcat :: (InSpace V2 n a, Floating n, Juxtaposable a, HasOrigin a, Monoid' a) => [a] -> a

-- | A variant of <a>hcat</a> taking an extra <a>CatOpts</a> record to
--   control the spacing. See the <a>cat'</a> documentation for a
--   description of the possibilities. For the common case of setting just
--   a separation amount, see <a>hsep</a>.
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:
--   <tt>hsep s === hcat' (with &amp; sep .~ s)</tt>.
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.
--   
--   <ul>
--   <li>For more control over the spacing, see <a>vcat'</a>.</li>
--   <li>To align the diagrams horizontally (or otherwise), use alignment
--   combinators (such as <a>alignL</a> or <a>alignR</a>) from
--   <a>Diagrams.TwoD.Align</a> before applying <a>vcat</a>.</li>
--   <li>For non-axis-aligned layout, see <a>cat</a>.</li>
--   </ul>
vcat :: (InSpace V2 n a, Floating n, Juxtaposable a, HasOrigin a, Monoid' a) => [a] -> a

-- | A variant of <a>vcat</a> taking an extra <a>CatOpts</a> record to
--   control the spacing. See the <a>cat'</a> documentation for a
--   description of the possibilities. For the common case of setting just
--   a separation amount, see <a>vsep</a>.
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:
--   <tt>vsep s === vcat' (with &amp; sep .~ s)</tt>.
vsep :: (InSpace V2 n a, Floating n, Juxtaposable a, HasOrigin a, Monoid' a) => n -> [a] -> a

-- | <tt>strutX w</tt> is an empty diagram with width <tt>w</tt>, height 0,
--   and a centered local origin. Note that <tt>strutX (-w)</tt> behaves
--   the same as <tt>strutX w</tt>.
strutX :: (Metric v, R1 v, OrderedField n, Monoid' m) => n -> QDiagram b v n m

-- | <tt>strutY h</tt> is an empty diagram with height <tt>h</tt>, width 0,
--   and a centered local origin. Note that <tt>strutY (-h)</tt> behaves
--   the same as <tt>strutY h</tt>.
strutY :: (Metric v, R2 v, OrderedField n, Monoid' m) => n -> QDiagram b v n m

-- | <tt>padX s</tt> "pads" a diagram in the x-direction, expanding its
--   envelope horizontally by a factor of <tt>s</tt> (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 <a>centerX</a>) before
--   applying <tt>padX</tt>.
padX :: (Metric v, R2 v, OrderedField n, Monoid' m) => n -> QDiagram b v n m -> QDiagram b v n m

-- | <tt>padY s</tt> "pads" a diagram in the y-direction, expanding its
--   envelope vertically by a factor of <tt>s</tt> (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 <a>centerY</a>) before
--   applying <tt>padY</tt>.
padY :: (Metric v, R2 v, Monoid' m, OrderedField n) => n -> QDiagram b v n m -> QDiagram b v n m

-- | <tt>extrudeLeft s</tt> "extrudes" a diagram in the negative
--   x-direction, offsetting its envelope by the provided distance. When
--   <tt> s &lt; 0 </tt>, the envelope is inset instead.
--   
--   See the documentation for <a>extrudeEnvelope</a> for more information.
extrudeLeft :: (OrderedField n, Monoid' m) => n -> QDiagram b V2 n m -> QDiagram b V2 n m

-- | <tt>extrudeRight s</tt> "extrudes" a diagram in the positive
--   x-direction, offsetting its envelope by the provided distance. When
--   <tt> s &lt; 0 </tt>, the envelope is inset instead.
--   
--   See the documentation for <a>extrudeEnvelope</a> for more information.
extrudeRight :: (OrderedField n, Monoid' m) => n -> QDiagram b V2 n m -> QDiagram b V2 n m

-- | <tt>extrudeBottom s</tt> "extrudes" a diagram in the negative
--   y-direction, offsetting its envelope by the provided distance. When
--   <tt> s &lt; 0 </tt>, the envelope is inset instead.
--   
--   See the documentation for <a>extrudeEnvelope</a> for more information.
extrudeBottom :: (OrderedField n, Monoid' m) => n -> QDiagram b V2 n m -> QDiagram b V2 n m

-- | <tt>extrudeTop s</tt> "extrudes" a diagram in the positive
--   y-direction, offsetting its envelope by the provided distance. When
--   <tt> s &lt; 0 </tt>, the envelope is inset instead.
--   
--   See the documentation for <a>extrudeEnvelope</a> for more information.
extrudeTop :: (OrderedField n, Monoid' m) => n -> QDiagram b V2 n m -> QDiagram b V2 n m

-- | <tt>rectEnvelope p v</tt> sets the envelope of a diagram to a
--   rectangle whose lower-left corner is at <tt>p</tt> and whose
--   upper-right corner is at <tt>p .+^ v</tt>. 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 <a>bg</a> 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

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

-- | Like <a>alignX</a>, but moving the local origin vertically, with an
--   argument of <tt>1</tt> corresponding to the top edge and <tt>(-1)</tt>
--   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 <a>alignX</a>.
snugX :: (InSpace v n a, R1 v, Fractional n, Alignable a, Traced a, HasOrigin a) => n -> a -> a

-- | See the documentation for <a>alignY</a>.
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 <tt>diameter unitX</tt>.
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 <tt>(lo,hi)</tt>. Return <tt>Nothing</tt> for objects with an
--   empty envelope.
--   
--   Note this is just <tt>extent unitX</tt>.
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 <tt>(lo,hi)</tt>. Return <tt>Nothing</tt> for objects with an
--   empty envelope.
extentY :: (InSpace v n a, R2 v, Enveloped a) => a -> Maybe (n, n)

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

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

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

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

-- | A Texture is either a color <a>SC</a>, linear gradient <a>LG</a>, or
--   radial gradient <a>RG</a>. An object can have only one texture which
--   is determined by the <a>Last</a> 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 <a>SpreadMethod</a> determines what happens before
--   <a>lGradStart</a> and after <a>lGradEnd</a>. <a>GradPad</a> 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. <a>GradRepeat</a> restarts the gradient and
--   <a>GradReflect</a> 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 <i>not</i> a valid setter
--   because it doesn't abide the functor law (see <a>committed</a>).
_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
--   <a>local</a> 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
--   <a>local</a> 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, <tt>lg = defaultLG &amp; lGradStart .~
--   (0.25 ^&amp; 0.33)</tt>. Note that no default value is provided for
--   <tt>lGradStops</tt>, 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 <a>SpreadMethod</a>. The <a>lGradTrans</a> field is set to
--   the identity transfrom, to change it use the <a>lGradTrans</a> 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 <a>local</a> 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 <a>local</a> 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, <tt>rg = defaultRG &amp; rGradRadius1 .~
--   0.25</tt>. Note that no default value is provided for
--   <tt>rGradStops</tt>, 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 <a>SpreadMethod</a>. The <a>rGradTrans</a> field is set
--   to the identity transfrom, to change it use the <a>rGradTrans</a>
--   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 <a>Colour</a> or <a>AlphaColour</a>), but
--   this can sometimes create problems for type inference, so the
--   <a>fc</a> and <a>fcA</a> 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 <a>AlphaColour</a> <a>Double</a> of a <a>SC</a> texture.
_AC :: Prism' (Texture n) (AlphaColour Double)

-- | A synonym for <a>fillColor</a>, specialized to <tt><a>Colour</a>
--   Double</tt> (i.e. opaque colors). See comment after <a>fillColor</a>
--   about backends.
fc :: (InSpace V2 n a, Floating n, Typeable n, HasStyle a) => Colour Double -> a -> a

-- | A synonym for <a>fillColor</a>, specialized to <tt><a>AlphaColour</a>
--   Double</tt> (i.e. colors with transparency). See comment after
--   <a>fillColor</a> 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 <a>fillColor</a> (or <a>fc</a>, or <a>fcA</a>) are used. See
--   comment after <a>fillColor</a> 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 <a>Colour</a> or
--   <a>AlphaColour</a>), but this can sometimes create problems for type
--   inference, so the <a>lc</a> and <a>lcA</a> 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 <a>lineColor</a>, specialized to <tt><a>Colour</a>
--   Double</tt> (i.e. opaque colors). See comment in <a>lineColor</a>
--   about backends.
lc :: (InSpace V2 n a, Typeable n, Floating n, HasStyle a) => Colour Double -> a -> a

-- | A synonym for <a>lineColor</a>, specialized to <tt><a>AlphaColour</a>
--   Double</tt> (i.e. colors with transparency). See comment in
--   <a>lineColor</a> 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 <tt>diagrams-lib</tt> or
--   <tt>diagrams-core</tt>. This module can be used if you want to avoid
--   some potential conflicts with other modules, but importing
--   <a>Diagrams.Prelude</a> (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
--   
--   <ul>
--   <li>embed pure expressions (<a>pure</a>), and</li>
--   <li>sequence computations and combine their results
--   (<a>&lt;*&gt;</a>).</li>
--   </ul>
--   
--   A minimal complete definition must include implementations of these
--   functions satisfying the following laws:
--   
--   <ul>
--   <li><i><i>identity</i></i> <pre><a>pure</a> <a>id</a> <a>&lt;*&gt;</a>
--   v = v</pre></li>
--   <li><i><i>composition</i></i> <pre><a>pure</a> (.) <a>&lt;*&gt;</a> u
--   <a>&lt;*&gt;</a> v <a>&lt;*&gt;</a> w = u <a>&lt;*&gt;</a> (v
--   <a>&lt;*&gt;</a> w)</pre></li>
--   <li><i><i>homomorphism</i></i> <pre><a>pure</a> f <a>&lt;*&gt;</a>
--   <a>pure</a> x = <a>pure</a> (f x)</pre></li>
--   <li><i><i>interchange</i></i> <pre>u <a>&lt;*&gt;</a> <a>pure</a> y =
--   <a>pure</a> (<a>$</a> y) <a>&lt;*&gt;</a> u</pre></li>
--   </ul>
--   
--   The other methods have the following default definitions, which may be
--   overridden with equivalent specialized implementations:
--   
--   <ul>
--   <li><pre>u <a>*&gt;</a> v = <a>pure</a> (<a>const</a> <a>id</a>)
--   <a>&lt;*&gt;</a> u <a>&lt;*&gt;</a> v</pre></li>
--   <li><pre>u <a>&lt;*</a> v = <a>pure</a> <a>const</a> <a>&lt;*&gt;</a>
--   u <a>&lt;*&gt;</a> v</pre></li>
--   </ul>
--   
--   As a consequence of these laws, the <a>Functor</a> instance for
--   <tt>f</tt> will satisfy
--   
--   <ul>
--   <li><pre><a>fmap</a> f x = <a>pure</a> f <a>&lt;*&gt;</a> x</pre></li>
--   </ul>
--   
--   If <tt>f</tt> is also a <a>Monad</a>, it should satisfy
--   
--   <ul>
--   <li><pre><a>pure</a> = <a>return</a></pre></li>
--   <li><pre>(<a>&lt;*&gt;</a>) = <a>ap</a></pre></li>
--   </ul>
--   
--   (which implies that <a>pure</a> and <a>&lt;*&gt;</a> 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 <a>fmap</a>.
--   
--   <h4><b>Examples</b></h4>
--   
--   Convert from a <tt><tt>Maybe</tt> <tt>Int</tt></tt> to a
--   <tt><tt>Maybe</tt> <tt>String</tt></tt> using <tt>show</tt>:
--   
--   <pre>
--   &gt;&gt;&gt; show &lt;$&gt; Nothing
--   Nothing
--   
--   &gt;&gt;&gt; show &lt;$&gt; Just 3
--   Just "3"
--   </pre>
--   
--   Convert from an <tt><tt>Either</tt> <tt>Int</tt> <tt>Int</tt></tt> to
--   an <tt><tt>Either</tt> <tt>Int</tt></tt> <tt>String</tt> using
--   <tt>show</tt>:
--   
--   <pre>
--   &gt;&gt;&gt; show &lt;$&gt; Left 17
--   Left 17
--   
--   &gt;&gt;&gt; show &lt;$&gt; Right 17
--   Right "17"
--   </pre>
--   
--   Double each element of a list:
--   
--   <pre>
--   &gt;&gt;&gt; (*2) &lt;$&gt; [1,2,3]
--   [2,4,6]
--   </pre>
--   
--   Apply <tt>even</tt> to the second element of a pair:
--   
--   <pre>
--   &gt;&gt;&gt; even &lt;$&gt; (2,2)
--   (2,True)
--   </pre>
(<$>) :: Functor f => (a -> b) -> f a -> f b

-- | Replace all locations in the input with the same value. The default
--   definition is <tt><a>fmap</a> . <a>const</a></tt>, 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
--   <a>fmap</a> in a <a>Functor</a> 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
