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


-- | Collection of user contributions to diagrams EDSL
--   
--   A collection of user contributions for diagrams, an embedded
--   domain-specific language for generation of vector graphics.
@package diagrams-contrib
@version 1.4.3


-- | An <i>anchor</i> is a point on an object which can be used for
--   alignment by naming it, offering easier control over alignment
--   compared to the <a>Align</a> module when aligning many objects.
module Diagrams.Anchors
type Anchor = Name

-- | An <a>Anchored</a> object which can be aligned to anchor points before
--   concatenating with other <a>Anchored</a> objects. Note that when
--   concatenating, any anchors with the same names in each of the left and
--   right operands will be retained in the left operand, and lost in the
--   right. To avoid this, qualify anchors in each object using
--   '(&gt;&gt;/)'.
data Anchored t

-- | Attach a list of anchors to an object, making it <a>Anchored</a>.
withAnchors :: IsName anchor => [(anchor, V t (N t))] -> t -> Anchored t

-- | Turn an object into a trivial <a>Anchored</a> object with no anchors.
noAnchors :: t -> Anchored t

-- | Add another anchor to an already <a>Anchored</a> object.
addAnchor :: IsName anchor => anchor -> V t (N t) -> Anchored t -> Anchored t

-- | Delete an anchor from an anchored object. Does nothing if the object
--   does not have the specified anchor.
deleteAnchor :: IsName anchor => anchor -> Anchored t -> Anchored t

-- | Get the offset from the origin of a particular anchor, or <a>zero</a>
--   if the object does not have the specified anchor.
getAnchorOffset :: (Num (N t), Additive (V t), IsName a) => a -> Anchored t -> V t (N t)

-- | Align an anchored object to an anchor. Subsequently concatening with
--   '(&lt;&gt;)' will take this into account.
alignAnchor :: (IsName a) => a -> Anchored t -> Anchored t

-- | Does the given anchored object have the given anchor?
hasAnchor :: (IsName a) => a -> Anchored t -> Bool

-- | Throw away anchors and get the underlying object.
unanchor :: Anchored t -> t

-- | A convenient type of positional anchors.
data PositionalAnchor
AnchorL :: PositionalAnchor
AnchorTL :: PositionalAnchor
AnchorT :: PositionalAnchor
AnchorTR :: PositionalAnchor
AnchorR :: PositionalAnchor
AnchorBR :: PositionalAnchor
AnchorB :: PositionalAnchor
AnchorBL :: PositionalAnchor

-- | Given an <a>Anchored</a> object containing the given list of anchors,
--   rotate the order of the given anchors clockwise by the given number of
--   positions.
--   
--   For example, given a diagram with positional anchors on it in these
--   positions:
--   
--   <pre>
--   TL    T    TR
--   
--   L          R
--   
--   BL    B    BR
--   </pre>
--   
--   using <tt><a>rotatePosAnchors</a> 1 = <a>rotateAnchors</a> (enumFrom
--   AnchorL) 1</tt> will move the anchors to these positions:
--   
--   <pre>
--   L     TL   T
--   
--   BL         TR
--   
--   B     BR   R
--   </pre>
--   
--   Using a parameter <tt>n</tt> is equivalent to using <tt>1</tt>,
--   <tt>n</tt> times and a negative number produces an anticlockwise
--   rotation.
--   
--   If any of the anchors do not exist, this function skips them.
rotateAnchors :: (IsName anchor) => [anchor] -> Int -> Anchored t -> Anchored t

-- | As <a>rotateAnchors</a>, but specialised to the list of all
--   <a>PositionalAnchor</a>s.
rotatePosAnchors :: Int -> Anchored t -> Anchored t

-- | Starting from a base anchored object, recursively concatenate more
--   objects to the structure built up so far. Be sure to qualify anchors
--   in the input so that names aren't overwritten.
--   
--   In each <tt>(thatAnchor, thisAnchor, obj)</tt> triple,
--   <tt>thatAnchor</tt> refers to the anchor point in the structure
--   already constructed, and <tt>thisAnchor</tt> refers to the anchor
--   point in the new object being added.
anchorMany :: (Num (N t), Semigroup t, Additive (V t), HasOrigin t, IsName anchor) => Anchored t -> [(anchor, anchor, Anchored t)] -> Anchored t

-- | As <a>anchorMany</a>, but call <a>unanchor</a> on the result.
--   Convenient when you're not going to be doing any more alignment using
--   anchors with the result.
anchorMany_ :: (Num (N c), Semigroup c, Additive (V c), HasOrigin c, IsName anchor) => Anchored c -> [(anchor, anchor, Anchored c)] -> c

-- | Show a particular anchor in the <a>Anchored</a> object.
showAnchor :: (RealFloat n, Typeable n, Monoid m, Semigroup m, Renderable (Path V2 n) b, IsName a) => a -> Anchored (QDiagram b V2 n m) -> Anchored (QDiagram b V2 n m)

-- | Show a particular anchor in the <a>Anchored</a> object, then
--   <a>unanchor</a>.
showAnchor_ :: (RealFloat n, Typeable n, Monoid m, Semigroup m, Renderable (Path V2 n) b, IsName a) => a -> Anchored (QDiagram b V2 n m) -> QDiagram b V2 n m
instance GHC.Enum.Enum Diagrams.Anchors.PositionalAnchor
instance GHC.Show.Show Diagrams.Anchors.PositionalAnchor
instance GHC.Classes.Ord Diagrams.Anchors.PositionalAnchor
instance GHC.Classes.Eq Diagrams.Anchors.PositionalAnchor
instance Diagrams.Core.Names.IsName Diagrams.Anchors.PositionalAnchor
instance (Diagrams.Core.HasOrigin.HasOrigin t, Linear.Vector.Additive (Diagrams.Core.V.V t), GHC.Num.Num (Diagrams.Core.V.N t)) => Diagrams.Core.HasOrigin.HasOrigin (Diagrams.Anchors.Anchored t)
instance Diagrams.Core.Transform.Transformable t => Diagrams.Core.Transform.Transformable (Diagrams.Anchors.Anchored t)
instance (Linear.Vector.Additive (Diagrams.Core.V.V t), GHC.Num.Num (Diagrams.Core.V.N t), Diagrams.Core.HasOrigin.HasOrigin t, GHC.Base.Semigroup t) => GHC.Base.Semigroup (Diagrams.Anchors.Anchored t)
instance (Linear.Vector.Additive (Diagrams.Core.V.V t), GHC.Num.Num (Diagrams.Core.V.N t), Diagrams.Core.HasOrigin.HasOrigin t, Data.Monoid.WithSemigroup.Monoid' t) => GHC.Base.Monoid (Diagrams.Anchors.Anchored t)
instance (GHC.Show.Show (Diagrams.Core.V.V t (Diagrams.Core.V.N t)), GHC.Show.Show t) => GHC.Show.Show (Diagrams.Anchors.Anchored t)
instance Diagrams.Core.Names.Qualifiable t => Diagrams.Core.Names.Qualifiable (Diagrams.Anchors.Anchored t)


-- | Utilities for working with color in HSV space.
--   
--   Right now, the only utility is a function for blending colors in HSV
--   space. This has the effect of "travelling around the color wheel",
--   which can be especially nice when one wants to blend smoothly from one
--   color to another (blending in RGB space can tend to travel across some
--   icky brown/grey colors).
module Diagrams.Color.HSV

-- | Blend two colors in HSV space---that is, linearly interpolate between
--   their hues, saturations, and values independently (wrapping around
--   appropriately in the case of hue). In particular, <tt>hsvBlend a c1
--   c2</tt> is like doing <tt>(a-1)*c1 + a*c2</tt> in HSV space. That is,
--   a parameter of <tt>0</tt> results in only the first color; <tt>1</tt>
--   results in only the second color; and anything in between results in a
--   blend.
hsvBlend :: RealFloat n => n -> Colour n -> Colour n -> Colour n


-- | The 949 most common RGB monitor colors, as determined by the xkcd
--   color name survey. See <a>http://xkcd.com/color/rgb/</a> . Data taken
--   from <a>http://xkcd.com/color/rgb.txt</a> (License:
--   <a>http://creativecommons.org/publicdomain/zero/1.0/</a> .)
--   
--   This module defines many common color names that no standards
--   committee would ever countenance, including crude ones like
--   <a>poopGreen</a> and <a>puke</a>, as well as more acceptable but still
--   non-standards-worthy names like <a>windowsBlue</a> and
--   <a>toxicGreen</a>. It also contains several misspellings such as
--   <a>liliac</a> and <a>manilla</a>, though by definition this list
--   contains only very common misspellings.
--   
--   Names in the original list that use a forward slash (e.g.
--   "yellow/green") are represented here with an underscore, e.g.
--   <a>yellow_green</a> (note that <tt>yellow_green /= yellowGreen</tt>!).
--   
--   Note that the color name <a>tan</a> clashes with the Haskell Prelude.
--   Many other color names here clash with names from
--   <a>Data.Colour.Names</a> (taken from the X11 standard), which is
--   automatically re-exported from <a>Diagrams.Prelude</a>. It is
--   recommended to import this module qualified.
module Diagrams.Color.XKCD
cloudyBlue :: AlphaColour Double
darkPastelGreen :: AlphaColour Double
dust :: AlphaColour Double
electricLime :: AlphaColour Double
freshGreen :: AlphaColour Double
lightEggplant :: AlphaColour Double
nastyGreen :: AlphaColour Double
reallyLightBlue :: AlphaColour Double
tea :: AlphaColour Double
warmPurple :: AlphaColour Double
yellowishTan :: AlphaColour Double
cement :: AlphaColour Double
darkGrassGreen :: AlphaColour Double
dustyTeal :: AlphaColour Double
greyTeal :: AlphaColour Double
macaroniAndCheese :: AlphaColour Double
pinkishTan :: AlphaColour Double
spruce :: AlphaColour Double
strongBlue :: AlphaColour Double
toxicGreen :: AlphaColour Double
windowsBlue :: AlphaColour Double
blueBlue :: AlphaColour Double
blueWithAHintOfPurple :: AlphaColour Double
booger :: AlphaColour Double
brightSeaGreen :: AlphaColour Double
darkGreenBlue :: AlphaColour Double
deepTurquoise :: AlphaColour Double
greenTeal :: AlphaColour Double
strongPink :: AlphaColour Double
bland :: AlphaColour Double
deepAqua :: AlphaColour Double
lavenderPink :: AlphaColour Double
lightMossGreen :: AlphaColour Double
lightSeafoamGreen :: AlphaColour Double
oliveYellow :: AlphaColour Double
pigPink :: AlphaColour Double
deepLilac :: AlphaColour Double
desert :: AlphaColour Double
dustyLavender :: AlphaColour Double
purpleyGrey :: AlphaColour Double
purply :: AlphaColour Double
candyPink :: AlphaColour Double
lightPastelGreen :: AlphaColour Double
boringGreen :: AlphaColour Double
kiwiGreen :: AlphaColour Double
lightGreyGreen :: AlphaColour Double
orangePink :: AlphaColour Double
teaGreen :: AlphaColour Double
veryLightBrown :: AlphaColour Double
eggShell :: AlphaColour Double
eggplantPurple :: AlphaColour Double
powderPink :: AlphaColour Double
reddishGrey :: AlphaColour Double
babyShitBrown :: AlphaColour Double
liliac :: AlphaColour Double
stormyBlue :: AlphaColour Double
uglyBrown :: AlphaColour Double
custard :: AlphaColour Double
darkishPink :: AlphaColour Double
deepBrown :: AlphaColour Double
greenishBeige :: AlphaColour Double
manilla :: AlphaColour Double
offBlue :: AlphaColour Double
battleshipGrey :: AlphaColour Double
brownyGreen :: AlphaColour Double
bruise :: AlphaColour Double
kelleyGreen :: AlphaColour Double
sicklyYellow :: AlphaColour Double
sunnyYellow :: AlphaColour Double
azul :: AlphaColour Double
darkgreen :: AlphaColour Double
green_yellow :: AlphaColour Double
lichen :: AlphaColour Double
lightLightGreen :: AlphaColour Double
paleGold :: AlphaColour Double
sunYellow :: AlphaColour Double
tanGreen :: AlphaColour Double
burple :: AlphaColour Double
butterscotch :: AlphaColour Double
toupe :: AlphaColour Double
darkCream :: AlphaColour Double
indianRed :: AlphaColour Double
lightLavendar :: AlphaColour Double
poisonGreen :: AlphaColour Double
babyPukeGreen :: AlphaColour Double
brightYellowGreen :: AlphaColour Double
charcoalGrey :: AlphaColour Double
squash :: AlphaColour Double
cinnamon :: AlphaColour Double
lightPeaGreen :: AlphaColour Double
radioactiveGreen :: AlphaColour Double
rawSienna :: AlphaColour Double
babyPurple :: AlphaColour Double
cocoa :: AlphaColour Double
lightRoyalBlue :: AlphaColour Double
orangeish :: AlphaColour Double
rustBrown :: AlphaColour Double
sandBrown :: AlphaColour Double
swamp :: AlphaColour Double
tealishGreen :: AlphaColour Double
burntSiena :: AlphaColour Double
camo :: AlphaColour Double
duskBlue :: AlphaColour Double
fern :: AlphaColour Double
oldRose :: AlphaColour Double
paleLightGreen :: AlphaColour Double
peachyPink :: AlphaColour Double
rosyPink :: AlphaColour Double
lightBluishGreen :: AlphaColour Double
lightBrightGreen :: AlphaColour Double
lightNeonGreen :: AlphaColour Double
lightSeafoam :: AlphaColour Double
tiffanyBlue :: AlphaColour Double
washedOutGreen :: AlphaColour Double
brownyOrange :: AlphaColour Double
niceBlue :: AlphaColour Double
sapphire :: AlphaColour Double
greyishTeal :: AlphaColour Double
orangeyYellow :: AlphaColour Double
parchment :: AlphaColour Double
straw :: AlphaColour Double
veryDarkBrown :: AlphaColour Double
terracota :: AlphaColour Double
uglyBlue :: AlphaColour Double
clearBlue :: AlphaColour Double
creme :: AlphaColour Double
foamGreen :: AlphaColour Double
grey_green :: AlphaColour Double
lightGold :: AlphaColour Double
seafoamBlue :: AlphaColour Double
topaz :: AlphaColour Double
violetPink :: AlphaColour Double
wintergreen :: AlphaColour Double
yellowTan :: AlphaColour Double
darkFuchsia :: AlphaColour Double
indigoBlue :: AlphaColour Double
lightYellowishGreen :: AlphaColour Double
paleMagenta :: AlphaColour Double
richPurple :: AlphaColour Double
sunflowerYellow :: AlphaColour Double
green_blue :: AlphaColour Double
leather :: AlphaColour Double
racingGreen :: AlphaColour Double
vividPurple :: AlphaColour Double
darkRoyalBlue :: AlphaColour Double
hazel :: AlphaColour Double
mutedPink :: AlphaColour Double
boogerGreen :: AlphaColour Double
canary :: AlphaColour Double
coolGrey :: AlphaColour Double
darkTaupe :: AlphaColour Double
darkishPurple :: AlphaColour Double
trueGreen :: AlphaColour Double
coralPink :: AlphaColour Double
darkSage :: AlphaColour Double
darkSlateBlue :: AlphaColour Double
flatBlue :: AlphaColour Double
mushroom :: AlphaColour Double
richBlue :: AlphaColour Double
dirtyPurple :: AlphaColour Double
greenblue :: AlphaColour Double
ickyGreen :: AlphaColour Double
lightKhaki :: AlphaColour Double
warmBlue :: AlphaColour Double
darkHotPink :: AlphaColour Double
deepSeaBlue :: AlphaColour Double
carmine :: AlphaColour Double
darkYellowGreen :: AlphaColour Double
palePeach :: AlphaColour Double
plumPurple :: AlphaColour Double
goldenRod :: AlphaColour Double
neonRed :: AlphaColour Double
oldPink :: AlphaColour Double
veryPaleBlue :: AlphaColour Double
bloodOrange :: AlphaColour Double
grapefruit :: AlphaColour Double
sandYellow :: AlphaColour Double
clayBrown :: AlphaColour Double
darkBlueGrey :: AlphaColour Double
flatGreen :: AlphaColour Double
lightGreenBlue :: AlphaColour Double
warmPink :: AlphaColour Double
dodgerBlue :: AlphaColour Double
grossGreen :: AlphaColour Double
ice :: AlphaColour Double
metallicBlue :: AlphaColour Double
paleSalmon :: AlphaColour Double
sapGreen :: AlphaColour Double
algae :: AlphaColour Double
blueyGrey :: AlphaColour Double
greenyGrey :: AlphaColour Double
highlighterGreen :: AlphaColour Double
lightLightBlue :: AlphaColour Double
lightMint :: AlphaColour Double
rawUmber :: AlphaColour Double
vividBlue :: AlphaColour Double
deepLavender :: AlphaColour Double
dullTeal :: AlphaColour Double
lightGreenishBlue :: AlphaColour Double
mudGreen :: AlphaColour Double
pinky :: AlphaColour Double
redWine :: AlphaColour Double
shitGreen :: AlphaColour Double
tanBrown :: AlphaColour Double
darkblue :: AlphaColour Double
rosa :: AlphaColour Double
lipstick :: AlphaColour Double
paleMauve :: AlphaColour Double
claret :: AlphaColour Double
dandelion :: AlphaColour Double
orangered :: AlphaColour Double
poopGreen :: AlphaColour Double
ruby :: AlphaColour Double
dark :: AlphaColour Double
greenishTurquoise :: AlphaColour Double
pastelRed :: AlphaColour Double
pissYellow :: AlphaColour Double
brightCyan :: AlphaColour Double
darkCoral :: AlphaColour Double
algaeGreen :: AlphaColour Double
darkishRed :: AlphaColour Double
reddyBrown :: AlphaColour Double
blushPink :: AlphaColour Double
camouflageGreen :: AlphaColour Double
lawnGreen :: AlphaColour Double
putty :: AlphaColour Double
vibrantBlue :: AlphaColour Double
darkSand :: AlphaColour Double
purple_blue :: AlphaColour Double
saffron :: AlphaColour Double
twilight :: AlphaColour Double
warmBrown :: AlphaColour Double
bluegrey :: AlphaColour Double
bubbleGumPink :: AlphaColour Double
duckEggBlue :: AlphaColour Double
greenishCyan :: AlphaColour Double
petrol :: AlphaColour Double
royal :: AlphaColour Double
butter :: AlphaColour Double
dustyOrange :: AlphaColour Double
offYellow :: AlphaColour Double
paleOliveGreen :: AlphaColour Double
orangish :: AlphaColour Double
leaf :: AlphaColour Double
lightBlueGrey :: AlphaColour Double
driedBlood :: AlphaColour Double
lightishPurple :: AlphaColour Double
rustyRed :: AlphaColour Double
lavenderBlue :: AlphaColour Double
lightGrassGreen :: AlphaColour Double
lightMintGreen :: AlphaColour Double
sunflower :: AlphaColour Double
velvet :: AlphaColour Double
brickOrange :: AlphaColour Double
lightishRed :: AlphaColour Double
pureBlue :: AlphaColour Double
twilightBlue :: AlphaColour Double
violetRed :: AlphaColour Double
yellowyBrown :: AlphaColour Double
carnation :: AlphaColour Double
muddyYellow :: AlphaColour Double
darkSeafoamGreen :: AlphaColour Double
deepRose :: AlphaColour Double
dustyRed :: AlphaColour Double
grey_blue :: AlphaColour Double
lemonLime :: AlphaColour Double
purple_pink :: AlphaColour Double
brownYellow :: AlphaColour Double
purpleBrown :: AlphaColour Double
wisteria :: AlphaColour Double
bananaYellow :: AlphaColour Double
lipstickRed :: AlphaColour Double
waterBlue :: AlphaColour Double
brownGrey :: AlphaColour Double
vibrantPurple :: AlphaColour Double
babyGreen :: AlphaColour Double
barfGreen :: AlphaColour Double
eggshellBlue :: AlphaColour Double
sandyYellow :: AlphaColour Double
coolGreen :: AlphaColour Double
pale :: AlphaColour Double
blue_grey :: AlphaColour Double
hotMagenta :: AlphaColour Double
greyblue :: AlphaColour Double
purpley :: AlphaColour Double
babyShitGreen :: AlphaColour Double
brownishPink :: AlphaColour Double
darkAquamarine :: AlphaColour Double
diarrhea :: AlphaColour Double
lightMustard :: AlphaColour Double
paleSkyBlue :: AlphaColour Double
turtleGreen :: AlphaColour Double
brightOlive :: AlphaColour Double
darkGreyBlue :: AlphaColour Double
greenyBrown :: AlphaColour Double
lemonGreen :: AlphaColour Double
lightPeriwinkle :: AlphaColour Double
seaweedGreen :: AlphaColour Double
sunshineYellow :: AlphaColour Double
uglyPurple :: AlphaColour Double
mediumPink :: AlphaColour Double
pukeBrown :: AlphaColour Double
veryLightPink :: AlphaColour Double
viridian :: AlphaColour Double
bile :: AlphaColour Double
fadedYellow :: AlphaColour Double
veryPaleGreen :: AlphaColour Double
vibrantGreen :: AlphaColour Double
brightLime :: AlphaColour Double
spearmint :: AlphaColour Double
lightAquamarine :: AlphaColour Double
lightSage :: AlphaColour Double
yellowgreen :: AlphaColour Double
babyPoo :: AlphaColour Double
darkSeafoam :: AlphaColour Double
deepTeal :: AlphaColour Double
heather :: AlphaColour Double
rustOrange :: AlphaColour Double
dirtyBlue :: AlphaColour Double
fernGreen :: AlphaColour Double
brightLilac :: AlphaColour Double
weirdGreen :: AlphaColour Double
peacockBlue :: AlphaColour Double
avocadoGreen :: AlphaColour Double
fadedOrange :: AlphaColour Double
grapePurple :: AlphaColour Double
hotGreen :: AlphaColour Double
limeYellow :: AlphaColour Double
mango :: AlphaColour Double
shamrock :: AlphaColour Double
bubblegum :: AlphaColour Double
purplishBrown :: AlphaColour Double
vomitYellow :: AlphaColour Double
paleCyan :: AlphaColour Double
keyLime :: AlphaColour Double
tomatoRed :: AlphaColour Double
lightgreen :: AlphaColour Double
merlot :: AlphaColour Double
nightBlue :: AlphaColour Double
purpleishPink :: AlphaColour Double
apple :: AlphaColour Double
babyPoopGreen :: AlphaColour Double
greenApple :: AlphaColour Double
heliotrope :: AlphaColour Double
yellow_green :: AlphaColour Double
almostBlack :: AlphaColour Double
coolBlue :: AlphaColour Double
leafyGreen :: AlphaColour Double
mustardBrown :: AlphaColour Double
dusk :: AlphaColour Double
dullBrown :: AlphaColour Double
frogGreen :: AlphaColour Double
vividGreen :: AlphaColour Double
brightLightGreen :: AlphaColour Double
fluroGreen :: AlphaColour Double
kiwi :: AlphaColour Double
seaweed :: AlphaColour Double
navyGreen :: AlphaColour Double
ultramarineBlue :: AlphaColour Double
iris :: AlphaColour Double
pastelOrange :: AlphaColour Double
yellowishOrange :: AlphaColour Double
perrywinkle :: AlphaColour Double
tealish :: AlphaColour Double
darkPlum :: AlphaColour Double
pear :: AlphaColour Double
pinkishOrange :: AlphaColour Double
midnightPurple :: AlphaColour Double
lightUrple :: AlphaColour Double
darkMint :: AlphaColour Double
greenishTan :: AlphaColour Double
lightBurgundy :: AlphaColour Double
turquoiseBlue :: AlphaColour Double
uglyPink :: AlphaColour Double
sandy :: AlphaColour Double
electricPink :: AlphaColour Double
mutedPurple :: AlphaColour Double
midGreen :: AlphaColour Double
greyish :: AlphaColour Double
neonYellow :: AlphaColour Double
banana :: AlphaColour Double
carnationPink :: AlphaColour Double
tomato :: AlphaColour Double
sea :: AlphaColour Double
muddyBrown :: AlphaColour Double
turquoiseGreen :: AlphaColour Double
buff :: AlphaColour Double
fawn :: AlphaColour Double
mutedBlue :: AlphaColour Double
paleRose :: AlphaColour Double
darkMintGreen :: AlphaColour Double
amethyst :: AlphaColour Double
blue_green :: AlphaColour Double
chestnut :: AlphaColour Double
sickGreen :: AlphaColour Double
pea :: AlphaColour Double
rustyOrange :: AlphaColour Double
stone :: AlphaColour Double
roseRed :: AlphaColour Double
paleAqua :: AlphaColour Double
deepOrange :: AlphaColour Double
earth :: AlphaColour Double
mossyGreen :: AlphaColour Double
grassyGreen :: AlphaColour Double
paleLimeGreen :: AlphaColour Double
lightGreyBlue :: AlphaColour Double
paleGrey :: AlphaColour Double
asparagus :: AlphaColour Double
blueberry :: AlphaColour Double
purpleRed :: AlphaColour Double
paleLime :: AlphaColour Double
greenishTeal :: AlphaColour Double
caramel :: AlphaColour Double
deepMagenta :: AlphaColour Double
lightPeach :: AlphaColour Double
milkChocolate :: AlphaColour Double
ocher :: AlphaColour Double
offGreen :: AlphaColour Double
purplyPink :: AlphaColour Double
lightblue :: AlphaColour Double
duskyBlue :: AlphaColour Double
golden :: AlphaColour Double
lightBeige :: AlphaColour Double
butterYellow :: AlphaColour Double
duskyPurple :: AlphaColour Double
frenchBlue :: AlphaColour Double
uglyYellow :: AlphaColour Double
greenyYellow :: AlphaColour Double
orangishRed :: AlphaColour Double
shamrockGreen :: AlphaColour Double
orangishBrown :: AlphaColour Double
treeGreen :: AlphaColour Double
deepViolet :: AlphaColour Double
gunmetal :: AlphaColour Double
blue_purple :: AlphaColour Double
cherry :: AlphaColour Double
sandyBrown :: AlphaColour Double
warmGrey :: AlphaColour Double
darkIndigo :: AlphaColour Double
midnight :: AlphaColour Double
blueyGreen :: AlphaColour Double
greyPink :: AlphaColour Double
softPurple :: AlphaColour Double
blood :: AlphaColour Double
brownRed :: AlphaColour Double
mediumGrey :: AlphaColour Double
berry :: AlphaColour Double
poo :: AlphaColour Double
purpleyPink :: AlphaColour Double
lightSalmon :: AlphaColour Double
snot :: AlphaColour Double
easterPurple :: AlphaColour Double
lightYellowGreen :: AlphaColour Double
darkNavyBlue :: AlphaColour Double
drab :: AlphaColour Double
lightRose :: AlphaColour Double
rouge :: AlphaColour Double
purplishRed :: AlphaColour Double
slimeGreen :: AlphaColour Double
babyPoop :: AlphaColour Double
irishGreen :: AlphaColour Double
pink_purple :: AlphaColour Double
darkNavy :: AlphaColour Double
greenyBlue :: AlphaColour Double
lightPlum :: AlphaColour Double
pinkishGrey :: AlphaColour Double
dirtyOrange :: AlphaColour Double
rustRed :: AlphaColour Double
paleLilac :: AlphaColour Double
orangeyRed :: AlphaColour Double
primaryBlue :: AlphaColour Double
kermitGreen :: AlphaColour Double
brownishPurple :: AlphaColour Double
murkyGreen :: AlphaColour Double
wheat :: AlphaColour Double
veryDarkPurple :: AlphaColour Double
bottleGreen :: AlphaColour Double
watermelon :: AlphaColour Double
deepSkyBlue :: AlphaColour Double
fireEngineRed :: AlphaColour Double
yellowOchre :: AlphaColour Double
pumpkinOrange :: AlphaColour Double
paleOlive :: AlphaColour Double
lightLilac :: AlphaColour Double
lightishGreen :: AlphaColour Double
carolinaBlue :: AlphaColour Double
mulberry :: AlphaColour Double
shockingPink :: AlphaColour Double
auburn :: AlphaColour Double
brightLimeGreen :: AlphaColour Double
celadon :: AlphaColour Double
pinkishBrown :: AlphaColour Double
pooBrown :: AlphaColour Double
brightSkyBlue :: AlphaColour Double
celery :: AlphaColour Double
dirtBrown :: AlphaColour Double
strawberry :: AlphaColour Double
darkLime :: AlphaColour Double
copper :: AlphaColour Double
mediumBrown :: AlphaColour Double
mutedGreen :: AlphaColour Double
robin'sEgg :: AlphaColour Double
brightAqua :: AlphaColour Double
brightLavender :: AlphaColour Double
ivory :: AlphaColour Double
veryLightPurple :: AlphaColour Double
lightNavy :: AlphaColour Double
pinkRed :: AlphaColour Double
oliveBrown :: AlphaColour Double
poopBrown :: AlphaColour Double
mustardGreen :: AlphaColour Double
oceanGreen :: AlphaColour Double
veryDarkBlue :: AlphaColour Double
dustyGreen :: AlphaColour Double
lightNavyBlue :: AlphaColour Double
mintyGreen :: AlphaColour Double
adobe :: AlphaColour Double
barney :: AlphaColour Double
jadeGreen :: AlphaColour Double
brightLightBlue :: AlphaColour Double
lightLime :: AlphaColour Double
darkKhaki :: AlphaColour Double
orangeYellow :: AlphaColour Double
ocre :: AlphaColour Double
maize :: AlphaColour Double
fadedPink :: AlphaColour Double
britishRacingGreen :: AlphaColour Double
sandstone :: AlphaColour Double
mudBrown :: AlphaColour Double
lightSeaGreen :: AlphaColour Double
robinEggBlue :: AlphaColour Double
aquaMarine :: AlphaColour Double
darkSeaGreen :: AlphaColour Double
softPink :: AlphaColour Double
orangeyBrown :: AlphaColour Double
cherryRed :: AlphaColour Double
burntYellow :: AlphaColour Double
brownishGrey :: AlphaColour Double
camel :: AlphaColour Double
purplishGrey :: AlphaColour Double
marine :: AlphaColour Double
greyishPink :: AlphaColour Double
paleTurquoise :: AlphaColour Double
pastelYellow :: AlphaColour Double
blueyPurple :: AlphaColour Double
canaryYellow :: AlphaColour Double
fadedRed :: AlphaColour Double
sepia :: AlphaColour Double
coffee :: AlphaColour Double
brightMagenta :: AlphaColour Double
mocha :: AlphaColour Double
ecru :: AlphaColour Double
purpleish :: AlphaColour Double
cranberry :: AlphaColour Double
darkishGreen :: AlphaColour Double
brownOrange :: AlphaColour Double
duskyRose :: AlphaColour Double
melon :: AlphaColour Double
sicklyGreen :: AlphaColour Double
silver :: AlphaColour Double
purplyBlue :: AlphaColour Double
purpleishBlue :: AlphaColour Double
hospitalGreen :: AlphaColour Double
shitBrown :: AlphaColour Double
midBlue :: AlphaColour Double
amber :: AlphaColour Double
easterGreen :: AlphaColour Double
softBlue :: AlphaColour Double
ceruleanBlue :: AlphaColour Double
goldenBrown :: AlphaColour Double
brightTurquoise :: AlphaColour Double
redPink :: AlphaColour Double
redPurple :: AlphaColour Double
greyishBrown :: AlphaColour Double
vermillion :: AlphaColour Double
russet :: AlphaColour Double
steelGrey :: AlphaColour Double
lighterPurple :: AlphaColour Double
brightViolet :: AlphaColour Double
prussianBlue :: AlphaColour Double
slateGreen :: AlphaColour Double
dirtyPink :: AlphaColour Double
darkBlueGreen :: AlphaColour Double
pine :: AlphaColour Double
yellowyGreen :: AlphaColour Double
darkGold :: AlphaColour Double
bluish :: AlphaColour Double
darkishBlue :: AlphaColour Double
dullRed :: AlphaColour Double
pinkyRed :: AlphaColour Double
bronze :: AlphaColour Double
paleTeal :: AlphaColour Double
militaryGreen :: AlphaColour Double
barbiePink :: AlphaColour Double
bubblegumPink :: AlphaColour Double
peaSoupGreen :: AlphaColour Double
darkMustard :: AlphaColour Double
shit :: AlphaColour Double
mediumPurple :: AlphaColour Double
veryDarkGreen :: AlphaColour Double
dirt :: AlphaColour Double
duskyPink :: AlphaColour Double
redViolet :: AlphaColour Double
lemonYellow :: AlphaColour Double
pistachio :: AlphaColour Double
dullYellow :: AlphaColour Double
darkLimeGreen :: AlphaColour Double
denimBlue :: AlphaColour Double
tealBlue :: AlphaColour Double
lightishBlue :: AlphaColour Double
purpleyBlue :: AlphaColour Double
lightIndigo :: AlphaColour Double
swampGreen :: AlphaColour Double
brownGreen :: AlphaColour Double
darkMaroon :: AlphaColour Double
hotPurple :: AlphaColour Double
darkForestGreen :: AlphaColour Double
fadedBlue :: AlphaColour Double
drabGreen :: AlphaColour Double
lightLimeGreen :: AlphaColour Double
snotGreen :: AlphaColour Double
yellowish :: AlphaColour Double
lightBlueGreen :: AlphaColour Double
bordeaux :: AlphaColour Double
lightMauve :: AlphaColour Double
ocean :: AlphaColour Double
marigold :: AlphaColour Double
muddyGreen :: AlphaColour Double
dullOrange :: AlphaColour Double
steel :: AlphaColour Double
electricPurple :: AlphaColour Double
fluorescentGreen :: AlphaColour Double
yellowishBrown :: AlphaColour Double
blush :: AlphaColour Double
softGreen :: AlphaColour Double
brightOrange :: AlphaColour Double
lemon :: AlphaColour Double
purpleGrey :: AlphaColour Double
acidGreen :: AlphaColour Double
paleLavender :: AlphaColour Double
violetBlue :: AlphaColour Double
lightForestGreen :: AlphaColour Double
burntRed :: AlphaColour Double
khakiGreen :: AlphaColour Double
cerise :: AlphaColour Double
fadedPurple :: AlphaColour Double
apricot :: AlphaColour Double
darkOliveGreen :: AlphaColour Double
greyBrown :: AlphaColour Double
greenGrey :: AlphaColour Double
trueBlue :: AlphaColour Double
paleViolet :: AlphaColour Double
periwinkleBlue :: AlphaColour Double
lightSkyBlue :: AlphaColour Double
blurple :: AlphaColour Double
greenBrown :: AlphaColour Double
bluegreen :: AlphaColour Double
brightTeal :: AlphaColour Double
brownishYellow :: AlphaColour Double
peaSoup :: AlphaColour Double
forest :: AlphaColour Double
barneyPurple :: AlphaColour Double
ultramarine :: AlphaColour Double
purplish :: AlphaColour Double
pukeYellow :: AlphaColour Double
bluishGrey :: AlphaColour Double
darkPeriwinkle :: AlphaColour Double
darkLilac :: AlphaColour Double
reddish :: AlphaColour Double
lightMaroon :: AlphaColour Double
dustyPurple :: AlphaColour Double
terraCotta :: AlphaColour Double
avocado :: AlphaColour Double
marineBlue :: AlphaColour Double
tealGreen :: AlphaColour Double
slateGrey :: AlphaColour Double
lighterGreen :: AlphaColour Double
electricGreen :: AlphaColour Double
dustyBlue :: AlphaColour Double
goldenYellow :: AlphaColour Double
brightYellow :: AlphaColour Double
lightLavender :: AlphaColour Double
umber :: AlphaColour Double
poop :: AlphaColour Double
darkPeach :: AlphaColour Double
jungleGreen :: AlphaColour Double
eggshell :: AlphaColour Double
denim :: AlphaColour Double
yellowBrown :: AlphaColour Double
dullPurple :: AlphaColour Double
chocolateBrown :: AlphaColour Double
wineRed :: AlphaColour Double
neonBlue :: AlphaColour Double
dirtyGreen :: AlphaColour Double
lightTan :: AlphaColour Double
iceBlue :: AlphaColour Double
cadetBlue :: AlphaColour Double
darkMauve :: AlphaColour Double
veryLightBlue :: AlphaColour Double
greyPurple :: AlphaColour Double
pastelPink :: AlphaColour Double
veryLightGreen :: AlphaColour Double
darkSkyBlue :: AlphaColour Double
evergreen :: AlphaColour Double
dullPink :: AlphaColour Double
aubergine :: AlphaColour Double
mahogany :: AlphaColour Double
reddishOrange :: AlphaColour Double
deepGreen :: AlphaColour Double
vomitGreen :: AlphaColour Double
purplePink :: AlphaColour Double
dustyPink :: AlphaColour Double
fadedGreen :: AlphaColour Double
camoGreen :: AlphaColour Double
pinkyPurple :: AlphaColour Double
pinkPurple :: AlphaColour Double
brownishRed :: AlphaColour Double
darkRose :: AlphaColour Double
mud :: AlphaColour Double
brownish :: AlphaColour Double
emeraldGreen :: AlphaColour Double
paleBrown :: AlphaColour Double
dullBlue :: AlphaColour Double
burntUmber :: AlphaColour Double
mediumGreen :: AlphaColour Double
clay :: AlphaColour Double
lightAqua :: AlphaColour Double
lightOliveGreen :: AlphaColour Double
brownishOrange :: AlphaColour Double
darkAqua :: AlphaColour Double
purplishPink :: AlphaColour Double
darkSalmon :: AlphaColour Double
greenishGrey :: AlphaColour Double
jade :: AlphaColour Double
uglyGreen :: AlphaColour Double
darkBeige :: AlphaColour Double
emerald :: AlphaColour Double
paleRed :: AlphaColour Double
lightMagenta :: AlphaColour Double
sky :: AlphaColour Double
lightCyan :: AlphaColour Double
yellowOrange :: AlphaColour Double
reddishPurple :: AlphaColour Double
reddishPink :: AlphaColour Double
orchid :: AlphaColour Double
dirtyYellow :: AlphaColour Double
orangeRed :: AlphaColour Double
deepRed :: AlphaColour Double
orangeBrown :: AlphaColour Double
cobaltBlue :: AlphaColour Double
neonPink :: AlphaColour Double
rosePink :: AlphaColour Double
greyishPurple :: AlphaColour Double
raspberry :: AlphaColour Double
aquaGreen :: AlphaColour Double
salmonPink :: AlphaColour Double
tangerine :: AlphaColour Double
brownishGreen :: AlphaColour Double
redBrown :: AlphaColour Double
greenishBrown :: AlphaColour Double
pumpkin :: AlphaColour Double
pineGreen :: AlphaColour Double
charcoal :: AlphaColour Double
babyPink :: AlphaColour Double
cornflower :: AlphaColour Double
blueViolet :: AlphaColour Double
chocolate :: AlphaColour Double
greyishGreen :: AlphaColour Double
scarlet :: AlphaColour Double
greenYellow :: AlphaColour Double
darkOlive :: AlphaColour Double
sienna :: AlphaColour Double
pastelPurple :: AlphaColour Double
terracotta :: AlphaColour Double
aquaBlue :: AlphaColour Double
sageGreen :: AlphaColour Double
bloodRed :: AlphaColour Double
deepPink :: AlphaColour Double
grass :: AlphaColour Double
moss :: AlphaColour Double
pastelBlue :: AlphaColour Double
bluishGreen :: AlphaColour Double
greenBlue :: AlphaColour Double
darkTan :: AlphaColour Double
greenishBlue :: AlphaColour Double
paleOrange :: AlphaColour Double
vomit :: AlphaColour Double
forrestGreen :: AlphaColour Double
darkLavender :: AlphaColour Double
darkViolet :: AlphaColour Double
purpleBlue :: AlphaColour Double
darkCyan :: AlphaColour Double
oliveDrab :: AlphaColour Double
pinkish :: AlphaColour Double
cobalt :: AlphaColour Double
neonPurple :: AlphaColour Double
lightTurquoise :: AlphaColour Double
appleGreen :: AlphaColour Double
dullGreen :: AlphaColour Double
wine :: AlphaColour Double
powderBlue :: AlphaColour Double
offWhite :: AlphaColour Double
electricBlue :: AlphaColour Double
darkTurquoise :: AlphaColour Double
bluePurple :: AlphaColour Double
azure :: AlphaColour Double
brightRed :: AlphaColour Double
pinkishRed :: AlphaColour Double
cornflowerBlue :: AlphaColour Double
lightOlive :: AlphaColour Double
grape :: AlphaColour Double
greyishBlue :: AlphaColour Double
purplishBlue :: AlphaColour Double
yellowishGreen :: AlphaColour Double
greenishYellow :: AlphaColour Double
mediumBlue :: AlphaColour Double
dustyRose :: AlphaColour Double
lightViolet :: AlphaColour Double
midnightBlue :: AlphaColour Double
bluishPurple :: AlphaColour Double
redOrange :: AlphaColour Double
darkMagenta :: AlphaColour Double
greenish :: AlphaColour Double
oceanBlue :: AlphaColour Double
coral :: AlphaColour Double
cream :: AlphaColour Double
reddishBrown :: AlphaColour Double
burntSienna :: AlphaColour Double
brick :: AlphaColour Double
sage :: AlphaColour Double
greyGreen :: AlphaColour Double
white :: AlphaColour Double
robin'sEggBlue :: AlphaColour Double
mossGreen :: AlphaColour Double
steelBlue :: AlphaColour Double
eggplant :: AlphaColour Double
lightYellow :: AlphaColour Double
leafGreen :: AlphaColour Double
lightGrey :: AlphaColour Double
puke :: AlphaColour Double
pinkishPurple :: AlphaColour Double
seaBlue :: AlphaColour Double
palePurple :: AlphaColour Double
slateBlue :: AlphaColour Double
blueGrey :: AlphaColour Double
hunterGreen :: AlphaColour Double
fuchsia :: AlphaColour Double
crimson :: AlphaColour Double
paleYellow :: AlphaColour Double
ochre :: AlphaColour Double
mustardYellow :: AlphaColour Double
lightRed :: AlphaColour Double
cerulean :: AlphaColour Double
palePink :: AlphaColour Double
deepBlue :: AlphaColour Double
rust :: AlphaColour Double
lightTeal :: AlphaColour Double
slate :: AlphaColour Double
goldenrod :: AlphaColour Double
darkYellow :: AlphaColour Double
darkGrey :: AlphaColour Double
armyGreen :: AlphaColour Double
greyBlue :: AlphaColour Double
seafoam :: AlphaColour Double
puce :: AlphaColour Double
springGreen :: AlphaColour Double
darkOrange :: AlphaColour Double
sand :: AlphaColour Double
pastelGreen :: AlphaColour Double
mint :: AlphaColour Double
lightOrange :: AlphaColour Double
brightPink :: AlphaColour Double
chartreuse :: AlphaColour Double
deepPurple :: AlphaColour Double
darkBrown :: AlphaColour Double
taupe :: AlphaColour Double
peaGreen :: AlphaColour Double
pukeGreen :: AlphaColour Double
kellyGreen :: AlphaColour Double
seafoamGreen :: AlphaColour Double
blueGreen :: AlphaColour Double
khaki :: AlphaColour Double
burgundy :: AlphaColour Double
darkTeal :: AlphaColour Double
brickRed :: AlphaColour Double
royalPurple :: AlphaColour Double
plum :: AlphaColour Double
mintGreen :: AlphaColour Double
gold :: AlphaColour Double
babyBlue :: AlphaColour Double
yellowGreen :: AlphaColour Double
brightPurple :: AlphaColour Double
darkRed :: AlphaColour Double
paleBlue :: AlphaColour Double
grassGreen :: AlphaColour Double
navy :: AlphaColour Double
aquamarine :: AlphaColour Double
burntOrange :: AlphaColour Double
neonGreen :: AlphaColour Double
brightBlue :: AlphaColour Double
rose :: AlphaColour Double
lightPink :: AlphaColour Double
mustard :: AlphaColour Double
indigo :: AlphaColour Double
lime :: AlphaColour Double
seaGreen :: AlphaColour Double
periwinkle :: AlphaColour Double
darkPink :: AlphaColour Double
oliveGreen :: AlphaColour Double
peach :: AlphaColour Double
paleGreen :: AlphaColour Double
lightBrown :: AlphaColour Double
hotPink :: AlphaColour Double
black :: AlphaColour Double
lilac :: AlphaColour Double
navyBlue :: AlphaColour Double
royalBlue :: AlphaColour Double
beige :: AlphaColour Double
salmon :: AlphaColour Double
olive :: AlphaColour Double
maroon :: AlphaColour Double
brightGreen :: AlphaColour Double
darkPurple :: AlphaColour Double
mauve :: AlphaColour Double
forestGreen :: AlphaColour Double
aqua :: AlphaColour Double
cyan :: AlphaColour Double
tan :: AlphaColour Double
darkBlue :: AlphaColour Double
lavender :: AlphaColour Double
turquoise :: AlphaColour Double
darkGreen :: AlphaColour Double
violet :: AlphaColour Double
lightPurple :: AlphaColour Double
limeGreen :: AlphaColour Double
grey :: AlphaColour Double
skyBlue :: AlphaColour Double
yellow :: AlphaColour Double
magenta :: AlphaColour Double
lightGreen :: AlphaColour Double
orange :: AlphaColour Double
teal :: AlphaColour Double
lightBlue :: AlphaColour Double
red :: AlphaColour Double
brown :: AlphaColour Double
pink :: AlphaColour Double
blue :: AlphaColour Double
green :: AlphaColour Double
purple :: AlphaColour Double
xkcdColorMap :: Map String (AlphaColour Double)


-- | An algorithm for filling space in a fashion akin to word-wrapping.
module Diagrams.Layout.Wrap

-- | <tt>wrapDiagram</tt> post-processes the results of
--   <tt>wrapOutside</tt> / <tt>wrapInside</tt> into a Diagram of the
--   result. This only works when applying them to a list of diagrams.
wrapDiagram :: (Metric v, OrderedField n) => ([(v n, QDiagram b v n Any)], [QDiagram b v n Any]) -> QDiagram b v n Any

-- | <tt>wrapOutside</tt> is the same as <tt>wrapInside</tt>, but with an
--   inverted predicate.
wrapOutside :: (Enveloped a, V a ~ v, N a ~ n, Epsilon n) => (Point v n -> Bool) -> [v n] -> Point v n -> [a] -> ([(v n, a)], [a])

-- | <tt>wrapInside</tt> greedily wraps content to fill a space defined by
--   a predicate. It is passed a list of vectors which express the order of
--   dimensions to be filled. In other words, wrapping RTL text is done by
--   passing in [unitX, unitY], to first exhaust space horizontally, and
--   then vertically.
--   
--   Note that this function does not guarantee that there are not points
--   inside each positioned item for which the predicate is False. Instead,
--   only the corners of the bounds, along each axii, are used.
wrapInside :: forall a v n. (Enveloped a, V a ~ v, N a ~ n, Metric v, OrderedField n, Epsilon n) => (Point v n -> Bool) -> [v n] -> Point v n -> [a] -> ([(v n, a)], [a])


-- | This module provides utilities for using <a>Control.Lens</a> with
--   diagrams.
module Diagrams.Lens

-- | A traversal that either has 0 (empty box) or 2 points. These points
--   are the lower and upper corners, respectively.
_corners :: (Additive v', Foldable v', Ord n') => Traversal (BoundingBox v n) (BoundingBox v' n') (Point v n) (Point v' n')

-- | Gets or set the <a>location</a> of a <a>Subdiagram</a>.
_location :: (HasLinearMap v, Metric v, OrderedField n) => Lens' (Subdiagram b v n m) (Point v n)
_Loc :: Iso (Located a) (Located a') (Point (V a) (N a), a) (Point (V a') (N a'), a')
_mkFixedSeg :: (Additive v, Additive v', Num n, Num n') => Iso (Located (Segment Closed v n)) (Located (Segment Closed v' n')) (FixedSegment v n) (FixedSegment v' n')

-- | Prism that constructs linear segments. Can also destruct them, if the
--   segment is Linear.
_straight :: Prism' (Segment Closed v n) (v n)

-- | Prism that constructs cubic bezier segments. Can also destruct them,
--   if segment is a <a>Cubic</a>.
_bezier3 :: Prism' (Segment Closed v n) (v n, v n, v n)
_lineSegments :: (Metric v', OrderedField n') => Iso (Trail' Line v n) (Trail' Line v' n') [Segment Closed v n] [Segment Closed v' n']


-- | Generation of Apollonian gaskets. Any three mutually tangent circles
--   uniquely determine exactly two others which are mutually tangent to
--   all three. This process can be repeated, generating a fractal circle
--   packing.
--   
--   See J. Lagarias, C. Mallows, and A. Wilks, "Beyond the Descartes
--   circle theorem", <i>Amer. Math. Monthly</i> 109 (2002), 338--361.
--   <a>http://arxiv.org/abs/math/0101066</a>.
--   
--   A few examples:
--   
--   <pre>
--   import Diagrams.TwoD.Apollonian
--   apollonian1 = apollonianGasket 0.01 2 2 2
--   </pre>
--   
--   
--   <pre>
--   import Diagrams.TwoD.Apollonian
--   apollonian2 = apollonianGasket 0.01 2 3 3
--   </pre>
--   
--   
--   <pre>
--   import Diagrams.TwoD.Apollonian
--   apollonian3 = apollonianGasket 0.01 2 4 7
--   </pre>
--   
module Diagrams.TwoD.Apollonian

-- | Representation for circles that lets us quickly compute an Apollonian
--   gasket.
data Circle n
Circle :: n -> Complex n -> Circle n

-- | The bend is the reciprocal of signed radius: a negative radius means
--   the outside and inside of the circle are switched. The bends of any
--   four mutually tangent circles satisfy Descartes' Theorem.
[bend] :: Circle n -> n

-- | <i>Product</i> of bend and center represented as a complex number.
--   Amazingly, these products also satisfy the equation of Descartes'
--   Theorem.
[cb] :: Circle n -> Complex n

-- | Create a <tt>Circle</tt> given a signed radius and a location for its
--   center.
mkCircle :: Fractional n => n -> P2 n -> Circle n

-- | Get the center of a circle.
center :: Fractional n => Circle n -> P2 n

-- | Get the (unsigned) radius of a circle.
radius :: Fractional n => Circle n -> n

-- | Descartes' Theorem states that if <tt>b1</tt>, <tt>b2</tt>,
--   <tt>b3</tt> and <tt>b4</tt> are the bends of four mutually tangent
--   circles, then
--   
--   <pre>
--   b1^2 + b2^2 + b3^2 + b4^2 = 1/2 * (b1 + b2 + b3 + b4)^2.
--   
--   </pre>
--   
--   Surprisingly, if we replace each of the <tt>bi</tt> with the
--   <i>product</i> of <tt>bi</tt> and the center of the corresponding
--   circle (represented as a complex number), the equation continues to
--   hold! (See the paper referenced at the top of the module.)
--   
--   <tt>descartes [b1,b2,b3]</tt> solves for <tt>b4</tt>, returning both
--   solutions. Notably, <tt>descartes</tt> works for any instance of
--   <tt>Floating</tt>, which includes both <tt>Double</tt> (for bends),
--   <tt>Complex Double</tt> (for bend/center product), and <tt>Circle</tt>
--   (for both at once).
descartes :: Floating n => [n] -> [n]

-- | If we have <i>four</i> mutually tangent circles we can choose one of
--   them to replace; the remaining three determine exactly one other
--   circle which is mutually tangent. However, in this situation there is
--   no need to apply <a>descartes</a> again, since the two solutions
--   <tt>b4</tt> and <tt>b4'</tt> satisfy
--   
--   <pre>
--   b4 + b4' = 2 * (b1 + b2 + b3)
--   
--   </pre>
--   
--   Hence, to replace <tt>b4</tt> with its dual, we need only sum the
--   other three, multiply by two, and subtract <tt>b4</tt>. Again, this
--   works for bends as well as bend/center products.
other :: Num n => [n] -> n -> n

-- | Generate an initial configuration of four mutually tangent circles,
--   given just the signed bends of three of them.
initialConfig :: RealFloat n => n -> n -> n -> [Circle n]

-- | Given a threshold radius and a list of <i>four</i> mutually tangent
--   circles, generate the Apollonian gasket containing those circles. Stop
--   the recursion when encountering a circle with an (unsigned) radius
--   smaller than the threshold.
apollonian :: RealFloat n => n -> [Circle n] -> [Circle n]

-- | The basic idea of a kissing set is supposed to represent a set of four
--   mutually tangent circles with one selected, though in fact it is more
--   general than that: it represents any set of objects with one
--   distinguished object selected.
data KissingSet n
KS :: n -> [n] -> KissingSet n
[selected] :: KissingSet n -> n
[others] :: KissingSet n -> [n]

-- | Generate all possible kissing sets from a set of objects by selecting
--   each object in turn.
kissingSets :: [n] -> [KissingSet n]

-- | "Flip" the selected circle to the <a>other</a> circle mutually tangent
--   to the other three. The new circle remains selected.
flipSelected :: Num n => KissingSet n -> KissingSet n

-- | Make the selected circle unselected, and select each of the others,
--   generating a new kissing set for each.
selectOthers :: KissingSet n -> [KissingSet n]

-- | Given a set of <i>four</i> mutually tangent circles, generate the
--   infinite Apollonian tree rooted at the given set, represented as a
--   list of four subtrees. Each node in the tree is a kissing set with one
--   circle selected which has just been flipped. The three children of a
--   node represent the kissing sets obtained by selecting each of the
--   other three circles and flipping them. The initial roots of the four
--   trees are chosen by selecting and flipping each of the circles in the
--   starting set. This representation has the property that each circle in
--   the Apollonian gasket is the selected circle in exactly one node
--   (except that the initial four circles never appear as the selected
--   circle in any node).
apollonianTrees :: RealFloat n => [Circle n] -> [Tree (KissingSet (Circle n))]

-- | Generate a single Apollonian tree from a root kissing set. See the
--   documentation for <a>apollonianTrees</a> for an explanation.
apollonianTree :: RealFloat n => KissingSet (Circle n) -> Tree (KissingSet (Circle n))

-- | Draw a circle.
drawCircle :: (Renderable (Path V2 n) b, TypeableFloat n) => Circle n -> QDiagram b V2 n Any

-- | Draw a generated gasket, using a line width 0.003 times the radius of
--   the largest circle.
drawGasket :: (Renderable (Path V2 n) b, TypeableFloat n) => [Circle n] -> QDiagram b V2 n Any

-- | Draw an Apollonian gasket: the first argument is the threshold; the
--   recursion will stop upon reaching circles with radii less than it. The
--   next three arguments are bends of three circles.
apollonianGasket :: (Renderable (Path V2 n) b, TypeableFloat n) => n -> n -> n -> n -> QDiagram b V2 n Any
instance GHC.Show.Show n => GHC.Show.Show (Diagrams.TwoD.Apollonian.KissingSet n)
instance GHC.Show.Show n => GHC.Show.Show (Diagrams.TwoD.Apollonian.Circle n)
instance GHC.Classes.Eq n => GHC.Classes.Eq (Diagrams.TwoD.Apollonian.Circle n)
instance GHC.Float.RealFloat n => GHC.Num.Num (Diagrams.TwoD.Apollonian.Circle n)
instance GHC.Float.RealFloat n => GHC.Real.Fractional (Diagrams.TwoD.Apollonian.Circle n)
instance GHC.Float.RealFloat n => GHC.Float.Floating (Diagrams.TwoD.Apollonian.Circle n)


-- | Factorization diagrams, as seen at
--   <a>http://mathlesstraveled.com/2012/10/05/factorization-diagrams/</a>
--   and
--   <a>http://mathlesstraveled.com/2012/11/05/more-factorization-diagrams/</a>
--   and on the cover of Hacker Monthly
--   (<a>http://hackermonthly.com/issue-31.html</a>): visually represent
--   the prime factorization of n by drawing n dots recursively grouped
--   according to the factors.
--   
module Diagrams.TwoD.Factorization

-- | <tt>primeLayout</tt> takes a positive integer p (the idea is for it to
--   be prime, though it doesn't really matter) and a diagram, and lays out
--   p rotated copies of the diagram in a circular pattern.
--   
--   There is a special case for <tt>p = 2</tt>: if the given diagram is
--   taller than it is wide, then the two copies will be placed beside each
--   other; if wider then tall, they will be placed one above the other.
--   
--   The regular <tt>p</tt>-gon connecting the centers of the laid-out
--   diagrams is also filled in with vertical bars of color representing
--   the number <tt>p</tt>. In particular, there is one color for each
--   decimal digit (the provided list should have length 10 and represents
--   the digits 0-9), and the colors, read left to right, give the decimal
--   expansion of <tt>p</tt>.
--   
--   <pre>
--   import Diagrams.TwoD.Factorization
--   plExample
--     = pad 1.1 . centerXY
--     . hsep 0.5
--     . map (sized (mkWidth 1))
--     $ [ primeLayout defaultColors 5 (circle 1 # fc black)
--       , primeLayout defaultColors 103 (square 1 # fc green # lw none)
--       , primeLayout (repeat white) 13 (circle 1 # lc orange)
--       ]
--   </pre>
--   
primeLayout :: (Renderable (Path V2 n) b, TypeableFloat n) => [Colour Double] -> Integer -> QDiagram b V2 n Any -> QDiagram b V2 n Any

-- | Draw vertical bars of color inside a polygon which represent the
--   decimal expansion of <tt>p</tt>, using the provided list of colors to
--   represent the digits 0-9.
--   
--   <pre>
--   import Diagrams.TwoD.Factorization
--   colorBarsEx = colorBars defaultColors 3526 (square 1)
--   </pre>
--   
colorBars :: (Renderable (Path V2 n) b, TypeableFloat n) => [Colour Double] -> Integer -> Path V2 n -> QDiagram b V2 n Any

-- | A default set of digit colors, based very loosely on the color code
--   for resistors
--   (<a>http://en.wikipedia.org/wiki/Electronic_color_code</a>), lightened
--   up a bit by blending with white.
--   
defaultColors :: [Colour Double]

-- | Create a centered factorization diagram from the given list of factors
--   (intended to be primes, but again, any positive integers will do; note
--   how the below example uses 6), by recursively folding according to
--   <a>primeLayout</a>, with the <a>defaultColors</a> and a base case of a
--   black circle.
--   
--   <pre>
--   import Diagrams.TwoD.Factorization
--   factorDiagram'Ex = factorDiagram' [2,5,6]
--   </pre>
--   
factorDiagram' :: (Renderable (Path V2 n) b, TypeableFloat n) => [Integer] -> QDiagram b V2 n Any

-- | Create a default factorization diagram for the given integer, by
--   factoring it and calling <a>factorDiagram'</a> on its prime
--   factorization (with the factors ordered from smallest to biggest).
--   
--   <pre>
--   import Diagrams.TwoD.Factorization
--   factorDiagramEx = factorDiagram 700
--   </pre>
--   
factorDiagram :: (Renderable (Path V2 n) b, TypeableFloat n) => Integer -> QDiagram b V2 n Any
factors :: Integer -> [Integer]

-- | Place a diagram inside a square with the given side length, centering
--   and scaling it to fit with a bit of padding.
--   
--   <pre>
--   import Diagrams.TwoD.Factorization
--   ensquareEx = ensquare 1 (circle 25) ||| ensquare 1 (factorDiagram 30)
--   </pre>
--   
ensquare :: (Renderable (Path V2 n) b, TypeableFloat n) => n -> QDiagram b V2 n Any -> QDiagram b V2 n Any

-- | <tt>fdGrid n</tt> creates a grid of factorization diagrams, given a
--   list of lists of integers: the inner lists represent L-R rows, which
--   are laid out from top to bottom.
--   
--   <pre>
--   import Diagrams.TwoD.Factorization
--   fdGridEx = fdGrid [[7,6,5],[4,19,200],[1,10,50]]
--   </pre>
--   
fdGrid :: (Renderable (Path V2 n) b, TypeableFloat n) => [[Integer]] -> QDiagram b V2 n Any

-- | <tt>fdGridList n</tt> creates a grid containing the factorization
--   diagrams of all the numbers from <tt>1</tt> to <tt>n^2</tt>, ordered
--   left to right, top to bottom (like the grid seen on the cover of
--   Hacker Monthly, <a>http://hackermonthly.com/issue-31.html</a>).
--   
--   <pre>
--   import Diagrams.TwoD.Factorization
--   grid100 = fdGridList 10
--   grid100Big = grid100
--   </pre>
--   
fdGridList :: (Renderable (Path V2 n) b, TypeableFloat n) => Integer -> QDiagram b V2 n Any

-- | <tt>fdTable n</tt> creates a "multiplication table" of factorization
--   diagrams, with the diagrams for <tt>1</tt> to <tt>n</tt> along both
--   the top row and left column, and the diagram for <tt>m*n</tt> in row
--   <tt>m</tt> and column <tt>n</tt>.
--   
--   <pre>
--   import Diagrams.TwoD.Factorization
--   fdMultTableEx = fdMultTable 13
--   </pre>
--   
fdMultTable :: (Renderable (Path V2 n) b, TypeableFloat n) => Integer -> QDiagram b V2 n Any


-- | 
--   The example above is created by the code below which generates a grid,
--   puts points on the interior and the boundary, draws dashed lines
--   around the points to which we wish to draw attention and annotates the
--   points of interest with some text.
--   
--   <pre>
--   {-# LANGUAGE FlexibleContexts      #-}
--   {-# LANGUAGE MultiParamTypeClasses #-}
--   
--   import Diagrams.TwoD.Grid
--   import Diagrams.TwoD.Text
--   
--   example :: (Renderable (Text Double) b, Renderable (Path V2 Double) b) =&gt;
--              Int -&gt; Int -&gt; QDiagram b V2 Double Any
--   example n m =
--   
--     (gridWithHalves n m) #
--   
--     -- Put points on the boundary
--     bndPts [ (1 :: Int,  m + 1     ) | m &lt;- [0,2..2 * m] ] #
--     bndPts [ (n + 1,     1 :: Int  ) | n &lt;- [0,2..2 * n] ] #
--     bndPts [ (2 * n + 1, m + 1     ) | m &lt;- [0,2..2 * m] ] #
--     bndPts [ (n + 1,     2 * m + 1 ) | n &lt;- [0,2..2 * n] ] #
--   
--     intPts [ (n + 1,          m + 1) | n &lt;- [2,4..2 * n - 1] :: [Int]
--                                      , m &lt;- [2,4..2 * m - 1] :: [Int] ] #
--   
--     selectedLines (2 * n - 3) (3 :: Int) #
--   
--     ann (2 * n - 1) (1 :: Int) red  #
--     ann (2 * n + 1) (3 :: Int) red  #
--     ann (2 * n - 1) (3 :: Int) blue #
--     ann (2 * n - 3) (3 :: Int) blue #
--     ann (2 * n - 1) (5 :: Int) blue
--   
--     where
--   
--       ann n m c = annotate ("u_" ++ show (n `div` 2) ++ show (m `div` 2)) txtPt c n m
--   
--       selectedLines n m = gridLines $ selectedPairs n m
--   
--       selectedPairs n m = let pts = selectedList n m
--                           in zip pts (tail pts)
--   
--       selectedList n m = [ (n - 1, m - 1)
--                          , (n - 1, m + 1)
--                          , (n + 1, m + 1)
--                          , (n + 1, m + 3)
--                          , (n + 3, m + 3)
--                          , (n + 3, m + 1)
--                          , (n + 5, m + 1)
--                          , (n + 5, m - 1)
--                          , (n + 3, m - 1)
--                          , (n + 3, m - 3)
--                          , (n + 1, m - 3)
--                          , (n + 1, m - 1)
--                          , (n - 1, m - 1)
--                          ]
--   
--       txtPt t = circle cSize # opacity 0.0 # lw none
--                 ===
--                 text t # fontSize (local 0.06)
--   
--       intPts = placeDiagramOnGrid (circle (cSize / 2) # fc blue # opacity 0.5 # lw none)
--       bndPts = placeDiagramOnGrid (circle (cSize / 2) # fc red  # opacity 0.5 # lw none)
--   
--       cSize :: Double
--       cSize = 0.03
--   
--   example1 = example 5 5
--   </pre>
module Diagrams.TwoD.Grid

-- | <tt>gridWithHalves'</tt> with default opts.
gridWithHalves :: (Renderable (Path V2 n) b, TypeableFloat n) => Int -> Int -> QDiagram b V2 n Any

-- | Create a n by m grid. Diagrams can be placed on either the grid points
--   themselves or on points half way between grid points. The latter
--   includes points a half grid length outside of the grid itself.
gridWithHalves' :: (Renderable (Path V2 n) b, TypeableFloat n) => GridOpts n -> Int -> Int -> QDiagram b V2 n Any
annotate :: (Floating n, Ord n, Typeable n) => String -> (String -> QDiagram b V2 n Any) -> Colour Double -> Int -> Int -> QDiagram b V2 n Any -> QDiagram b V2 n Any

-- | Draw a line between two named points on the grid.
gridLine :: (IsName a, IsName b, Renderable (Path V2 n) c, TypeableFloat n) => a -> b -> QDiagram c V2 n Any -> QDiagram c V2 n Any

-- | Draw a line between two named points on the grid.
gridLine' :: (IsName a, IsName b, Renderable (Path V2 n) c, TypeableFloat n) => HighlightLineOpts n -> a -> b -> QDiagram c V2 n Any -> QDiagram c V2 n Any

-- | Draw lines between a list of pairs of named points on the grid.
gridLines :: (Renderable (Path V2 n) c, TypeableFloat n, IsName a, IsName b) => [(a, b)] -> QDiagram c V2 n Any -> QDiagram c V2 n Any

-- | Place a diagram on a grid (which is itself a diagram) at all the
--   co-ordinates specified.
placeDiagramOnGrid :: (IsName nm, Floating n, Ord n) => QDiagram b V2 n Any -> [nm] -> QDiagram b V2 n Any -> QDiagram b V2 n Any
data GridOpts n
GridOpts :: Measure n -> Colour Double -> Colour Double -> V2 n -> V2 n -> V2 n -> GridOpts n
[_gridLineWidth] :: GridOpts n -> Measure n
[_gridYColour] :: GridOpts n -> Colour Double
[_gridXColour] :: GridOpts n -> Colour Double
[_gridLL] :: GridOpts n -> V2 n
[_gridLR] :: GridOpts n -> V2 n
[_gridUL] :: GridOpts n -> V2 n
gridLineWidth :: forall n_aHrC. Lens' (GridOpts n_aHrC) (Measure n_aHrC)
gridYColour :: forall n_aHrC. Lens' (GridOpts n_aHrC) (Colour Double)
gridXColour :: forall n_aHrC. Lens' (GridOpts n_aHrC) (Colour Double)
gridLL :: forall n_aHrC. Lens' (GridOpts n_aHrC) (V2 n_aHrC)
gridLR :: forall n_aHrC. Lens' (GridOpts n_aHrC) (V2 n_aHrC)
gridUL :: forall n_aHrC. Lens' (GridOpts n_aHrC) (V2 n_aHrC)
data HighlightLineOpts n
HighlightLineOpts :: Colour Double -> Measure n -> [Measure n] -> Measure n -> HighlightLineOpts n
[_highLightLineColour] :: HighlightLineOpts n -> Colour Double
[_highLightLineWidth] :: HighlightLineOpts n -> Measure n
[_highLightLineDashingOnOff] :: HighlightLineOpts n -> [Measure n]
[_highLightLineDashingOffset] :: HighlightLineOpts n -> Measure n
highLightLineColour :: forall n_aHrB. Lens' (HighlightLineOpts n_aHrB) (Colour Double)
highLightLineWidth :: forall n_aHrB. Lens' (HighlightLineOpts n_aHrB) (Measure n_aHrB)
highLightLineDashingOnOff :: forall n_aHrB. Lens' (HighlightLineOpts n_aHrB) [Measure n_aHrB]
highLightLineDashingOffset :: forall n_aHrB. Lens' (HighlightLineOpts n_aHrB) (Measure n_aHrB)
instance (GHC.Float.Floating n, GHC.Classes.Ord n) => Data.Default.Class.Default (Diagrams.TwoD.Grid.HighlightLineOpts n)
instance (GHC.Float.Floating n, GHC.Classes.Ord n) => Data.Default.Class.Default (Diagrams.TwoD.Grid.GridOpts n)


-- | A method for laying out diagrams using a circle packing algorithm. For
--   details on the algorithm, see <a>Optimisation.CirclePacking</a> in the
--   module circle-packing.
--   
--   Here is an example:
--   
--   <pre>
--   import Optimisation.CirclePacking
--   import Diagrams.TwoD.Vector       (e)
--   
--   colorize = zipWith fc $
--       cycle [red,blue,yellow,magenta,cyan,bisque,firebrick,indigo]
--   
--   objects = colorize $
--       [ circle r  | r &lt;- [0.1,0.2..1.6] ] ++
--       [ hexagon r | r &lt;- [0.1,0.2..0.7] ] ++
--       [ decagon r | r &lt;- [0.1,0.2..0.7] ]
--   
--   -- Just a approximation, diagram objects do not have an exact radius
--   radiusApproximation o = maximum [ radius (e (alpha @@ turn)) o | alpha &lt;- [0,0.1..1.0]]
--   
--   circlePackingExample =
--       position $ map (\(o,(x,y)) -&gt; (p2 (x,y),o)) $
--       packCircles radiusApproximation objects
--   </pre>
--   
module Diagrams.TwoD.Layout.CirclePacking

-- | Combines the passed objects, whose radius is estimated using the given
--   <a>RadiusFunction</a>, so that they do not overlap (according to the
--   radius function) and otherwise form, as far as possible, a tight
--   circle.
renderCirclePacking :: (Monoid' m, Floating (N b), Ord (N b)) => RadiusFunction b m -> [QDiagram b V2 (N b) m] -> QDiagram b V2 (N b) m

-- | More general version of <a>renderCirclePacking</a>. You can use this
--   if you have more information available in the values of type
--   <tt>a</tt> that allows you to calculate the radius better (or even
--   exactly).
createCirclePacking :: (Monoid' m, Ord (N b), Floating (N b)) => (a -> Double) -> (a -> QDiagram b V2 (N b) m) -> [a] -> QDiagram b V2 (N b) m

-- | The type of radius-estimating functions for Diagrams such as
--   <a>approxRadius</a> and <a>circleRadius</a>. When you can calculate
--   the radius better, but not any more once you converted your data to a
--   diagram, use <a>createCirclePacking</a>.
type RadiusFunction b m = QDiagram b V2 (N b) m -> Double

-- | A safe approximation. Calculates the outer radius of the smallest
--   axis-aligned polygon with the given number of edges that contains the
--   object. A parameter of 4 up to 8 should be sufficient for most
--   applications.
approxRadius :: (Monoid' m, Floating (N b), Real (N b), Ord (N b)) => Int -> RadiusFunction b m

-- | An unsafe approximation. This is the radius of the largest circle that
--   fits in the rectangular bounding box of the object, so it may be too
--   small. It is, however, exact for circles, and there is no function
--   that is safe for all diagrams and exact for circles.
circleRadius :: (Monoid' m, Floating (N b), Real (N b)) => RadiusFunction b m


-- | Lay out diagrams by specifying constraints. Currently, the API is
--   fairly simple: only equational constraints are supported (not
--   inequalities), and you can only use it to compose a collection of
--   diagrams (and not to, say, compute the position of some point). Future
--   versions may support additional features.
--   
--   As a basic example, we can introduce a circle and a square, and
--   constrain them to be next to each other:
--   
--   <pre>
--   import Diagrams.TwoD.Layout.Constrained
--   
--   constrCircleSq = frame 0.2 $ layout $ do
--     c &lt;- newDia (circle 1)
--     s &lt;- newDia (square 2)
--     constrainWith hcat [c, s]
--   </pre>
--   
--   We start a block of constraints with <a>layout</a>; introduce new
--   diagrams with <a>newDia</a>, and then constrain them, in this case
--   using the <a>constrainWith</a> function. The result looks like this:
--   
--   
--   Of course this is no different than just writing <tt>circle 1 |||
--   square 2</tt>. The interest comes when we start constraining things in
--   more interesting ways.
--   
--   For example, the following code creates a row of differently-sized
--   circles with a bit of space in between them, and then draws a square
--   which is tangent to the last circle and passes through the center of
--   the third. Manually computing the size (and position) of this square
--   would be tedious. Instead, the square is declared to be scalable,
--   meaning it may be uniformly scaled to accomodate constraints. Then a
--   point on the left side of the square is constrained to be equal to the
--   center of the third circle, and a point on the right side of the
--   square is made equal to a point on the edge of the rightmost circle.
--   This causes the square to be automatically positioned and scaled
--   appropriately.
--   
--   <pre>
--   import Diagrams.TwoD.Layout.Constrained
--   
--   circleRow = frame 1 $ layout $ do
--     cirs &lt;- newDias (map circle [1..5])
--     constrainWith (hsep 1) cirs
--     rc &lt;- newPointOn (last cirs) (envelopeP unitX)
--   
--     sq &lt;- newScalableDia (square 1)
--     ls &lt;- newPointOn sq (envelopeP unit_X)
--     rs &lt;- newPointOn sq (envelopeP unitX)
--   
--     ls =.= centerOf (cirs !! 2)
--     rs =.= rc
--   </pre>
--   
--   
--   As a final example, the following code draws a vertical stack of
--   circles, along with an accompanying set of squares, such that (1) each
--   square constrained to lie on the same horizontal line as a circle
--   (using <tt>zipWithM_ <a>sameY</a></tt>), and (2) the squares all lie
--   on a diagonal line (using <a>along</a>).
--   
--   <pre>
--   import Diagrams.TwoD.Layout.Constrained
--   import Control.Monad (zipWithM_)
--   
--   diagonalLayout = frame 1 $ layout $ do
--     cirs &lt;- newDias (map circle [1..5] # fc blue)
--     sqs  &lt;- newDias (replicate 5 (square 2) # fc orange)
--     constrainWith vcat cirs
--     zipWithM_ sameY cirs sqs
--     constrainWith hcat [cirs !! 0, sqs !! 0]
--     along (direction (1 ^&amp; (-1))) (map centerOf sqs)
--   </pre>
--   
--   
--   Take a look at the implementations of combinators such as
--   <a>sameX</a>, <a>allSame</a>, <a>constrainDir</a>, and <a>along</a>
--   for ideas on implementing your own constraint combinators.
--   
--   Ideas for future versions of this module:
--   
--   <ul>
--   <li>Introduce z-index constraints. Right now the diagrams are just
--   drawn in the order that they are introduced.</li>
--   <li>A way to specify default values --- <i>i.e.</i> be able to
--   introduce new point or scalar variables with a specified default value
--   (instead of just defaulting to the origin or to 1).</li>
--   <li>Doing something more reasonable than crashing for overconstrained
--   systems.</li>
--   </ul>
--   
--   I am also open to other suggestions and/or pull requests!
module Diagrams.TwoD.Layout.Constrained

-- | The type of reified expressions over <tt>Vars</tt>, with numeric
--   values taken from the type <tt>n</tt>. The important point to note is
--   that <a>Expr</a> is an instance of <a>Num</a>, <a>Fractional</a>, and
--   <a>Floating</a>, so <a>Expr</a> values can be combined and manipulated
--   as if they were numeric expressions, even when they occur inside other
--   types. For example, 2D vector values of type <tt>V2 (Expr s n)</tt>
--   and point values of type <tt>P2 (Expr s n)</tt> can be combined using
--   operators such as <a>.+^</a>, <a>.-.</a>, and so on, in order to
--   express constraints on vectors and points.
--   
--   To create literal <a>Expr</a> values, you can use <a>mkExpr</a>.
--   Otherwise, they are introduced by creation functions such as
--   <a>newPoint</a>, <a>newScalar</a>, or diagram accessor functions like
--   <a>centerOf</a> or <a>xOf</a>.
type Expr s n = Expr (Var s) n

-- | Convert a literal numeric value into an <a>Expr</a>. To convert
--   structured types such as vectors or points, you can use e.g. <tt>fmap
--   mkExpr :: V2 n -&gt; V2 (Expr s n)</tt>.
mkExpr :: n -> Expr s n

-- | A monad for constrained systems. It suffices to think of it as an
--   abstract monadic type; the constructor for the internal state is
--   intentionally not exported. <a>Constrained</a> values can be created
--   using the combinators below; combined using the <tt>Monad</tt>
--   interface; and discharged by the <a>layout</a> function.
--   
--   Note that <tt>s</tt> is a phantom parameter, used in a similar fashion
--   to the <tt>ST</tt> monad, to ensure that generated diagram IDs cannot
--   be mixed between different <a>layout</a> blocks.
type Constrained s b n m a = State (ConstrainedState s b n m) a

-- | The state maintained by the Constrained monad. Note that <tt>s</tt> is
--   a phantom parameter, used in a similar fashion to the <tt>ST</tt>
--   monad, to ensure that generated diagram IDs do not leak.
data ConstrainedState s b n m

-- | An abstract type representing unique IDs for diagrams. The constructor
--   is not exported, so the only way to obtain a <a>DiaID</a> is by
--   calling <a>newDia</a> or <a>newDias</a>. The phantom type parameter
--   <tt>s</tt> ensures that such <a>DiaID</a>s can only be used with the
--   constrained system in which they were introduced.
data DiaID s

-- | Solve a constrained system, combining the resulting diagrams with
--   <a>mconcat</a>. This is the top-level function for introducing a
--   constrained system, and is the only way to generate an actual diagram.
--   
--   Redundant constraints are ignored. If there are any unconstrained
--   diagram variables remaining, they are given default values one at a
--   time, beginning with defaulting remaining scaling factors to 1, then
--   defaulting x- and y-coordinates to zero.
--   
--   An overconstrained system will cause <a>layout</a> to simply crash.
--   This is obviously not ideal. A future version may do something more
--   reasonable.
layout :: (Monoid' m, Hashable n, Floating n, RealFrac n, Show n) => (forall s. Constrained s b n m a) -> QDiagram b V2 n m

-- | Like <a>layout</a>, but also allows the caller to retrieve the result
--   of the <a>Constrained</a> computation.
runLayout :: (Monoid' m, Hashable n, Floating n, RealFrac n, Show n) => (forall s. Constrained s b n m a) -> (a, QDiagram b V2 n m)

-- | Introduce a new diagram into the constrained system. Returns a unique
--   ID for use in referring to the diagram later.
--   
--   The position of the diagram's origin may be constrained. If
--   unconstrained, the origin will default to (0,0). For a diagram whose
--   scaling factor may also be constrained, see <a>newScalableDia</a>.
newDia :: (Hashable n, Floating n, RealFrac n) => QDiagram b V2 n m -> Constrained s b n m (DiaID s)

-- | Introduce a list of diagrams into the constrained system. Returns a
--   corresponding list of unique IDs for use in referring to the diagrams
--   later.
newDias :: (Hashable n, Floating n, RealFrac n) => [QDiagram b V2 n m] -> Constrained s b n m [DiaID s]

-- | Introduce a new diagram into the constrained system. Returns a unique
--   ID for use in referring to the diagram later.
--   
--   Both the position of the diagram's origin and its scaling factor may
--   be constrained. If unconstrained, the origin will default to (0,0),
--   and the scaling factor to 1, respectively.
newScalableDia :: QDiagram b V2 n m -> Constrained s b n m (DiaID s)

-- | Introduce a new constrainable point, unattached to any particular
--   diagram. If either of the coordinates are still unconstrained at the
--   end, they will default to zero.
newPoint :: Num n => Constrained s b n m (P2 (Expr s n))

-- | Create a new (constrainable) point attached to the given diagram,
--   using a function that picks a point given a diagram.
--   
--   For example, to get the point on the right edge of a diagram's
--   envelope, one may write
--   
--   <pre>
--   rt &lt;- newPointOn d (envelopeP unitX)
--   </pre>
--   
--   To get the point (1,1),
--   
--   <pre>
--   one_one &lt;- newPointOn d (const (1 ^&amp; 1))
--   </pre>
--   
--   This latter example is far from useless: note that <tt>one_one</tt>
--   now corresponds not to the absolute coordinates (1,1), but to the
--   point which lies at (1,1) /relative to the unscaled diagram's origin/.
--   If the diagram is positioned or scaled to satisfy some other
--   constraints, <tt>one_one</tt> will move right along with it.
--   
--   For example, the following code establishes a small circle which is
--   located at a specific point relative to a big circle. The small circle
--   is carried along with the big circle as it is laid out in between some
--   squares.
--   
--   <pre>
--   import Diagrams.TwoD.Layout.Constrained
--   
--   circleWithCircle = frame 0.3 $ layout $ do
--     c2 &lt;- newScalableDia (circle 2)
--     p &lt;- newPointOn c2 (const $ (1 ^&amp; 0) # rotateBy (1/8))
--   
--     c1 &lt;- newDia (circle 1)
--     centerOf c1 =.= p
--   
--     [a,b] &lt;- newDias (replicate 2 (square 2))
--     constrainWith hcat [a,c2,b]
--   </pre>
--   
newPointOn :: (Hashable n, Floating n, RealFrac n) => DiaID s -> (QDiagram b V2 n m -> P2 n) -> Constrained s b n m (P2 (Expr s n))

-- | Introduce a new scalar value which can be constrained. If still
--   unconstrained at the end, it will default to 1.
newScalar :: Num n => Constrained s b n m (Expr s n)

-- | The point at the center (i.e. local origin) of the given diagram. For
--   example, to constrain the origin of diagram <tt>b</tt> to be offset
--   from the origin of diagram <tt>a</tt> by one unit to the right and one
--   unit up, one may write
--   
--   <pre>
--   centerOf b =.= centerOf a .+^ (1 ^&amp; 1)
--   </pre>
centerOf :: Num n => DiaID s -> P2 (Expr s n)

-- | The x-coordinate of the center for the given diagram, which can be
--   used in constraints to determine the x-position of this diagram
--   relative to others.
--   
--   For example,
--   
--   <pre>
--   xOf d1 + 2 === xOf d2
--   </pre>
--   
--   constrains diagram <tt>d2</tt> to lie 2 units to the right of
--   <tt>d1</tt> in the horizontal direction, though it does not constrain
--   their relative positioning in the vertical direction.
xOf :: Num n => DiaID s -> Expr s n

-- | The y-coordinate of the center for the given diagram, which can be
--   used in constraints to determine the y-position of this diagram
--   relative to others.
--   
--   For example,
--   
--   <pre>
--   allSame (map yOf ds)
--   </pre>
--   
--   constrains the diagrams <tt>ds</tt> to all lie on the same horizontal
--   line.
yOf :: Num n => DiaID s -> Expr s n

-- | The scaling factor applied to this diagram.
--   
--   For example,
--   
--   <pre>
--   scaleOf d1 === 2 * scaleOf d2
--   </pre>
--   
--   constrains <tt>d1</tt> to be scaled twice as much as <tt>d2</tt>. (It
--   does not, however, guarantee anything about their actual relative
--   sizes; that depends on their relative size when unscaled.)
scaleOf :: Num n => DiaID s -> Expr s n

-- | Constrain two scalar expressions to be equal. Note that you need not
--   worry about introducing redundant constraints; they are ignored.
(====) :: (Floating n, RealFrac n, Hashable n) => Expr s n -> Expr s n -> Constrained s b n m ()
infix 1 ====

-- | Constrain two points to be equal.
(=.=) :: (Hashable n, Floating n, RealFrac n) => P2 (Expr s n) -> P2 (Expr s n) -> Constrained s b n m ()
infix 1 =.=

-- | Constrain two vectors to be equal.
(=^=) :: (Hashable n, Floating n, RealFrac n) => V2 (Expr s n) -> V2 (Expr s n) -> Constrained s b n m ()
infix 1 =^=

-- | Constrain the origins of two diagrams to have the same x-coordinate.
sameX :: (Hashable n, Floating n, RealFrac n) => DiaID s -> DiaID s -> Constrained s b n m ()

-- | Constrain the origins of two diagrams to have the same y-coordinate.
sameY :: (Hashable n, Floating n, RealFrac n) => DiaID s -> DiaID s -> Constrained s b n m ()

-- | Constrain a list of scalar expressions to be all equal.
allSame :: (Hashable n, Floating n, RealFrac n) => [Expr s n] -> Constrained s b n m ()

-- | Constrain a collection of diagrams to be positioned relative to one
--   another according to a function such as <a>hcat</a>, <a>vcat</a>,
--   <a>hsep</a>, and so on.
--   
--   A typical use would be
--   
--   <pre>
--   cirs &lt;- newDias (map circle [1..5])
--   constrainWith (hsep 1) cirs
--   </pre>
--   
--   which creates five circles and constrains them to be positioned in a
--   row, with one unit of space in between adjacent pairs.
--   
--   The funny type signature is something of a hack. The sorts of
--   functions which should be passed as the first argument to
--   <a>constrainWith</a> tend to be highly polymorphic;
--   <a>constrainWith</a> uses a concrete type which it can use to extract
--   relevant information about the function by observing its behavior. In
--   short, you do not need to know anything about <tt>Located
--   Envelope</tt>s in order to call this function.
constrainWith :: (Hashable n, RealFrac n, Floating n, Monoid' m) => ([[Located (Envelope V2 n)]] -> [Located (Envelope V2 n)]) -> [DiaID s] -> Constrained s b n m ()

-- | <tt>constrainDir d p q</tt> constrains the direction from <tt>p</tt>
--   to <tt>q</tt> to be <tt>d</tt>. That is, the direction of the vector
--   <tt>q .-. p</tt> must be <tt>d</tt>.
constrainDir :: (Hashable n, Floating n, RealFrac n) => Direction V2 (Expr s n) -> P2 (Expr s n) -> P2 (Expr s n) -> Constrained s b n m ()

-- | <tt>along d ps</tt> constrains the points <tt>ps</tt> to all lie along
--   a ray parallel to the direction <tt>d</tt>.
along :: (Hashable n, Floating n, RealFrac n) => Direction V2 (Expr s n) -> [P2 (Expr s n)] -> Constrained s b n m ()
instance Data.Hashable.Class.Hashable (Diagrams.TwoD.Layout.Constrained.DiaID s)
instance Data.Hashable.Class.Hashable Diagrams.TwoD.Layout.Constrained.VarType
instance Data.Hashable.Class.Hashable (Diagrams.TwoD.Layout.Constrained.Var s)
instance GHC.Show.Show (Diagrams.TwoD.Layout.Constrained.Var s)
instance GHC.Generics.Generic (Diagrams.TwoD.Layout.Constrained.Var s)
instance GHC.Classes.Ord (Diagrams.TwoD.Layout.Constrained.Var s)
instance GHC.Classes.Eq (Diagrams.TwoD.Layout.Constrained.Var s)
instance GHC.Generics.Generic Diagrams.TwoD.Layout.Constrained.VarType
instance GHC.Show.Show Diagrams.TwoD.Layout.Constrained.VarType
instance GHC.Read.Read Diagrams.TwoD.Layout.Constrained.VarType
instance GHC.Classes.Ord Diagrams.TwoD.Layout.Constrained.VarType
instance GHC.Classes.Eq Diagrams.TwoD.Layout.Constrained.VarType
instance GHC.Generics.Generic (Diagrams.TwoD.Layout.Constrained.DiaID s)
instance GHC.Show.Show (Diagrams.TwoD.Layout.Constrained.DiaID s)
instance GHC.Classes.Eq (Diagrams.TwoD.Layout.Constrained.DiaID s)
instance GHC.Classes.Ord (Diagrams.TwoD.Layout.Constrained.DiaID s)


-- | Functions for effortlessly putting lists of diagrams in a grid layout.
module Diagrams.TwoD.Layout.Grid

-- | Puts a list of diagrams in a grid, left-to-right, top-to-bottom. The
--   grid is as close to square as possible.
--   
--   <pre>
--   import Diagrams.TwoD.Layout.Grid
--   gridCatExample = gridCat $ map (flip regPoly 1) [3..10]
--   </pre>
--   
gridCat :: TypeableFloat n => [QDiagram b V2 n Any] -> QDiagram b V2 n Any

-- | Same as <a>gridCat</a>, but with a specified number of columns.
--   
--   <pre>
--   import Diagrams.TwoD.Layout.Grid
--   gridCatExample' = gridCat' 4 $ map (flip regPoly 1) [3..10]
--   </pre>
--   
gridCat' :: TypeableFloat n => Int -> [QDiagram b V2 n Any] -> QDiagram b V2 n Any

-- | Puts a list of diagrams in a grid, alternating left-to-right and
--   right-to-left. Useful for comparing sequences of diagrams. The grid is
--   as close to square as possible.
--   
--   <pre>
--   import Diagrams.TwoD.Layout.Grid
--   gridSnakeExample = gridSnake $ map (flip regPoly 1) [3..10]
--   </pre>
--   
gridSnake :: TypeableFloat n => [QDiagram b V2 n Any] -> QDiagram b V2 n Any

-- | Same as <a>gridSnake</a>, but with a specified number of columns.
--   
--   <pre>
--   import Diagrams.TwoD.Layout.Grid
--   gridSnakeExample' = gridSnake' 4 $ map (flip regPoly 1) [3..10]
--   </pre>
--   
gridSnake' :: TypeableFloat n => Int -> [QDiagram b V2 n Any] -> QDiagram b V2 n Any

-- | `gridWith f (cols, rows)` uses <tt>f</tt>, a function of two
--   zero-indexed integer coordinates, to generate a grid of diagrams with
--   the specified dimensions.
gridWith :: TypeableFloat n => (Int -> Int -> QDiagram b V2 n Any) -> (Int, Int) -> QDiagram b V2 n Any

-- | Make all diagrams have the same bounding rect, one that bounds them
--   all.
sameBoundingRect :: forall n b. TypeableFloat n => [QDiagram b V2 n Any] -> [QDiagram b V2 n Any]

-- | Make all diagrams have the same bounding square, one that bounds them
--   all.
sameBoundingSquare :: forall b n. TypeableFloat n => [QDiagram b V2 n Any] -> [QDiagram b V2 n Any]


-- | A collection of methods for laying out various kinds of trees. This
--   module is still experimental, and more layout methods will probably be
--   added over time.
--   
--   Laying out a rose tree using a symmetric layout:
--   
--   <pre>
--   import Data.Tree
--   import Diagrams.TwoD.Layout.Tree
--   
--   t1 = Node 'A' [Node 'B' (map lf "CDE"), Node 'F' [Node 'G' (map lf "HIJKLM"), Node 'N' (map lf "OPQR")]]
--     where lf x = Node x []
--   
--   exampleSymmTree =
--     renderTree ((&lt;&gt; circle 1 # fc white) . text . (:[]))
--                (~~)
--                (symmLayout' (with &amp; slHSep .~ 4 &amp; slVSep .~ 4) t1)
--     # centerXY # pad 1.1
--   </pre>
--   
--   
--   Laying out a rose tree of diagrams, with spacing automatically
--   adjusted for the size of the diagrams:
--   
--   <pre>
--   import Data.Tree
--   import Data.Maybe (fromMaybe)
--   import Diagrams.TwoD.Layout.Tree
--   
--   tD = Node (rect 1 3)
--          [ Node (circle 0.2) []
--          , Node (hcat . replicate 3 $ circle 1) []
--          , Node (eqTriangle 5) []
--          ]
--   
--   exampleSymmTreeWithDs =
--     renderTree id (~~)
--     (symmLayout' (with &amp; slWidth  .~ fromMaybe (0,0) . extentX
--                        &amp; slHeight .~ fromMaybe (0,0) . extentY)
--        tD)
--     # centerXY # pad 1.1
--   </pre>
--   
--   
--   Using a variant symmetric layout algorithm specifically for binary
--   trees:
--   
--   <pre>
--   import Diagrams.TwoD.Layout.Tree
--   import Diagrams.Prelude hiding (Empty)
--   
--   drawT = maybe mempty (renderTree (const (circle 0.05 # fc black)) (~~))
--         . symmLayoutBin' (with &amp; slVSep .~ 0.5)
--   
--   tree500 = drawT t # centerXY # pad 1.1
--     where t = genTree 500 0.05
--           -- genTree 500 0.05 randomly generates trees of size 500 +/- 5%,
--           -- definition not shown
--   </pre>
--   
--   
--   Using force-based layout on a binary tree:
--   
--   <pre>
--   {-# LANGUAGE NoMonomorphismRestriction #-}
--   import Diagrams.Prelude hiding (Empty)
--   import Diagrams.TwoD.Layout.Tree
--   
--   gent 0 = Empty
--   gent n = BNode n (gent (n-1)) (gent (n-1))
--   
--   Just t' = uniqueXLayout 1 1 (gent 4)
--   
--   fblEx = renderTree (\n -&gt; (text (show n) # fontSizeL 0.5
--                               &lt;&gt; circle 0.3 # fc white))
--               (~~)
--               (forceLayoutTree t')
--           # centerXY # pad 1.1
--   </pre>
--   
--   
--   Using a radial layout:
--   
--   <pre>
--   import Diagrams.Prelude
--   import Diagrams.TwoD.Layout.Tree
--   import Data.Tree
--   
--   t = Node 'A' [Node 'B' (map lf "CDE"), Node 'F' [Node 'G' (map lf "HIJKLM"), Node 'N' (map lf "OPQRS")], Node 'T' (map lf "UVWXYZ")]
--     where lf x = Node x []
--   
--   radialEx =
--      renderTree (\n -&gt; (text (show n) # fontSizeG 0.5
--                               &lt;&gt; circle 0.5 # fc white))
--                (~~) (radialLayout t)
--      # centerXY # pad 1.1
--   </pre>
--   
module Diagrams.TwoD.Layout.Tree

-- | Binary trees with data at internal nodes.
data BTree a
Empty :: BTree a
BNode :: a -> (BTree a) -> (BTree a) -> BTree a

-- | Convenient constructor for leaves.
leaf :: a -> BTree a

-- | <tt>uniqueXLayout xSep ySep t</tt> lays out the binary tree <tt>t</tt>
--   using a simple recursive algorithm with the following properties:
--   
--   <ul>
--   <li>Every left subtree is completely to the left of its parent, and
--   similarly for right subtrees.</li>
--   <li>All the nodes at a given depth in the tree have the same
--   y-coordinate. The separation distance between levels is given by
--   <tt>ySep</tt>.</li>
--   <li>Every node has a unique x-coordinate. The separation between
--   successive nodes from left to right is given by <tt>xSep</tt>.</li>
--   </ul>
uniqueXLayout :: Num n => n -> n -> BTree a -> Maybe (Tree (a, P2 n))

-- | Radial layout of rose trees, adapted from Andy Pavlo, "Interactive,
--   Tree-Based Graph Visualization", p. 18
--   (<a>http://www.cs.cmu.edu/~pavlo/static/papers/APavloThesis032006.pdf</a>)
radialLayout :: Tree a -> Tree (a, P2 Double)

-- | Run the symmetric rose tree layout algorithm on a given tree using
--   default options, resulting in the same tree annotated with node
--   positions.
symmLayout :: (Fractional n, Ord n) => Tree a -> Tree (a, P2 n)

-- | Run the symmetric rose tree layout algorithm on a given tree,
--   resulting in the same tree annotated with node positions.
symmLayout' :: (Fractional n, Ord n) => SymmLayoutOpts n a -> Tree a -> Tree (a, P2 n)

-- | Lay out a binary tree using a slight variant of the symmetric layout
--   algorithm, using default options. In particular, if a node has only a
--   left child but no right child (or vice versa), the child will be
--   offset from the parent horizontally by half the horizontal separation
--   parameter. Note that the result will be <tt>Nothing</tt> if and only
--   if the input tree is <tt>Empty</tt>.
symmLayoutBin :: (Fractional n, Ord n) => BTree a -> Maybe (Tree (a, P2 n))

-- | Lay out a binary tree using a slight variant of the symmetric layout
--   algorithm. In particular, if a node has only a left child but no right
--   child (or vice versa), the child will be offset from the parent
--   horizontally by half the horizontal separation parameter. Note that
--   the result will be <tt>Nothing</tt> if and only if the input tree is
--   <tt>Empty</tt>.
symmLayoutBin' :: (Fractional n, Ord n) => SymmLayoutOpts n a -> BTree a -> Maybe (Tree (a, P2 n))

-- | Options for controlling the symmetric tree layout algorithm.
data SymmLayoutOpts n a
SLOpts :: n -> n -> a -> (n, n) -> a -> (n, n) -> SymmLayoutOpts n a

-- | Minimum horizontal separation between sibling nodes. The default is 1.
[_slHSep] :: SymmLayoutOpts n a -> n

-- | Vertical separation between adjacent levels of the tree. The default
--   is 1.
[_slVSep] :: SymmLayoutOpts n a -> n

-- | A function for measuring the horizontal extent (a pair of
--   x-coordinates) of an item in the tree. The default is <tt>const
--   (0,0)</tt>, that is, the nodes are considered as taking up no space,
--   so the centers of the nodes will be separated according to the
--   <tt>slHSep</tt> and <tt>slVSep</tt>. However, this can be useful,
--   <i>e.g.</i> if you have a tree of diagrams of irregular size and want
--   to make sure no diagrams overlap. In that case you could use
--   <tt>fromMaybe (0,0) . extentX</tt>.
[_slWidth] :: SymmLayoutOpts n a -> a -> (n, n)

-- | A function for measuring the vertical extent of an item in the tree.
--   The default is <tt>const (0,0)</tt>. See the documentation for
--   <a>slWidth</a> for more information.
[_slHeight] :: SymmLayoutOpts n a -> a -> (n, n)
slHSep :: forall n_aVw4 a_aVw5. Lens' (SymmLayoutOpts n_aVw4 a_aVw5) n_aVw4
slVSep :: forall n_aVw4 a_aVw5. Lens' (SymmLayoutOpts n_aVw4 a_aVw5) n_aVw4
slWidth :: forall n_aVw4 a_aVw5. Lens' (SymmLayoutOpts n_aVw4 a_aVw5) (a_aVw5 -> (n_aVw4, n_aVw4))
slHeight :: forall n_aVw4 a_aVw5. Lens' (SymmLayoutOpts n_aVw4 a_aVw5) (a_aVw5 -> (n_aVw4, n_aVw4))

-- | Force-directed layout of rose trees, with default parameters (for more
--   options, see <a>forceLayoutTree'</a>). In particular,
--   
--   <ul>
--   <li>edges are modeled as springs</li>
--   <li>nodes are modeled as point charges</li>
--   <li>nodes are constrained to keep the same y-coordinate.</li>
--   </ul>
--   
--   The input could be a tree already laid out by some other method, such
--   as <a>uniqueXLayout</a>.
forceLayoutTree :: (Floating n, Ord n) => Tree (a, P2 n) -> Tree (a, P2 n)

-- | Force-directed layout of rose trees, with configurable parameters.
forceLayoutTree' :: (Floating n, Ord n) => ForceLayoutTreeOpts n -> Tree (a, P2 n) -> Tree (a, P2 n)
data ForceLayoutTreeOpts n
FLTOpts :: ForceLayoutOpts n -> n -> n -> n -> ForceLayoutTreeOpts n

-- | Options to the force layout simulator, including damping.
[_forceLayoutOpts] :: ForceLayoutTreeOpts n -> ForceLayoutOpts n

-- | How long edges should be, ideally. This will be the resting length for
--   the springs.
[_edgeLen] :: ForceLayoutTreeOpts n -> n

-- | Spring constant. The bigger the constant, the more the edges push/pull
--   towards their resting length.
[_springK] :: ForceLayoutTreeOpts n -> n

-- | Coulomb constant. The bigger the constant, the more sibling nodes
--   repel each other.
[_staticK] :: ForceLayoutTreeOpts n -> n
forceLayoutOpts :: forall n_aWjb. Lens' (ForceLayoutTreeOpts n_aWjb) (ForceLayoutOpts n_aWjb)
edgeLen :: forall n_aWjb. Lens' (ForceLayoutTreeOpts n_aWjb) n_aWjb
springK :: forall n_aWjb. Lens' (ForceLayoutTreeOpts n_aWjb) n_aWjb
staticK :: forall n_aWjb. Lens' (ForceLayoutTreeOpts n_aWjb) n_aWjb

-- | Assign unique ID numbers to the nodes of a tree, and generate an
--   <a>Ensemble</a> suitable for simulating in order to do force-directed
--   layout of the tree. In particular,
--   
--   <ul>
--   <li>edges are modeled as springs</li>
--   <li>nodes are modeled as point charges</li>
--   <li>nodes are constrained to keep the same y-coordinate.</li>
--   </ul>
--   
--   The input to <tt>treeToEnsemble</tt> could be a tree already laid out
--   by some other method, such as <a>uniqueXLayout</a>.
treeToEnsemble :: forall a n. Floating n => ForceLayoutTreeOpts n -> Tree (a, P2 n) -> (Tree (a, PID), Ensemble V2 n)

-- | Assign unique IDs to every node in a tree (or other traversable
--   structure).
label :: (Traversable t) => t a -> t (a, PID)

-- | Reconstruct a tree (or any traversable structure) from an
--   <a>Ensemble</a>, given unique identifier annotations matching the
--   identifiers used in the <a>Ensemble</a>.
reconstruct :: (Functor t, Num n) => Ensemble V2 n -> t (a, PID) -> t (a, P2 n)

-- | Draw a tree annotated with node positions, given functions specifying
--   how to draw nodes and edges.
renderTree :: (Monoid' m, Floating n, Ord n) => (a -> QDiagram b V2 n m) -> (P2 n -> P2 n -> QDiagram b V2 n m) -> Tree (a, P2 n) -> QDiagram b V2 n m

-- | Draw a tree annotated with node positions, given functions specifying
--   how to draw nodes and edges. Unlike <a>renderTree</a>, this version
--   gives the edge-drawing function access to the actual values stored at
--   the nodes rather than just their positions.
renderTree' :: (Monoid' m, Floating n, Ord n) => (a -> QDiagram b V2 n m) -> ((a, P2 n) -> (a, P2 n) -> QDiagram b V2 n m) -> Tree (a, P2 n) -> QDiagram b V2 n m
instance GHC.Float.Floating n => Data.Default.Class.Default (Diagrams.TwoD.Layout.Tree.ForceLayoutTreeOpts n)
instance GHC.Num.Num n => Data.Default.Class.Default (Diagrams.TwoD.Layout.Tree.SymmLayoutOpts n a)
instance GHC.Base.Semigroup (Diagrams.TwoD.Layout.Tree.Extent n)
instance GHC.Base.Monoid (Diagrams.TwoD.Layout.Tree.Extent n)
instance GHC.Show.Show Diagrams.TwoD.Layout.Tree.Pos
instance GHC.Classes.Eq Diagrams.TwoD.Layout.Tree.Pos
instance Data.Traversable.Traversable Diagrams.TwoD.Layout.Tree.BTree
instance Data.Foldable.Foldable Diagrams.TwoD.Layout.Tree.BTree
instance GHC.Base.Functor Diagrams.TwoD.Layout.Tree.BTree
instance GHC.Show.Show a => GHC.Show.Show (Diagrams.TwoD.Layout.Tree.BTree a)
instance GHC.Read.Read a => GHC.Read.Read (Diagrams.TwoD.Layout.Tree.BTree a)
instance GHC.Classes.Ord a => GHC.Classes.Ord (Diagrams.TwoD.Layout.Tree.BTree a)
instance GHC.Classes.Eq a => GHC.Classes.Eq (Diagrams.TwoD.Layout.Tree.BTree a)


-- | Set operations on paths. As a side effect it removes overlapping
--   regions. Since <a>Path</a> is <a>TrailLike</a>, you can use these
--   operations directly with any combinator which generates <a>Loop</a>s,
--   like <tt>circle</tt> or <a>fromSegments</a>. <a>Line</a>s are
--   discarded, only <a>Loop</a>s are used. If you have several paths, you
--   can combine them with <a>&lt;&gt;</a> first. Use <a>toPath</a> if you
--   want to convert a <a>Trail</a> or <a>Located</a> <a>Trail</a> to a
--   <a>Path</a>. The <a>FillRule</a> argument determines how
--   <i>insideness</i> is calculated for the input.
module Diagrams.TwoD.Path.Boolean

-- | Remove overlapping regions in the path. If you have several paths,
--   combine them using <a>&lt;&gt;</a> first.
--   
--   
--   <pre>
--   import Diagrams.TwoD.Path.Boolean
--   import Diagrams.Prelude hiding (union)
--   
--   unionEx = frame 0.1 . strokePath $ union Winding $
--             (square 1) &lt;&gt; circle 0.5 # translate (V2 0.5 (-0.5))
--   </pre>
union :: FillRule -> Path V2 Double -> Path V2 Double

-- | Difference of two paths. First overlap is removed in the two input
--   arguments, then the difference is calculated.
--   
--   
--   <pre>
--   import Diagrams.TwoD.Path.Boolean
--   import Diagrams.Prelude hiding (difference)
--   
--   diffEx = frame 0.1 . strokePath $
--            difference Winding (square 1) $
--            circle 0.5 # translate (V2 0.5 (-0.5))
--   </pre>
difference :: FillRule -> Path V2 Double -> Path V2 Double -> Path V2 Double

-- | Intersection of two paths. First overlap is removed in the two input
--   arguments, then the intersection is calculated.
--   
--   
--   <pre>
--   import Diagrams.TwoD.Path.Boolean
--   import Diagrams.Prelude hiding (intersection)
--   
--   isectEx = frame 0.1 . strokePath $
--             intersection Winding (square 1) $
--             circle 0.5 # translate (V2 0.5 (-0.5))
--   </pre>
intersection :: FillRule -> Path V2 Double -> Path V2 Double -> Path V2 Double

-- | Exclusion (exclusive or) of two paths. First overlap is removed in the
--   two input arguments, then the exclusion is calculated.
--   
--   
--   <pre>
--   import Diagrams.TwoD.Path.Boolean
--   
--   exclEx = fc grey . frame 0.1 . strokePath $
--            exclusion Winding (square 1) $
--            circle 0.5 # translate (V2 0.5 (-0.5))
--   </pre>
exclusion :: FillRule -> Path V2 Double -> Path V2 Double -> Path V2 Double

-- | Like <a>union</a>, but takes a tolerance parameter.
union' :: Double -> FillRule -> Path V2 Double -> Path V2 Double

-- | Like <a>difference</a>, but takes a tolerance parameter.
difference' :: Double -> FillRule -> Path V2 Double -> Path V2 Double -> Path V2 Double

-- | Like <a>intersection</a>, but takes a tolerance parameter.
intersection' :: Double -> FillRule -> Path V2 Double -> Path V2 Double -> Path V2 Double

-- | Like <a>exclusion</a>, but takes a tolerance parameter.
exclusion' :: Double -> FillRule -> Path V2 Double -> Path V2 Double -> Path V2 Double

-- | Union of a list of loops.
loopUnion :: Double -> FillRule -> [Located (Trail' Loop V2 Double)] -> [Located (Trail' Loop V2 Double)]

-- | Difference between loops. The loops in both lists are first merged
--   using <a>union</a>.
loopDifference :: Double -> FillRule -> [Located (Trail' Loop V2 Double)] -> [Located (Trail' Loop V2 Double)] -> [Located (Trail' Loop V2 Double)]

-- | Intersection of loops. The loops in both lists are first merged using
--   <a>union</a>.
loopIntersection :: Double -> FillRule -> [Located (Trail' Loop V2 Double)] -> [Located (Trail' Loop V2 Double)] -> [Located (Trail' Loop V2 Double)]

-- | Exclusion (xor) of loops. The loops in both lists are first merged
--   using <a>union</a>.
loopExclusion :: Double -> FillRule -> [Located (Trail' Loop V2 Double)] -> [Located (Trail' Loop V2 Double)] -> [Located (Trail' Loop V2 Double)]


-- | Create "calligraphic" strokes by filling between two offset copies of
--   a curve.
module Diagrams.TwoD.Path.Calligraphic

-- | <tt>calligraphic pen t</tt> creates a "calligraphic" variant of
--   <tt>t</tt> by filling between two copies of <tt>t</tt> offset by the
--   <tt>pen</tt> vector.
--   
--   
--   <pre>
--   import Diagrams.Coordinates
--   import Diagrams.TwoD.Path.Calligraphic
--   
--   curve = cubicSpline False [1 ^&amp; 1, 2 ^&amp; 5, 5 ^&amp; 6, 8 ^&amp; 12]
--         # scale 3
--   
--   calligraphicEx =
--     [ circle 15 # calligraphic (2 ^&amp; 1)
--     , curve     # calligraphic (2 ^&amp; 2)
--     ]
--     # map (centerXY . strokeLoop)
--     # fc black
--     # hcat' (with &amp; sep .~ 10)
--   </pre>
calligraphic :: (Floating n, Ord n) => V2 n -> Trail' Line V2 n -> Trail' Loop V2 n


-- | An alternative monoid for trails which rotates trails so their
--   starting and ending tangents match at join points.
module Diagrams.TwoD.Path.Follow

-- | <tt>Following</tt> is just like <tt>Trail' Line V2</tt>, except that
--   it has a different <a>Monoid</a> instance. <tt>Following</tt> values
--   are concatenated, just like regular lines, except that they are also
--   rotated so the tangents match at the join point. In addition, they are
--   normalized so the tangent at the start point is in the direction of
--   the positive x axis (essentially we are considering trails equivalent
--   up to rotation).
--   
--   Pro tip: you can concatenate a list of trails so their tangents match
--   using <a>ala</a> from <a>Control.Lens</a>, like so:
--   
--   <pre>
--   ala follow foldMap :: [Trail' Line V2 n] -&gt; Trail' Line V2 n
--   </pre>
--   
--   This is illustrated in the example below.
--   
--   
--   <pre>
--   import Control.Lens (ala)
--   import Diagrams.TwoD.Path.Follow
--   
--   wibble :: Trail' Line V2 Double
--   wibble = hrule 1 &lt;&gt; hrule 0.5 # rotateBy (1/6) &lt;&gt; hrule 0.5 # rotateBy (-1/6) &lt;&gt; a
--     where a = arc (xDir # rotateBy (-1/4)) (1/5 @@ turn)
--             # scale 0.7
--   
--   followExample =
--     [ wibble
--     , wibble
--       # replicate 5
--       # ala follow foldMap
--     ]
--     # map stroke
--     # map centerXY
--     # vsep 1
--     # frame 0.5
--   </pre>
data Following n

-- | Create a <tt>Following</tt> from a line, normalizing it (by rotation)
--   so that it starts in the positive x direction.
follow :: RealFloat n => Trail' Line V2 n -> Following n

-- | Project out the line from a <a>Following</a>.
--   
--   If trails are considered equivalent up to rotation, then
--   <a>unfollow</a> and <a>follow</a> are inverse.
unfollow :: Following n -> Trail' Line V2 n
instance (GHC.Float.Floating n, GHC.Classes.Ord n) => GHC.Base.Semigroup (Diagrams.TwoD.Path.Follow.Following n)
instance (GHC.Float.Floating n, GHC.Classes.Ord n) => GHC.Base.Monoid (Diagrams.TwoD.Path.Follow.Following n)
instance GHC.Float.RealFloat n => Control.Lens.Wrapped.Wrapped (Diagrams.TwoD.Path.Follow.Following n)
instance GHC.Float.RealFloat n => Control.Lens.Wrapped.Rewrapped (Diagrams.TwoD.Path.Follow.Following n) (Diagrams.TwoD.Path.Follow.Following n')


-- | Generate fractal trails by the "iterated subset" construction,
--   iteratively replacing each segment with a given pattern.
module Diagrams.TwoD.Path.IteratedSubset

-- | Use a trail to "refine" a linear segment (represented by a vector),
--   returning a scaled and/or rotated copy of the trail with the same
--   endpoint as the segment.
refineSegment :: RealFloat n => Trail' Line V2 n -> V2 n -> Maybe (Trail' Line V2 n)

-- | Given a "seed pattern", produce a list of successive refinements: the
--   zeroth trail in the output list is a horizontal unit segment, and the
--   nth trail is formed by replacing each segment of the seed pattern with
--   the (n-1)st trail. (Equivalently, the nth trail consists of the
--   (n-1)st trail with every segment replaced by the seed pattern.)
--   
--   See <a>iterGenerator</a> for a more sophisticated variant which can
--   associate one of four orientations with each segment of the seed
--   pattern.
--   
--   <pre>
--   import Diagrams.TwoD.Path.IteratedSubset
--   iterTrailEx = vsep 0.3 . map strokeLine . take 5
--               $ iterTrail koch
--   </pre>
--   
iterTrail :: RealFloat n => Trail' Line V2 n -> [Trail' Line V2 n]

-- | A <i>generator segment</i> is a vector along with two bits' worth of
--   orientation information: whether there is a reflection swapping its
--   start and end, and whether there is a reflection across its axis. When
--   a generator segment is replaced by a complex path, the endpoints of
--   the path will match the endpoints of the segment, but the path may
--   first have some reflections applied to it according to the orientation
--   of the segment.
data GeneratorSegment n
GS :: (V2 n) -> Bool -> Bool -> GeneratorSegment n

-- | Make a generator segment by specifying an x component, a y component,
--   a "horizontal" orientation (1 means normal, -1 means reversing the
--   start and end of the segment) and a "vertical" orientation (1 means
--   normal, -1 means reflecting across the axis of the segment). This
--   corresponds to the notation used by Ventrella in <i>Brainfilling
--   Curves</i>.
mkGS :: (n, n, Int, Int) -> GeneratorSegment n

-- | Make a generator segment on a triangular grid, by specifying a segment
--   on a square grid and then applying a shear and a scale to transform
--   the square grid into a triangular grid, as in the diagram below:
--   
mkGS3 :: Floating n => (n, n, Int, Int) -> GeneratorSegment n

-- | A generator is a sequence of consecutive generator segments.
type Generator n = [GeneratorSegment n]

-- | Use a trail to "refine" a generator segment, returning a scaled and/or
--   rotated copy of the trail with the same endpoints as the segment, and
--   with appropriate reflections applied depending on the orientation of
--   the segment.
refineGeneratorSegment :: RealFloat n => Trail' Line V2 n -> GeneratorSegment n -> Maybe (Trail' Line V2 n)

-- | Given a generator, produce a list of successive refinements: the
--   zeroth trail in the output list is a horizontal unit segment, and the
--   nth trail is formed by refining each segment of the generator with the
--   (n-1)st trail.
--   
--   <pre>
--   import Diagrams.TwoD.Path.IteratedSubset
--   iterGenEx = hsep 0.3 . map strokeLine . take 7
--             $ iterGenerator dragonGen
--   </pre>
--   
iterGenerator :: RealFloat n => Generator n -> [Trail' Line V2 n]

-- | Perform a "level-1 smoothing" by replacing a list of segments by the
--   segments between their midpoints. Can be a useful technique for
--   visualizing degenerate space-filling curves, <i>e.g.</i> which touch
--   at corners or even share entire edges.
averageLine :: (Metric v, Floating n, Ord n) => Trail' Line v n -> Trail' Line v n

-- | Bevel a line by "chopping off each corner", connecting points 1/3 and
--   2/3 of the way along each segment. Can be a useful technique for
--   visualizing degenerate space-filling curves, <i>e.g.</i> which touch
--   at corners or even share entire edges.
bevelLine :: (Metric v, Floating n, Ord n) => Trail' Line v n -> Trail' Line v n

-- | Create a graphical representation of a generator, using half
--   arrowheads to show the orientation of each segment.
showGenerator :: (Renderable (Path V2 n) b, TypeableFloat n) => Generator n -> QDiagram b V2 n Any

-- | Seed for the Koch curve (side of the famous Koch <a>snowflake</a>).
--   
koch :: (TrailLike t, V t ~ V2, N t ~ n) => t

-- | Seed for the Lévy dragon curve.
--   
levy :: (TrailLike t, V t ~ V2, N t ~ n) => t

-- | Strange zig-zag seed that produces a dense fractal path with lots of
--   triangles.
--   
zag :: (TrailLike t, V t ~ V2, N t ~ n) => t

-- | A "square impulse" seed which produces a quadratic von Koch curve.
--   
sqUp :: (TrailLike t, V t ~ V2, N t ~ n) => t

-- | A "double square impulse" seed which produces fantastic rectilinear
--   spiral patterns.
--   
sqUpDown :: (TrailLike t, V t ~ V2, N t ~ n) => t

-- | Generator for the classic Harter-Heighway Dragon (Ventrella p. 52,
--   sqrt 2 family).
--   
dragonGen :: Generator Double

-- | Generator for the Pólya sweep (Ventrella p. 52, sqrt 2 family).
--   
polyaGen :: Generator Double

-- | Generator for the Ter-Dragon (Ventrella p. 55, sqrt 3 family).
--   
terDragonGen :: Generator Double

-- | Inverted Ter-Dragon (Ventrella p. 56, sqrt 3 family).
--   
invTerDragonGen :: Generator Double

-- | Ventrella p. 56b, sqrt 3 family.
--   
ventrella56b :: Generator Double

-- | Yin Dragon (Ventrella p. 59, sqrt 3 family).
--   
yinDragonGen :: Generator Double

-- | Ventrella p. 67, sqrt 4 family.
--   
ventrella67 :: Generator Double

-- | "Inner-flip Quartet" (Ventrella p. 85, sqrt 5 family).
--   
innerFlipQuartetGen :: Generator Double

-- | "Anti-Gosper" (Ventrella p. 97, sqrt 7 family).
--   
antiGosperGen :: Generator Double

-- | "Mandelbrot Snowflake Sweep #2" (Ventrella p. 197, sqrt 27 family).
--   
mandelbrotSnowflakeGen :: Generator Double

-- | The famous Koch snowflake, made by putting three Koch curves together.
--   <tt>snowflake n</tt> yields an order-<tt>n</tt> snowflake.
--   
snowflake :: RealFloat n => Int -> Trail V2 n

-- | Parameters to generate an iterated subset fractal.
data IterTrailConfig n
ITC :: Trail' Line V2 n -> Colour Double -> Int -> IterTrailConfig n

-- | The seed trail
[seed] :: IterTrailConfig n -> Trail' Line V2 n

-- | The line color to use
[color] :: IterTrailConfig n -> Colour Double

-- | Number of iterations
[iters] :: IterTrailConfig n -> Int

-- | Generate a random <a>IterTrailConfig</a>. This features many
--   hard-coded values. If you want to play with it just copy the code and
--   modify it to suit.
randITC :: (MonadRandom m, Ord n, Floating n, Random n) => m (IterTrailConfig n)

-- | Generate an iterated subset fractal based on the given parameters.
drawITC :: (Renderable (Path V2 n) b, TypeableFloat n) => IterTrailConfig n -> QDiagram b V2 n Any

-- | Like <a>drawITC</a>, but also scales, centers, and pads the result so
--   that it fits nicely inside a 4x4 box.
drawITCScaled :: (Renderable (Path V2 n) b, RealFloat n, Typeable n) => IterTrailConfig n -> QDiagram b V2 n Any

-- | Create a grid of 25 random iterated subset fractals. Impress your
--   friends!
--   
randIterGrid :: (Renderable (Path V2 n) b, Random n, TypeableFloat n) => IO (QDiagram b V2 n Any)

module Diagrams.TwoD.Path.Metafont.Types

-- | A <tt>PathJoin</tt> specifies the directions at both ends of a
--   segment, and a join which describes the control points explicitly or
--   implicitly.
data PathJoin d j
PJ :: d -> j -> d -> PathJoin d j
[_d1] :: PathJoin d j -> d
[_j] :: PathJoin d j -> j
[_d2] :: PathJoin d j -> d
j :: forall d_a15KD j_a15KE j_a15OF. Lens (PathJoin d_a15KD j_a15KE) (PathJoin d_a15KD j_a15OF) j_a15KE j_a15OF
d2 :: forall d_a15KD j_a15KE. Lens' (PathJoin d_a15KD j_a15KE) d_a15KD
d1 :: forall d_a15KD j_a15KE. Lens' (PathJoin d_a15KD j_a15KE) d_a15KD

-- | A direction can be specified at any point of a path. A <i>curl</i>
--   should only be specified at the endpoints. The endpoints default to
--   curl 1 if not set.
data PathDir n
PathDirCurl :: n -> PathDir n
PathDirDir :: (Dir n) -> PathDir n

-- | A predicate to determine the constructor used.
isCurl :: PathDir n -> Bool
type Curl n = n
type Dir n = Direction V2 n
type BasicJoin n = Either (TensionJoin n) (ControlJoin n)

-- | Higher <i>Tension</i> brings the path closer to a straight line
--   between segments. Equivalently, it brings the control points closer to
--   the endpoints. <tt>TensionAmt</tt> introduces a fixed tension.
--   <tt>TensionAtLeast</tt> introduces a tension which will be increased
--   if by so doing, an inflection point can be eliminated.
data Tension n
TensionAmt :: n -> Tension n
TensionAtLeast :: n -> Tension n
getTension :: Tension n -> n

-- | Two tensions and two directions completely determine the control
--   points of a segment.
data TensionJoin n
TJ :: Tension n -> Tension n -> TensionJoin n
[_t1] :: TensionJoin n -> Tension n
[_t2] :: TensionJoin n -> Tension n

-- | The two intermediate control points of a segment, specified directly.
data ControlJoin n
CJ :: P2 n -> P2 n -> ControlJoin n
[_c1] :: ControlJoin n -> P2 n
[_c2] :: ControlJoin n -> P2 n
t2 :: forall n_a15Pi. Lens' (TensionJoin n_a15Pi) (Tension n_a15Pi)
t1 :: forall n_a15Pi. Lens' (TensionJoin n_a15Pi) (Tension n_a15Pi)
c2 :: forall n_a15Ph. Lens' (ControlJoin n_a15Ph) (P2 n_a15Ph)
c1 :: forall n_a15Ph. Lens' (ControlJoin n_a15Ph) (P2 n_a15Ph)
data P
data J

-- | <tt>MFPathData</tt> is the type manipulated by the metafont
--   combinators.
data MFPathData a n
[MFPathCycle] :: MFPathData P n
[MFPathEnd] :: P2 n -> MFPathData P n
[MFPathPt] :: P2 n -> MFPathData J n -> MFPathData P n
[MFPathJoin] :: PathJoin (Maybe (PathDir n)) (Maybe (BasicJoin n)) -> MFPathData P n -> MFPathData J n

-- | <tt>MetafontSegment</tt> is used internally in solving the metafont
--   equations. It represents a segment with two known endpoints, and a
--   <i>join</i>, which may be specified in various ways.
data MetafontSegment d j n
MFS :: P2 n -> (PathJoin d j) -> P2 n -> MetafontSegment d j n
[_x1] :: MetafontSegment d j n -> P2 n
[_pj] :: MetafontSegment d j n -> (PathJoin d j)
[_x2] :: MetafontSegment d j n -> P2 n

-- | <tt>MFPath</tt> is the type used internally in solving the metafont
--   equations. The direction and join types are progressively refined
--   until all control points are known. The <tt>loop</tt> flag affects
--   both the equations to be solved and the type of <tt>Trail</tt> in the
--   result. If constructing an <tt>MFPath</tt> in new code, the
--   responsibility rests on the user to ensure that successive
--   <tt>MetafontSegment</tt>s share an endpoint. If this is not true, the
--   result is undefined.
data MFPath d j n
MFP :: Bool -> [MetafontSegment d j n] -> MFPath d j n
[_loop] :: MFPath d j n -> Bool
[_segs] :: MFPath d j n -> [MetafontSegment d j n]

-- | MFP is a type synonym to clarify signatures in Metafont.Internal. Note
--   that the type permits segments which are "overspecified", having one
--   or both directions specified, and also a <a>ControlJoin</a>. In this
--   case, <a>Metafont.Internal</a> ignores the directions.
type MFP n = MFPath (Maybe (PathDir n)) (BasicJoin n) n

-- | MFS is a type synonym to clarify signatures in
--   <a>Metafont.Internal</a>.
type MFS n = MetafontSegment (Maybe (PathDir n)) (BasicJoin n) n
x2 :: forall d_a1605 j_a1606 n_a1607. Lens' (MetafontSegment d_a1605 j_a1606 n_a1607) (P2 n_a1607)
x1 :: forall d_a1605 j_a1606 n_a1607. Lens' (MetafontSegment d_a1605 j_a1606 n_a1607) (P2 n_a1607)
pj :: forall d_a1605 j_a1606 n_a1607 d_a169H j_a169I. Lens (MetafontSegment d_a1605 j_a1606 n_a1607) (MetafontSegment d_a169H j_a169I n_a1607) (PathJoin d_a1605 j_a1606) (PathJoin d_a169H j_a169I)
segs :: forall d_a1602 j_a1603 n_a1604 d_a16bX j_a16bY n_a16bZ. Lens (MFPath d_a1602 j_a1603 n_a1604) (MFPath d_a16bX j_a16bY n_a16bZ) [MetafontSegment d_a1602 j_a1603 n_a1604] [MetafontSegment d_a16bX j_a16bY n_a16bZ]
loop :: forall d_a1602 j_a1603 n_a1604. Lens' (MFPath d_a1602 j_a1603 n_a1604) Bool
instance GHC.Base.Monoid (Diagrams.TwoD.Path.Metafont.Types.PathJoin (GHC.Base.Maybe (Diagrams.TwoD.Path.Metafont.Types.PathDir n)) (GHC.Base.Maybe (Diagrams.TwoD.Path.Metafont.Types.BasicJoin n)))
instance GHC.Base.Semigroup (Diagrams.TwoD.Path.Metafont.Types.PathJoin (GHC.Base.Maybe (Diagrams.TwoD.Path.Metafont.Types.PathDir n)) (GHC.Base.Maybe (Diagrams.TwoD.Path.Metafont.Types.BasicJoin n)))
instance (GHC.Show.Show n, GHC.Show.Show d, GHC.Show.Show j) => GHC.Show.Show (Diagrams.TwoD.Path.Metafont.Types.MFPath d j n)
instance (GHC.Show.Show n, GHC.Show.Show d, GHC.Show.Show j) => GHC.Show.Show (Diagrams.TwoD.Path.Metafont.Types.MetafontSegment d j n)
instance GHC.Base.Functor (Diagrams.TwoD.Path.Metafont.Types.MetafontSegment d j)
instance GHC.Show.Show n => GHC.Show.Show (Diagrams.TwoD.Path.Metafont.Types.ControlJoin n)
instance GHC.Show.Show n => GHC.Show.Show (Diagrams.TwoD.Path.Metafont.Types.TensionJoin n)
instance GHC.Show.Show n => GHC.Show.Show (Diagrams.TwoD.Path.Metafont.Types.Tension n)
instance GHC.Show.Show n => GHC.Show.Show (Diagrams.TwoD.Path.Metafont.Types.PathDir n)
instance (GHC.Show.Show d, GHC.Show.Show j) => GHC.Show.Show (Diagrams.TwoD.Path.Metafont.Types.PathJoin d j)
instance GHC.Base.Functor (Diagrams.TwoD.Path.Metafont.Types.PathJoin d)

module Diagrams.TwoD.Path.Metafont.Parser

-- | Parse a <tt>Text</tt> value in Metafont syntax, as destribed in /The
--   METAFONTbook/.
metafontParser :: (Num n, Read n) => Parser (MFPath (Maybe (PathDir n)) (BasicJoin n) n)


-- | Solve equations due to John Hobby, as implemented in Donald Knuth's
--   <i>Metafont</i>, to create (usually) smooth paths from specified
--   points and directions.
module Diagrams.TwoD.Path.Metafont.Internal

-- | Run all the rules required to fully specify all segment directions,
--   but do not replace the Joins with ControlJoin.
solve :: RealFloat n => MFP n -> MFPath (Dir n) (BasicJoin n) n

-- | Take a segment whose endpoint directions have been fully determined,
--   and compute the control points to realize it as a cubic Bézier
--   segment. If the segment already has control points specified, the
--   directions are ignored (they are assumed to match). If the segment
--   tensions are specified as TensionAtLeast, check whether the minimum
--   tension will lead to an inflection point. If so, pick the maximum
--   velocity (equivalent to minimum tension) that avoids the inflection
--   point. Otherwise, calculate the velocity from the tension using
--   <a>hobbyF</a>. Then calculate the control point positions from the
--   direction and the velocity. Afterwards we can forget the direction
--   information (since the control points are what we really want, and the
--   directions can be recovered by subtracting the control points from the
--   endpoints anyway).
computeControls :: RealFloat n => MetafontSegment (Dir n) (BasicJoin n) n -> MetafontSegment () (ControlJoin n) n

-- | Convert a MetaFont path to a Diagrams Trail, using a Loop or Line as
--   needed
locatedTrail :: (Floating n, Ord n) => MFPath () (ControlJoin n) n -> Located (Trail V2 n)

-- | Convert a path in combinator syntax to the internal representation
--   used for solving.
mfPathToSegments :: forall n. Num n => MFPathData P n -> MFP n


-- | Combinators to allow writing Metafont-style paths embedded in Haskell,
--   with the usual Diagrams types for points and directions.
module Diagrams.TwoD.Path.Metafont.Combinators

-- | <i>point</i> <tt>.-</tt> <i>join</i> <tt>-.</tt> <i>path</i> adds
--   <i>point</i> to the left end of the metafont <i>path</i>, connected by
--   <i>join</i>.
(.-) :: P2 n -> MFPathData J n -> MFPathData P n
infixr 5 .-

-- | See <tt>.-</tt> above.
(-.) :: Join n -> MFPathData P n -> MFPathData J n
infixr 5 -.

-- | Add a point to the left of a Metafont path using a simple join. That
--   is, neither direction is specified, and both tensions are 1.
(.--.) :: P2 n -> MFPathData P n -> MFPathData P n
infixr 5 .--.

-- | Terminate the right-end of a Metafont path at the given point.
endpt :: P2 n -> MFPathData P n

-- | Wrap the right-end of the Metafont path back to the left-end. When
--   converted to a Diagrams <a>Trail'</a>, this will be a Loop.
cyclePath :: MFPathData P n

-- | simpleJoin is the same as mempty, with a more specific type. It is
--   provided for convenience in situations where explicit type signatures
--   would otherwise be needed, such as when building up a join using
--   lenses.
simpleJoin :: Join n

-- | A join with both tensions the same.
tension :: n -> Join n

-- | A join with two tension values.
tensions :: n -> n -> Join n

-- | A join with explicit control points. Note that these are in the same
--   coordinate system as the endpoints, not relative to the latter.
controls :: P2 n -> P2 n -> Join n

-- | A join with the left-end direction specified.
leaving :: V2 n -> Join n

-- | A join with the right-end direction specified.
arriving :: V2 n -> Join n


-- | Define Diagrams Paths by specifying points and optionally directions
--   and tension. Calculate control points to maintain smooth curvature at
--   each point, following rules implemented in Donald Knuth's
--   <i>Metafont</i>.
--   
--   This module is intended to be imported qualified.
module Diagrams.TwoD.Path.Metafont

-- | MF.fromString parses a Text value in MetaFont syntax, and attempts to
--   return a TrailLike. Only a subset of Metafont is supported; see the
--   tutorial for details.
fromString :: (TrailLike t, V t ~ V2, N t ~ n, Read n, RealFloat n) => Text -> Either ParseError t

-- | fromStrings takes a list of MetaFont strings, and returns either all
--   errors, or, if there are no parsing errors, a TrailLike for each
--   string. fromStrings is provided as a convenience because the MetaFont
--   &amp;-join is not supported. <a>mconcat</a> (<a>&lt;&gt;</a>) on the
--   TrailLike is equivalent, with clearer semantics.
fromStrings :: (TrailLike t, V t ~ V2, N t ~ n, Read n, RealFloat n) => [Text] -> Either [ParseError] [t]

-- | Should you wish to construct the MFPath in some other fashion,
--   fromPath makes a TrailLike directly from the MFPath
fromPath :: (TrailLike t, V t ~ V2, N t ~ n, RealFloat n) => MFP n -> t

-- | flex ps draws a Trail through the points ps, such that at every point
--   p ∊ ps except the endpoints, the Trail is parallel to the line from
--   the first to the last point. This is the same as the flex command
--   defined in plain MetaFont.
flex :: (TrailLike t, V t ~ V2, N t ~ n, RealFloat n) => [P2 n] -> t

-- | metafont converts a path defined in the Metafont combinator synax into
--   a native Diagrams TrailLike.
metafont :: (TrailLike t, V t ~ V2, N t ~ n, RealFloat n) => MFPathData P n -> t

-- | Parse a <tt>Text</tt> value in Metafont syntax, as destribed in /The
--   METAFONTbook/.
metafontParser :: (Num n, Read n) => Parser (MFPath (Maybe (PathDir n)) (BasicJoin n) n)


-- | Authors : Michael Sloan <a>at gmail</a>, Deepak Jois
--   <a>deepak.jois@gmail.com</a>
--   
--   A module consisting of core types and functions to represent and
--   operate on a "turtle".
--   
--   More info about turtle graphics:
--   <a>http://en.wikipedia.org/wiki/Turtle_graphics</a>
module Diagrams.TwoD.Path.Turtle.Internal

-- | Core turtle data type. A turtle needs to keep track of its current
--   position, like its position, heading etc., and all the paths that it
--   has traversed so far.
--   
--   We need to record a new path, everytime an attribute like style, pen
--   position etc changes, so that we can separately track styles for each
--   portion of the eventual path that the turtle took.
data TurtleState n
TurtleState :: Bool -> P2 n -> Angle n -> Located (Trail' Line V2 n) -> PenStyle n -> [TurtlePath n] -> TurtleState n

-- | State of the pen. <tt>False</tt> means that turtle movements will not
--   draw anything
[isPenDown] :: TurtleState n -> Bool

-- | Current position. This is updated everytime the turtle moves
[penPos] :: TurtleState n -> P2 n

-- | Orientation of the turtle in 2D space, given in degrees
[heading] :: TurtleState n -> Angle n

-- | Path traversed by the turtle so far, without any style or pen
--   attributes changing
[currTrail] :: TurtleState n -> Located (Trail' Line V2 n)

-- | Current style of the pen
[currPenStyle] :: TurtleState n -> PenStyle n

-- | List of paths along with style information, traversed by the turtle
--   previously
[paths] :: TurtleState n -> [TurtlePath n]

-- | Turtle path type that captures a list of paths and the style
--   attributes associated with them
data TurtlePath n
TurtlePath :: PenStyle n -> Located (Trail V2 n) -> TurtlePath n

-- | Style
[penStyle] :: TurtlePath n -> PenStyle n

-- | Path
[turtleTrail] :: TurtlePath n -> Located (Trail V2 n)

-- | Style attributes associated with the turtle pen
data PenStyle n
PenStyle :: Measure n -> Colour Double -> PenStyle n

-- | Width of pen. Default is 1.0
[penWidth] :: PenStyle n -> Measure n

-- | Color of pen. Default is <tt>black</tt>
[penColor] :: PenStyle n -> Colour Double

-- | Move the turtle forward by <tt>x</tt> units
forward :: (Floating n, Ord n) => n -> TurtleState n -> TurtleState n

-- | Move the turtle backward by <tt>x</tt> units
backward :: (Floating n, Ord n) => n -> TurtleState n -> TurtleState n

-- | Turn the turtle anti-clockwise (left)
left :: Floating n => n -> TurtleState n -> TurtleState n

-- | Turn the turtle clockwise (right)
right :: Floating n => n -> TurtleState n -> TurtleState n

-- | alias of <tt>setPenColour</tt>
setPenColor :: (Ord n, Floating n) => Colour Double -> TurtleState n -> TurtleState n

-- | Set a new pen color for turtle.
--   
--   If pen is down, this adds the current trail to <tt>paths</tt> and
--   starts a new empty trail.
setPenColour :: (Ord n, Floating n) => Colour Double -> TurtleState n -> TurtleState n

-- | Set a new pen width for turtle.
--   
--   If pen is down, this adds the current trail to <tt>paths</tt> and
--   starts a new empty trail.
setPenWidth :: (Ord n, Floating n) => Measure n -> TurtleState n -> TurtleState n

-- | The initial state of turtle. The turtle is located at the origin, at
--   an orientation of 0 degrees with its pen position down. The pen style
--   is <tt>defaultPenStyle</tt>.
startTurtle :: (Floating n, Ord n) => TurtleState n

-- | Turn the turtle to the given orientation, in degrees
setHeading :: Floating n => n -> TurtleState n -> TurtleState n

-- | Sets the turtle orientation towards a given location.
towards :: RealFloat n => P2 n -> TurtleState n -> TurtleState n

-- | Set the turtle X/Y position.
--   
--   If pen is down and the current trail is non-empty, this will also add
--   the current trail to the <tt>paths</tt> field.
setPenPos :: (Ord n, Floating n) => P2 n -> TurtleState n -> TurtleState n

-- | Puts the turtle pen in “Up” mode. Turtle movements will not draw
--   anything
--   
--   Does nothing if the pen was already up. Otherwise, it creates a turtle
--   with the current trail added to <tt>paths</tt>.
penUp :: (Ord n, Floating n) => TurtleState n -> TurtleState n

-- | Puts the turtle pen in “Down” mode. Turtle movements will cause
--   drawing to happen
--   
--   Does nothing if the pen was already down. Otherwise, starts a new
--   trail starting at the current position.
penDown :: (Ord n, Floating n) => TurtleState n -> TurtleState n
penHop :: (Ord n, Floating n) => TurtleState n -> TurtleState n
closeCurrent :: (Floating n, Ord n) => TurtleState n -> TurtleState n

-- | Creates a diagram from a turtle
--   
--   Applies the styles to each trails in <tt>paths</tt> separately and
--   combines them into a single diagram
getTurtleDiagram :: (Renderable (Path V2 n) b, TypeableFloat n) => TurtleState n -> QDiagram b V2 n Any

-- | Creates a path from a turtle, ignoring the styles.
getTurtlePath :: (Floating n, Ord n) => TurtleState n -> Path V2 n


-- | Stateful domain specific language for diagram paths, modelled after
--   the classic "turtle" graphics language.
module Diagrams.TwoD.Path.Turtle
type Turtle n = TurtleT n Identity
type TurtleT n = StateT (TurtleState n)

-- | Run the turtle, yielding the final turtle state.
runTurtle :: (Floating n, Ord n) => Turtle n a -> TurtleState n

-- | A more general way to run the turtle. Returns a computation in the
--   underlying monad <tt>m</tt> yielding the final turtle state.
runTurtleT :: (OrderedField n, Monad m) => TurtleT n m a -> m (TurtleState n)

-- | Run the turtle, yielding a diagram.
drawTurtle :: (Renderable (Path V2 n) b, TypeableFloat n) => Turtle n a -> QDiagram b V2 n Any

-- | A more general way to run the turtle. Returns a computation in the
--   underlying monad <tt>m</tt> yielding the final diagram.
drawTurtleT :: (Monad m, Renderable (Path V2 n) b, TypeableFloat n) => TurtleT n m a -> m (QDiagram b V2 n Any)

-- | Run the turtle, ignoring any pen style commands and yielding a 2D
--   path.
sketchTurtle :: (Floating n, Ord n) => Turtle n a -> Path V2 n

-- | A more general way to run the turtle. Returns a computation in the
--   underlying monad <tt>m</tt>, ignoring any pen style commands and
--   yielding a 2D path.
sketchTurtleT :: (Monad m, Floating n, Ord n) => TurtleT n m a -> m (Path V2 n)

-- | Move the turtle forward, along the current heading.
forward :: (OrderedField n, Monad m) => n -> TurtleT n m ()

-- | Move the turtle backward, directly away from the current heading.
backward :: (OrderedField n, Monad m) => n -> TurtleT n m ()

-- | Modify the current heading to the left by the specified angle in
--   degrees.
left :: (OrderedField n, Monad m) => n -> TurtleT n m ()

-- | Modify the current heading to the right by the specified angle in
--   degrees.
right :: (OrderedField n, Monad m) => n -> TurtleT n m ()

-- | Get the current turtle angle, in degrees.
heading :: (OrderedField n, Monad m) => TurtleT n m n

-- | Set the current turtle angle, in degrees.
setHeading :: (OrderedField n, Monad m) => n -> TurtleT n m ()

-- | Sets the heading towards a given location.
towards :: (Monad m, RealFloat n) => P2 n -> TurtleT n m ()

-- | Queries whether the pen is currently drawing a path or not.
isDown :: Monad m => TurtleT n m Bool

-- | Get the current turtle X/Y position.
pos :: Monad m => TurtleT n m (P2 n)

-- | Set the current turtle X/Y position.
setPos :: (OrderedField n, Monad m) => P2 n -> TurtleT n m ()

-- | Sets the pen size
setPenWidth :: (OrderedField n, Monad m) => Measure n -> TurtleT n m ()

-- | Sets the pen color
setPenColor :: (OrderedField n, Monad m) => Colour Double -> TurtleT n m ()

-- | Ends the current path, and enters into "penUp" mode
penUp :: (OrderedField n, Monad m) => TurtleT n m ()

-- | Ends the current path, and enters into "penDown" mode
penDown :: (OrderedField n, Monad m) => TurtleT n m ()

-- | Start a new trail at current position
penHop :: (OrderedField n, Monad m) => TurtleT n m ()

-- | Closes the current path , to the starting position of the current
--   trail. Has no effect when the pen position is up.
closeCurrent :: (OrderedField n, Monad m) => TurtleT n m ()


-- | Adds compact aliases for turtle operations, to write code that looks
--   even more Turtle-y.
module Diagrams.TwoD.Path.Turtle.Aliases
fd :: (Floating n, Ord n) => n -> Turtle n ()
bk :: (Floating n, Ord n) => n -> Turtle n ()
lt :: (Floating n, Ord n) => n -> Turtle n ()
rt :: (Floating n, Ord n) => n -> Turtle n ()
pu :: (Floating n, Ord n) => Turtle n ()
pd :: (Floating n, Ord n) => Turtle n ()


-- | Source code for creating the diagrams logo.
--   
module Diagrams.Example.Logo
d :: (Renderable Path V2 n b, RealFloat n, Typeable n) => QDiagram b V2 n Any
ico_d :: (Renderable Path V2 n b, RealFloat n, Typeable n) => QDiagram b V2 n Any
i :: (Monoid m, TrailLike QDiagram b V2 n m, RealFloat n, Typeable n) => QDiagram b V2 n m
sierpinski :: (Semigroup p, Juxtaposable p, TrailLike p, Num t, Alignable p, HasOrigin p, Eq t, V p ~# V2) => t -> p
a1 :: (HasStyle b, HasOrigin b, Alignable b, TrailLike b, Juxtaposable b, Semigroup b, Typeable N b, Transformable b, V b ~# V2) => b
grid :: (Transformable a, Alignable a, TrailLike a, Monoid a, HasOrigin a, Juxtaposable a, V a ~# V2) => a
gbkg :: forall b n m. (TrailLike (QDiagram b V2 n m), Monoid m, Semigroup m, TypeableFloat n) => QDiagram b V2 n m
g :: (Typeable n, RealFloat n, Renderable Path V2 n b, Renderable Text n b) => QDiagram b V2 n Any
r :: (Typeable n, RealFloat n, Renderable Path V2 n b) => QDiagram b V2 n Any
aTree :: BTree ()
a2 :: (Monoid m, Floating n, Ord n, TrailLike QDiagram b V2 n m, Typeable n) => QDiagram b V2 n m
m :: (Typeable n, RealFloat n, Renderable Path V2 n b, Renderable Text n b) => QDiagram b V2 n Any
ps :: Fractional n => [P2 n]
s :: (HasStyle b, Transformable b, TrailLike b, HasOrigin b, Monoid b, Typeable N b, V b ~# V2) => b
disk :: (TrailLike b, Transformable b, Typeable N b, HasStyle b, V b ~# V2) => Colour Double -> b
logo :: (Renderable Path V2 n b, Renderable Text n b, Typeable n, RealFloat n) => QDiagram b V2 n Any


-- | Create LSystem diagrams and paths.
--   
--   See "The Algorithmic Beauty of Plants".
--   <a>http://algorithmicbotany.org/papers/abop/abop-ch1.pdf</a>
module Diagrams.TwoD.Path.LSystem

-- | Symbols:
--   
--   <ul>
--   <li><pre>F ('F') draw a segment.</pre></li>
--   <li><pre>G ('f' or 'G') move the turtle one unit without drawing
--   anything.</pre></li>
--   <li><pre>Plus ('+') turn the turtle clockwise.</pre></li>
--   <li><pre>Minus ('-') turn the turtle anti-clockwise.</pre></li>
--   <li><pre>Reverse ('!') turn the turtle 180 degrees.</pre></li>
--   <li><pre>Flip ('~') switch right and left.</pre></li>
--   <li><pre>Push ('[') push the current state onto the stack.</pre></li>
--   <li><pre>Pop (']') pop the current state.</pre></li>
--   <li><pre>Width x ('&lt;', '&gt;') increase (decrease) stroke width by
--   factor of 1.1 (0.9).</pre></li>
--   <li><pre>Delta x ('(', ')') increase (decrease) turn angle by factor
--   of 1.1 (0.9).</pre></li>
--   <li><pre>X n ('X','Y','Z','A','B') constants.</pre></li>
--   </ul>
data Symbol n
F :: Symbol n
G :: Symbol n
Plus :: Symbol n
Minus :: Symbol n
Reverse :: Symbol n
Flip :: Symbol n
Push :: Symbol n
Pop :: Symbol n
X :: Int -> Symbol n
Width :: n -> Symbol n
Delta :: n -> Symbol n

-- | Production rules.
type Rules n = Map (Symbol n) [Symbol n]

-- | Successive generations of the production rules applied to the starting
--   symbols.
generations :: Ord n => Rules n -> [Symbol n] -> [[Symbol n]]

-- | Interpret a list of symbols as turtle graphics commands to create a
--   <a>TurtleState</a>. The turtle data is tracked in a Reader monad.
lSystemR :: (Floating n, Ord n) => [Symbol n] -> Reader (Environment n) (TurtleState n)

-- | Create a <tt>TurtelState</tt> using n iterations of the rules with
--   given axiom symbols and the angle increment, delta. The first segment
--   is in the unitX direction.
lSystem :: (Floating n, Ord n) => Int -> Angle n -> [Symbol n] -> Rules n -> TurtleState n

-- | Create a path using n iterations of the rules with given axiom symbols
--   and the angle increment, delta. The first segment is in the unitX
--   direction. The styles in the <a>TurtleState</a> are ignored.
lSystemPath :: (Floating n, Ord n) => Int -> Angle n -> [Symbol n] -> Rules n -> Path V2 n

-- | Create a diagram using n iterations of the rules with given axiom
--   symbols and the angle increment, delta. The first segment is in the
--   unitX direction. The styles in the <a>TurtleState</a> are applied to
--   the trails in the diagram.
lSystemDiagram :: (TypeableFloat n, Renderable (Path V2 n) b) => Int -> Angle n -> [Symbol n] -> Rules n -> QDiagram b V2 n Any
symbol :: Fractional n => Char -> Symbol n
symbols :: Fractional n => String -> [Symbol n]
rule :: Fractional n => Char -> String -> (Symbol n, [Symbol n])

-- | Sierpinski triangle.
--   
sierpinski :: RealFloat n => Int -> TurtleState n

-- | Cantor dust
--   
cantor :: (Renderable (Path V2 n) b, TypeableFloat n) => Int -> QDiagram b V2 n Any

-- | Dragon curve
--   
dragon :: RealFloat n => Int -> TurtleState n

-- | Hexagonal Gosper curve
--   
hexGosper :: RealFloat n => Int -> TurtleState n

-- | Koch Island
--   
kochIsland :: RealFloat n => Int -> TurtleState n

-- | Koch lake
--   
kochLake :: RealFloat n => Int -> TurtleState n

-- | Koch curve 1
--   
koch1 :: RealFloat n => Int -> TurtleState n

-- | Koch curve 2
--   
koch2 :: RealFloat n => Int -> TurtleState n

-- | Koch curve 3
--   
koch3 :: RealFloat n => Int -> TurtleState n

-- | Koch curve 4
--   
koch4 :: RealFloat n => Int -> TurtleState n

-- | Koch curve 5
--   
koch5 :: RealFloat n => Int -> TurtleState n

-- | Koch curve 6
--   
koch6 :: RealFloat n => Int -> TurtleState n

-- | Tree 1
--   
tree1 :: RealFloat n => Int -> TurtleState n

-- | Tree 2
--   
tree2 :: RealFloat n => Int -> TurtleState n

-- | Tree 3
--   
tree3 :: RealFloat n => Int -> TurtleState n

-- | Tree 4
--   
tree4 :: RealFloat n => Int -> TurtleState n

-- | Tree 5
--   
tree5 :: RealFloat n => Int -> TurtleState n

-- | Tree 6
--   
tree6 :: RealFloat n => Int -> TurtleState n

-- | Core turtle data type. A turtle needs to keep track of its current
--   position, like its position, heading etc., and all the paths that it
--   has traversed so far.
--   
--   We need to record a new path, everytime an attribute like style, pen
--   position etc changes, so that we can separately track styles for each
--   portion of the eventual path that the turtle took.
data TurtleState n

-- | Creates a path from a turtle, ignoring the styles.
getTurtlePath :: (Floating n, Ord n) => TurtleState n -> Path V2 n

-- | Creates a diagram from a turtle
--   
--   Applies the styles to each trails in <tt>paths</tt> separately and
--   combines them into a single diagram
getTurtleDiagram :: (Renderable (Path V2 n) b, TypeableFloat n) => TurtleState n -> QDiagram b V2 n Any
instance GHC.Show.Show n => GHC.Show.Show (Diagrams.TwoD.Path.LSystem.Symbol n)
instance GHC.Classes.Ord n => GHC.Classes.Ord (Diagrams.TwoD.Path.LSystem.Symbol n)
instance GHC.Classes.Eq n => GHC.Classes.Eq (Diagrams.TwoD.Path.LSystem.Symbol n)


-- | Generation of Sunburst Partitions. A radial view of a Treemap.
--   
--   The partitions are created without examining the contents of the tree
--   nodes which allows us to create a sunburst for any <tt>Tree a</tt>. As
--   a consequence we cannot base the size or color of the sections on the
--   data in the tree, but only on depth and number of children. Of course
--   the code could easily be adapted to handle more specific tree data.
--   
--   See John Stasko, Richard Catrambone, "An evaluation of space-filling
--   information visualizations for depicting hierarchical structures",
--   2000. <a>http://www.cc.gatech.edu/~john.stasko/papers/ijhcs00.pdf</a>.
module Diagrams.TwoD.Sunburst

-- | Take any <tt>Tree a</tt> and <tt>SunburstOpts</tt> and make a sunburst
--   partition. Basically a treemap with a radial layout. The root is the
--   center of the sunburst and its circumference is divided evenly
--   according to the number of child nodes it has. Then each of those
--   sections is treated the same way.
sunburst' :: (Renderable (Path V2 n) b, TypeableFloat n) => SunburstOpts n -> Tree a -> QDiagram b V2 n Any

-- | <tt>sunburst</tt> with default opts
--   
--   <pre>
--   import Diagrams.TwoD.Sunburst
--   import Data.Tree (unfoldTree)
--   aTree = unfoldTree (\n -&gt; (0, replicate n (n-1))) 6
--   sunburstEx = sunburst aTree # pad 1.1
--   </pre>
--   
sunburst :: (Renderable (Path V2 n) b, TypeableFloat n) => Tree a -> QDiagram b V2 n Any
data SunburstOpts n

-- | Color list one for each ring.
SunburstOpts :: n -> n -> [Colour Double] -> SunburstOpts n

-- | Relative size of the root circle, usually 1.
[_radius] :: SunburstOpts n -> n

-- | Relative width of the sections.
[_sectionWidth] :: SunburstOpts n -> n
[_colors] :: SunburstOpts n -> [Colour Double]
radius :: forall n_a1lRn. Lens' (SunburstOpts n_a1lRn) n_a1lRn
sectionWidth :: forall n_a1lRn. Lens' (SunburstOpts n_a1lRn) n_a1lRn
colors :: forall n_a1lRn. Lens' (SunburstOpts n_a1lRn) [Colour Double]
instance GHC.Real.Fractional n => Data.Default.Class.Default (Diagrams.TwoD.Sunburst.SunburstOpts n)


-- | Tools for generating and drawing plane tilings made of regular
--   polygons.
module Diagrams.TwoD.Tilings

-- | <tt>Q236 a b c d</tt> represents <tt>a + b sqrt(2) + c sqrt(3) + d
--   sqrt(6)</tt>. Note that the <tt>Ord</tt> instance is suitable for use
--   in <tt>Map</tt> and <tt>Set</tt>, but does not correspond to numeric
--   ordering (<tt>Q236</tt> is not an ordered field under this ordering).
data Q236
rt2 :: Q236
rt3 :: Q236
rt6 :: Q236

-- | Convert a <tt>Q236</tt> value to a <tt>Double</tt>.
toFloating :: Floating n => Q236 -> n
type Q2 = V2 Q236
toV2 :: Floating n => Q2 -> V2 n
toP2 :: Floating n => Q2 -> P2 n

-- | Regular polygons which may appear in a tiling of the plane.
data TilingPoly
Triangle :: TilingPoly
Square :: TilingPoly
Hexagon :: TilingPoly
Octagon :: TilingPoly
Dodecagon :: TilingPoly
polySides :: Num a => TilingPoly -> a
polyFromSides :: (Num a, Eq a, Show a) => a -> TilingPoly

-- | Cosine of a polygon's internal angle.
polyCos :: TilingPoly -> Q236

-- | Sine of a polygon's internal angle.
polySin :: TilingPoly -> Q236

-- | Rotate by polygon internal angle.
polyRotation :: TilingPoly -> Q2 -> Q2

-- | Rotate by polygon external angle.
polyExtRotation :: TilingPoly -> Q2 -> Q2

-- | A tiling, represented as a sort of zipper. <tt>curConfig</tt>
--   indicates the polygons around the current vertex, in couterclockwise
--   order starting from the edge along which we entered the vertex.
--   <tt>follow</tt> allows one to move along an edge to an adjacent
--   vertex, where the edges are numbered counterclockwise from zero,
--   beginning with the edge along which we entered the current vertex.
data Tiling
Tiling :: [TilingPoly] -> Int -> Tiling -> Tiling
[curConfig] :: Tiling -> [TilingPoly]
[follow] :: Tiling -> Int -> Tiling

-- | An edge is represented by a pair of vertices. Do not use the
--   <tt>Edge</tt> constructor directly; use <a>mkEdge</a> instead.
data Edge

-- | Smart constructor for <tt>Edge</tt>, which puts the vertices in a
--   canonical order.
mkEdge :: Q2 -> Q2 -> Edge

-- | A polygon is represented by a list of its vertices, in
--   counterclockwise order. However, the <tt>Eq</tt> and <tt>Ord</tt>
--   instances for polygons ignore the order.
newtype Polygon
Polygon :: [Q2] -> Polygon
[polygonVertices] :: Polygon -> [Q2]

-- | The state maintained while generating a tiling, recording which
--   vertices have been visited and which edges and polygons have been
--   drawn.
data TilingState
TP :: Set Q2 -> Set Edge -> Set Polygon -> TilingState
[visitedVertices] :: TilingState -> Set Q2
[visitedEdges] :: TilingState -> Set Edge
[visitedPolygons] :: TilingState -> Set Polygon
initTilingState :: TilingState

-- | The <tt>TilingM</tt> monad tracks a <tt>TilingState</tt>, and can
--   output elements of some monoid <tt>w</tt> along the way.
type TilingM w a = WriterT w (State TilingState) a
generateTiling :: forall w. Monoid w => Tiling -> Q2 -> Q2 -> (Q2 -> Bool) -> (Edge -> w) -> (Polygon -> w) -> w

t3 :: Tiling

t4 :: Tiling

t6 :: Tiling

-- | Create a tiling with the same 3 polygons surrounding each vertex. The
--   argument is the number of sides of the polygons surrounding a vertex.
mk3Tiling :: [Int] -> Tiling

t4612 :: Tiling

t488 :: Tiling

t31212 :: Tiling

t3636 :: Tiling

-- | Create a tiling where every vertex is the same up to rotation and
--   translation (but <i>not</i> reflection). Arbitrarily pick one of the
--   edges emanating from a vertex and number the edges counterclockwise
--   starting with 0 for the chosen edge.
semiregular :: [Int] -> [Int] -> Tiling
rot :: (Num a, Eq a) => a -> [t] -> [t]

t3464 :: Tiling

t33434 :: Tiling

t33344 :: Tiling

t33336L :: Tiling

t33336R :: Tiling

-- | Draw an edge with the given style.
drawEdge :: (Renderable (Path V2 n) b, TypeableFloat n) => Style V2 n -> Edge -> QDiagram b V2 n Any

-- | Draw a polygon with the given style.
drawPoly :: (Renderable (Path V2 n) b, TypeableFloat n) => (Polygon -> Style V2 n) -> Polygon -> QDiagram b V2 n Any
polyColor :: (Floating a, Ord a) => TilingPoly -> Colour a

-- | Draw a tiling, with a given width and height and default colors for
--   the polygons.
drawTiling :: (Renderable (Path V2 n) b, TypeableFloat n) => Tiling -> n -> n -> QDiagram b V2 n Any

-- | Draw a tiling with customizable styles for the polygons. This is just
--   an example, which you can use as the basis of your own tiling-drawing
--   routine.
drawTilingStyled :: forall b n. (Renderable (Path V2 n) b, TypeableFloat n) => Style V2 n -> (Polygon -> Style V2 n) -> Tiling -> n -> n -> QDiagram b V2 n Any
instance GHC.Show.Show Diagrams.TwoD.Tilings.Polygon
instance GHC.Show.Show Diagrams.TwoD.Tilings.Edge
instance GHC.Classes.Ord Diagrams.TwoD.Tilings.Edge
instance GHC.Classes.Eq Diagrams.TwoD.Tilings.Edge
instance GHC.Enum.Bounded Diagrams.TwoD.Tilings.TilingPoly
instance GHC.Enum.Enum Diagrams.TwoD.Tilings.TilingPoly
instance GHC.Read.Read Diagrams.TwoD.Tilings.TilingPoly
instance GHC.Show.Show Diagrams.TwoD.Tilings.TilingPoly
instance GHC.Classes.Ord Diagrams.TwoD.Tilings.TilingPoly
instance GHC.Classes.Eq Diagrams.TwoD.Tilings.TilingPoly
instance GHC.Read.Read Diagrams.TwoD.Tilings.Q236
instance GHC.Show.Show Diagrams.TwoD.Tilings.Q236
instance GHC.Classes.Ord Diagrams.TwoD.Tilings.Q236
instance GHC.Classes.Eq Diagrams.TwoD.Tilings.Q236
instance GHC.Classes.Eq Diagrams.TwoD.Tilings.Polygon
instance GHC.Classes.Ord Diagrams.TwoD.Tilings.Polygon
instance GHC.Num.Num Diagrams.TwoD.Tilings.Q236
instance GHC.Real.Fractional Diagrams.TwoD.Tilings.Q236
