-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Common drawing utilities built on wumpus-core. -- -- ** WARNING ** - this package is sub-alpha. It is only on Hackage to -- support other packages (Wumpus-Tree, Wumpus-Microprint) that are -- slighly more stable. -- -- A few of the modules (SafeFonts, SVGColours, X11Colours) are fairly -- stable others simply aren't and may even disappear in subsequent -- updates. -- -- Changelog: -- -- 0.2.0 to 0.3.0 : -- --
-- a `over` b ---- -- Place 'picture' a over b. The idea of over here is the same -- as z-ordering in 2D design programs. Implementations of this class -- should 'draw' picture a over b but move neither. -- -- Similarly beneath should 'draw' the first picture behind the -- second but move neither. -- -- Beneath has a default definition: -- --
-- beneath = flip over --class Composite a over :: (Composite a) => a -> a -> a beneath :: (Composite a) => a -> a -> a -- | Move in both the horizontal and vertical. class Move a move :: (Move a) => PUnit a -> PUnit a -> a -> a -- | Create a picture that has no content but occupies space (i.e. -- it has a bounding box). class Blank a blank :: (Blank a) => PUnit a -> PUnit a -> a -- | The center of a picture. center :: (Horizontal a, Vertical a, Fractional u, u ~ (PUnit a)) => a -> Point2 u -- | Extract the top-left corner. topleft :: (Horizontal a, Vertical a, u ~ (PUnit a)) => a -> Point2 u -- | Extract the top-right corner. topright :: (Horizontal a, Vertical a, u ~ (PUnit a)) => a -> Point2 u -- | Extract the bottom-left corner. bottomleft :: (Horizontal a, Vertical a, u ~ (PUnit a)) => a -> Point2 u -- | Extract the bottom-right corner. bottomright :: (Horizontal a, Vertical a, u ~ (PUnit a)) => a -> Point2 u -- |
-- a -@- b ---- -- Center a on top of b, a is potentially -- moved and drawn over b. (-@-) :: (Horizontal a, Vertical a, Composite a, Move a, Fractional u, u ~ (PUnit a)) => a -> a -> a -- |
-- a ->- b ---- -- Horizontal composition - move b, placing it to the right of -- a. (->-) :: (Horizontal a, Composite a, Num u, u ~ (PUnit a)) => a -> a -> a -- |
-- a -<- b ---- -- Horizontal composition - move a, placing it to the left of -- b. (-<-) :: (Horizontal a, Composite a, Num u, u ~ (PUnit a)) => a -> a -> a -- |
-- a -//- b ---- -- Vertical composition - move b, placing it below a. (-//-) :: (Vertical a, Composite a, Num u, u ~ (PUnit a)) => a -> a -> a -- |
-- a `above` b ---- -- Vertical composition - move a, placing it above b. above :: (Vertical a, Composite a, Num u, u ~ (PUnit a)) => a -> a -> a -- |
-- a `below` b ---- -- Vertical composition - move a, placing it below b below :: (Vertical a, Composite a, Num u, u ~ (PUnit a)) => a -> a -> a -- | Place the picture at the supplied point. at :: (Move a, u ~ (PUnit a)) => a -> Point2 u -> a -- | Center the picture at the supplied point. centeredAt :: (Horizontal a, Vertical a, Move a, Composite a, Blank a, Fractional u, u ~ (PUnit a)) => a -> Point2 u -> a -- |
-- xs `stackOnto` a ---- -- Stack the list of pictures xs over a. -- -- Note, the first picture in the list is drawn at the top, the last -- picture is draw over a. stackOnto :: (Composite a) => [a] -> a -> a -- |
-- x ->- xs ---- -- Concatenate the list pictures xs horizontally with -- (->-) starting at x. hcat :: (Horizontal a, Composite a, Num u, u ~ (PUnit a)) => a -> [a] -> a -- |
-- x -//- xs ---- -- Concatenate the list of pictures xs vertically with -- (-//-) starting at x. vcat :: (Vertical a, Composite a, Num u, u ~ (PUnit a)) => a -> [a] -> a -- | Stack pictures centered ontop of each other - the first picture in the -- list is drawn at the top, last picture is on drawn at the bottom. stackOntoCenter :: (Horizontal a, Vertical a, Composite a, Move a, Fractional u, u ~ (PUnit a)) => [a] -> a -> a -- |
-- hspace n a b ---- -- Concatenate the pictures a and b with -- (->-) - injecting a space of n units to separate -- the pictures. hspace :: (Num u, Composite a, Horizontal a, Blank a, u ~ (PUnit a)) => u -> a -> a -> a -- |
-- vspace n a b ---- -- Concatenate the pictures a and b with -- (-//-) - injecting a space of n units to separate -- the pictures. vspace :: (Num u, Composite a, Vertical a, Blank a, u ~ (PUnit a)) => u -> a -> a -> a -- |
-- hsep n x xs ---- -- Concatenate the list of pictures xs horizontally with -- hspace starting at x. The pictures are interspersed -- with spaces of n units. hsep :: (Num u, Composite a, Horizontal a, Blank a, u ~ (PUnit a)) => u -> a -> [a] -> a -- |
-- vsep n x xs ---- -- Concatenate the list of pictures xs vertically with -- vspace starting at x. The pictures are interspersed -- with spaces of n units. vsep :: (Num u, Composite a, Vertical a, Blank a, u ~ (PUnit a)) => u -> a -> [a] -> a -- |
-- alignH z a b ---- -- Move picture b up or down to be horizontally aligned along a -- line from the top, center or bottom of picture a alignH :: (Fractional u, Composite a, Horizontal a, Vertical a, Move a, u ~ (PUnit a)) => HAlign -> a -> a -> a -- |
-- alignV z a b ---- -- Move picture b left or right to be vertically aligned along a -- line from the left side, center or right side of picture a alignV :: (Fractional u, Composite a, Horizontal a, Vertical a, Move a, u ~ (PUnit a)) => VAlign -> a -> a -> a -- | Variant of hcat that aligns the pictures as well as -- concatenating them. hcatA :: (Fractional u, Horizontal a, Vertical a, Composite a, Move a, u ~ (PUnit a)) => HAlign -> a -> [a] -> a -- | Variant of vcat that aligns the pictures as well as -- concatenating them. vcatA :: (Fractional u, Horizontal a, Vertical a, Composite a, Move a, u ~ (PUnit a)) => VAlign -> a -> [a] -> a -- | Variant of hsep that aligns the pictures as well as -- concatenating and spacing them. hsepA :: (Fractional u, Horizontal a, Vertical a, Composite a, Move a, Blank a, u ~ (PUnit a)) => HAlign -> u -> a -> [a] -> a -- | Variant of vsep that aligns the pictures as well as -- concatenating and spacing them. vsepA :: (Fractional u, Horizontal a, Vertical a, Composite a, Move a, Blank a, u ~ (PUnit a)) => VAlign -> u -> a -> [a] -> a -- | Create multiple lines of text. -- -- The dimension argument is the linespacing, measured as the distance -- between the upper lines descender and the lower lines ascender. -- -- An error is throw if the list of strings is empty multilabel :: (Real u, Floating u, TextLabel t) => t -> u -> VAlign -> [String] -> Point2 u -> Picture u instance Eq VAlign instance Show VAlign instance Eq HAlign instance Show HAlign instance (Num u, Ord u) => Blank (Picture u) instance (Num u, Ord u) => Move (Picture u) instance (Num u, Ord u) => Composite (Picture u) instance (Num u, Ord u) => Vertical (Picture u) instance (Num u, Ord u) => Horizontal (Picture u) -- | Version number module Wumpus.Basic.VersionNumber -- | Version number -- --
-- (0,3,0) --wumpus_basic_version :: (Int, Int, Int) -- | The X11 'named colours', as rgb [0,1] values module Wumpus.Basic.X11Colours antiqueWhite1 :: DRGB antiqueWhite2 :: DRGB antiqueWhite3 :: DRGB antiqueWhite4 :: DRGB aquamarine1 :: DRGB aquamarine2 :: DRGB aquamarine3 :: DRGB aquamarine4 :: DRGB azure1 :: DRGB azure2 :: DRGB azure3 :: DRGB azure4 :: DRGB bisque1 :: DRGB bisque2 :: DRGB bisque3 :: DRGB bisque4 :: DRGB blue1 :: DRGB blue2 :: DRGB blue3 :: DRGB blue4 :: DRGB brown1 :: DRGB brown2 :: DRGB brown3 :: DRGB brown4 :: DRGB burlywood1 :: DRGB burlywood2 :: DRGB burlywood3 :: DRGB burlywood4 :: DRGB cadetBlue1 :: DRGB cadetBlue2 :: DRGB cadetBlue3 :: DRGB cadetBlue4 :: DRGB chartreuse1 :: DRGB chartreuse2 :: DRGB chartreuse3 :: DRGB chartreuse4 :: DRGB chocolate1 :: DRGB chocolate2 :: DRGB chocolate3 :: DRGB chocolate4 :: DRGB coral1 :: DRGB coral2 :: DRGB coral3 :: DRGB coral4 :: DRGB cornsilk1 :: DRGB cornsilk2 :: DRGB cornsilk3 :: DRGB cornsilk4 :: DRGB cyan1 :: DRGB cyan2 :: DRGB cyan3 :: DRGB cyan4 :: DRGB darkGoldenrod1 :: DRGB darkGoldenrod2 :: DRGB darkGoldenrod3 :: DRGB darkGoldenrod4 :: DRGB darkOliveGreen1 :: DRGB darkOliveGreen2 :: DRGB darkOliveGreen3 :: DRGB darkOliveGreen4 :: DRGB darkOrange1 :: DRGB darkOrange2 :: DRGB darkOrange3 :: DRGB darkOrange4 :: DRGB darkOrchid1 :: DRGB darkOrchid2 :: DRGB darkOrchid3 :: DRGB darkOrchid4 :: DRGB darkSeaGreen1 :: DRGB darkSeaGreen2 :: DRGB darkSeaGreen3 :: DRGB darkSeaGreen4 :: DRGB darkSlateGray1 :: DRGB darkSlateGray2 :: DRGB darkSlateGray3 :: DRGB darkSlateGray4 :: DRGB deepPink1 :: DRGB deepPink2 :: DRGB deepPink3 :: DRGB deepPink4 :: DRGB deepSkyBlue1 :: DRGB deepSkyBlue2 :: DRGB deepSkyBlue3 :: DRGB deepSkyBlue4 :: DRGB dodgerBlue1 :: DRGB dodgerBlue2 :: DRGB dodgerBlue3 :: DRGB dodgerBlue4 :: DRGB firebrick1 :: DRGB firebrick2 :: DRGB firebrick3 :: DRGB firebrick4 :: DRGB gold1 :: DRGB gold2 :: DRGB gold3 :: DRGB gold4 :: DRGB goldenrod1 :: DRGB goldenrod2 :: DRGB goldenrod3 :: DRGB goldenrod4 :: DRGB green1 :: DRGB green2 :: DRGB green3 :: DRGB green4 :: DRGB honeydew1 :: DRGB honeydew2 :: DRGB honeydew3 :: DRGB honeydew4 :: DRGB hotPink1 :: DRGB hotPink2 :: DRGB hotPink3 :: DRGB hotPink4 :: DRGB indianRed1 :: DRGB indianRed2 :: DRGB indianRed3 :: DRGB indianRed4 :: DRGB ivory1 :: DRGB ivory2 :: DRGB ivory3 :: DRGB ivory4 :: DRGB khaki1 :: DRGB khaki2 :: DRGB khaki3 :: DRGB khaki4 :: DRGB lavenderBlush1 :: DRGB lavenderBlush2 :: DRGB lavenderBlush3 :: DRGB lavenderBlush4 :: DRGB lemonChiffon1 :: DRGB lemonChiffon2 :: DRGB lemonChiffon3 :: DRGB lemonChiffon4 :: DRGB lightBlue1 :: DRGB lightBlue2 :: DRGB lightBlue3 :: DRGB lightBlue4 :: DRGB lightCyan1 :: DRGB lightCyan2 :: DRGB lightCyan3 :: DRGB lightCyan4 :: DRGB lightGoldenrod1 :: DRGB lightGoldenrod2 :: DRGB lightGoldenrod3 :: DRGB lightGoldenrod4 :: DRGB lightPink1 :: DRGB lightPink2 :: DRGB lightPink3 :: DRGB lightPink4 :: DRGB lightSalmon1 :: DRGB lightSalmon2 :: DRGB lightSalmon3 :: DRGB lightSalmon4 :: DRGB lightSkyBlue1 :: DRGB lightSkyBlue2 :: DRGB lightSkyBlue3 :: DRGB lightSkyBlue4 :: DRGB lightSteelBlue1 :: DRGB lightSteelBlue2 :: DRGB lightSteelBlue3 :: DRGB lightSteelBlue4 :: DRGB lightYellow1 :: DRGB lightYellow2 :: DRGB lightYellow3 :: DRGB lightYellow4 :: DRGB magenta1 :: DRGB magenta2 :: DRGB magenta3 :: DRGB magenta4 :: DRGB maroon1 :: DRGB maroon2 :: DRGB maroon3 :: DRGB maroon4 :: DRGB mediumOrchid1 :: DRGB mediumOrchid2 :: DRGB mediumOrchid3 :: DRGB mediumOrchid4 :: DRGB mediumPurple1 :: DRGB mediumPurple2 :: DRGB mediumPurple3 :: DRGB mediumPurple4 :: DRGB mistyRose1 :: DRGB mistyRose2 :: DRGB mistyRose3 :: DRGB mistyRose4 :: DRGB navajoWhite1 :: DRGB navajoWhite2 :: DRGB navajoWhite3 :: DRGB navajoWhite4 :: DRGB oliveDrab1 :: DRGB oliveDrab2 :: DRGB oliveDrab3 :: DRGB oliveDrab4 :: DRGB orange1 :: DRGB orange2 :: DRGB orange3 :: DRGB orange4 :: DRGB orangeRed1 :: DRGB orangeRed2 :: DRGB orangeRed3 :: DRGB orangeRed4 :: DRGB orchid1 :: DRGB orchid2 :: DRGB orchid3 :: DRGB orchid4 :: DRGB paleGreen1 :: DRGB paleGreen2 :: DRGB paleGreen3 :: DRGB paleGreen4 :: DRGB paleTurquoise1 :: DRGB paleTurquoise2 :: DRGB paleTurquoise3 :: DRGB paleTurquoise4 :: DRGB paleVioletRed1 :: DRGB paleVioletRed2 :: DRGB paleVioletRed3 :: DRGB paleVioletRed4 :: DRGB peachPuff1 :: DRGB peachPuff2 :: DRGB peachPuff3 :: DRGB peachPuff4 :: DRGB pink1 :: DRGB pink2 :: DRGB pink3 :: DRGB pink4 :: DRGB plum1 :: DRGB plum2 :: DRGB plum3 :: DRGB plum4 :: DRGB purple1 :: DRGB purple2 :: DRGB purple3 :: DRGB purple4 :: DRGB red1 :: DRGB red2 :: DRGB red3 :: DRGB red4 :: DRGB rosyBrown1 :: DRGB rosyBrown2 :: DRGB rosyBrown3 :: DRGB rosyBrown4 :: DRGB royalBlue1 :: DRGB royalBlue2 :: DRGB royalBlue3 :: DRGB royalBlue4 :: DRGB salmon1 :: DRGB salmon2 :: DRGB salmon3 :: DRGB salmon4 :: DRGB seaGreen1 :: DRGB seaGreen2 :: DRGB seaGreen3 :: DRGB seaGreen4 :: DRGB seashell1 :: DRGB seashell2 :: DRGB seashell3 :: DRGB seashell4 :: DRGB sienna1 :: DRGB sienna2 :: DRGB sienna3 :: DRGB sienna4 :: DRGB skyBlue1 :: DRGB skyBlue2 :: DRGB skyBlue3 :: DRGB skyBlue4 :: DRGB slateBlue1 :: DRGB slateBlue2 :: DRGB slateBlue3 :: DRGB slateBlue4 :: DRGB slateGray1 :: DRGB slateGray2 :: DRGB slateGray3 :: DRGB slateGray4 :: DRGB snow1 :: DRGB snow2 :: DRGB snow3 :: DRGB snow4 :: DRGB springGreen1 :: DRGB springGreen2 :: DRGB springGreen3 :: DRGB springGreen4 :: DRGB steelBlue1 :: DRGB steelBlue2 :: DRGB steelBlue3 :: DRGB steelBlue4 :: DRGB tan1 :: DRGB tan2 :: DRGB tan3 :: DRGB tan4 :: DRGB thistle1 :: DRGB thistle2 :: DRGB thistle3 :: DRGB thistle4 :: DRGB tomato1 :: DRGB tomato2 :: DRGB tomato3 :: DRGB tomato4 :: DRGB turquoise1 :: DRGB turquoise2 :: DRGB turquoise3 :: DRGB turquoise4 :: DRGB violetRed1 :: DRGB violetRed2 :: DRGB violetRed3 :: DRGB violetRed4 :: DRGB wheat1 :: DRGB wheat2 :: DRGB wheat3 :: DRGB wheat4 :: DRGB yellow1 :: DRGB yellow2 :: DRGB yellow3 :: DRGB yellow4 :: DRGB gray0 :: DRGB green0 :: DRGB grey0 :: DRGB maroon0 :: DRGB purple0 :: DRGB -- | Turtle monad and monad transformer. -- -- The Turtle monad embodies the LOGO style of imperative drawing - -- sending commands to update the a cursor. -- -- While Wumpus generally aims for a more compositional, -- "coordinate-free" style of drawing, some types of diagram are more -- easily expressed in the LOGO style. module Wumpus.Basic.Monads.TurtleClass type Coord = (Int, Int) data TurtleConfig u TurtleConfig :: !u -> !u -> TurtleConfig u xstep :: TurtleConfig u -> !u ystep :: TurtleConfig u -> !u regularConfig :: u -> TurtleConfig u class (Monad m) => TurtleM m getLoc :: (TurtleM m) => m (Int, Int) setLoc :: (TurtleM m) => (Int, Int) -> m () getOrigin :: (TurtleM m) => m (Int, Int) setOrigin :: (TurtleM m) => (Int, Int) -> m () class (TurtleM m) => TurtleScaleM m u | m -> u xStep :: (TurtleScaleM m u) => m u yStep :: (TurtleScaleM m u) => m u askSteps :: (TurtleScaleM m u) => m (u, u) setsLoc :: (TurtleM m) => (Coord -> (a, Coord)) -> m a setsLoc_ :: (TurtleM m) => (Coord -> Coord) -> m () resetLoc :: (TurtleM m) => m () moveLeft :: (TurtleM m) => m () moveRight :: (TurtleM m) => m () moveUp :: (TurtleM m) => m () moveDown :: (TurtleM m) => m () nextLine :: (TurtleM m) => m () getPos :: (TurtleScaleM m u, Num u) => m (Point2 u) scaleCoord :: (TurtleScaleM m u, Num u) => (Int, Int) -> m (Point2 u) instance (Eq u) => Eq (TurtleConfig u) instance (Show u) => Show (TurtleConfig u) -- | The SVG 'named colours', as rgb [0,1] values module Wumpus.Basic.SVGColours aliceBlue :: DRGB antiqueWhite :: DRGB aqua :: DRGB aquamarine :: DRGB azure :: DRGB beige :: DRGB bisque :: DRGB black :: DRGB blanchedAlmond :: DRGB blue :: DRGB blueViolet :: DRGB brown :: DRGB burlywood :: DRGB cadetBlue :: DRGB chartreuse :: DRGB chocolate :: DRGB coral :: DRGB cornflowerBlue :: DRGB cornsilk :: DRGB crimson :: DRGB cyan :: DRGB darkBlue :: DRGB darkCyan :: DRGB darkGoldenrod :: DRGB darkGray :: DRGB darkGreen :: DRGB darkGrey :: DRGB darkKhaki :: DRGB darkMagenta :: DRGB darkOliveGreen :: DRGB darkOrange :: DRGB darkOrchid :: DRGB darkRed :: DRGB darkSalmon :: DRGB darkSeaGreen :: DRGB darkSlateBlue :: DRGB darkSlateGray :: DRGB darkSlateGrey :: DRGB darkTurquoise :: DRGB darkViolet :: DRGB deepPink :: DRGB deepSkyBlue :: DRGB dimGray :: DRGB dimGrey :: DRGB dodgerBlue :: DRGB firebrick :: DRGB floralWhite :: DRGB forestGreen :: DRGB fuchsia :: DRGB gainsboro :: DRGB ghostWhite :: DRGB gold :: DRGB goldenrod :: DRGB gray :: DRGB grey :: DRGB green :: DRGB greenYellow :: DRGB honeydew :: DRGB hotPink :: DRGB indianRed :: DRGB indigo :: DRGB ivory :: DRGB khaki :: DRGB lavender :: DRGB lavenderBlush :: DRGB lawnGreen :: DRGB lemonChiffon :: DRGB lightBlue :: DRGB lightCoral :: DRGB lightCyan :: DRGB lightGoldenrodYellow :: DRGB lightGray :: DRGB lightGreen :: DRGB lightGrey :: DRGB lightPink :: DRGB lightSalmon :: DRGB lightSeaGreen :: DRGB lightSkyBlue :: DRGB lightSlateGray :: DRGB lightSlateGrey :: DRGB lightSteelBlue :: DRGB lightYellow :: DRGB lime :: DRGB limeGreen :: DRGB linen :: DRGB magenta :: DRGB maroon :: DRGB mediumAquamarine :: DRGB mediumBlue :: DRGB mediumOrchid :: DRGB mediumPurple :: DRGB mediumSeaGreen :: DRGB mediumSlateBlue :: DRGB mediumSpringGreen :: DRGB mediumTurquoise :: DRGB mediumVioletRed :: DRGB midnightBlue :: DRGB mintcream :: DRGB mistyrose :: DRGB moccasin :: DRGB navajoWhite :: DRGB navy :: DRGB oldlace :: DRGB olive :: DRGB oliveDrab :: DRGB orange :: DRGB orangeRed :: DRGB orchid :: DRGB paleGoldenrod :: DRGB paleGreen :: DRGB paleTurquoise :: DRGB paleVioletRed :: DRGB papayawhip :: DRGB peachpuff :: DRGB peru :: DRGB pink :: DRGB plum :: DRGB powderBlue :: DRGB purple :: DRGB red :: DRGB rosyBrown :: DRGB royalBlue :: DRGB saddleBrown :: DRGB salmon :: DRGB sandyBrown :: DRGB seaGreen :: DRGB seashell :: DRGB sienna :: DRGB silver :: DRGB skyBlue :: DRGB slateBlue :: DRGB slateGray :: DRGB slateGrey :: DRGB snow :: DRGB springGreen :: DRGB steelBlue :: DRGB tan :: DRGB teal :: DRGB thistle :: DRGB tomato :: DRGB turquoise :: DRGB violet :: DRGB wheat :: DRGB white :: DRGB whitesmoke :: DRGB yellow :: DRGB yellowGreen :: DRGB -- | Safe to use fonts. module Wumpus.Basic.SafeFonts timesRoman :: Int -> FontAttr timesItalic :: Int -> FontAttr timesBold :: Int -> FontAttr timesBoldItalic :: Int -> FontAttr helvetica :: Int -> FontAttr helveticaOblique :: Int -> FontAttr helveticaBold :: Int -> FontAttr helveticaBoldOblique :: Int -> FontAttr courier :: Int -> FontAttr courierOblique :: Int -> FontAttr courierBold :: Int -> FontAttr courierBoldOblique :: Int -> FontAttr symbol :: Int -> FontAttr -- | Hughes list, ... module Wumpus.Basic.Utils.HList type H a = [a] -> [a] emptyH :: H a wrapH :: a -> H a consH :: a -> H a -> H a snocH :: H a -> a -> H a appendH :: H a -> H a -> H a unfoldrH :: (b -> Maybe (a, b)) -> b -> H a -- | velo consumes the list as per map, but builds it back as a Hughes list -- - so items can be dropped replaced, repeated, etc... veloH :: (a -> H b) -> [a] -> H b concatH :: [H a] -> H a toListH :: H a -> [a] fromListH :: [a] -> H a -- | ** WARNING ** - function names likely to change. module Wumpus.Basic.Graphic.PointSupply two_pi :: Radian half_pi :: Radian -- | polygonPointsV : num_points * radius * center -> -- [point] polygonPointsV :: (Floating u) => Int -> u -> Point2 u -> [Point2 u] -- | hpoints : ypos * step * (x0,x1) -> [point] -- -- Generate points in a horizontal line between x0 and x1. -- -- Note - the step increment is w.r.t. 0 rather than x0. x0 and x1 are -- just the range. An example: -- --
-- hpoints 0 10 (5,35) ---- --
-- [P2 10 0, P2 20 0, P2 30 0] --hpoints :: (RealFrac u) => u -> u -> (u, u) -> [Point2 u] -- | vpoints : xpos * step * (y0,y1) -> [point] -- -- Generate points in a vertical line between y0 and y1. -- -- Note - the step increment is w.r.t. 0 rather than y0. y0 and y1 are -- just the range. An example: -- --
-- vpoints 5 100 (50,500) ---- --
-- [P2 5 100, P2 5 200, P2 5 300, P2 5 400] --vpoints :: (RealFrac u) => u -> u -> (u, u) -> [Point2 u] -- | Drawing attributes module Wumpus.Basic.Graphic.DrawingAttr data DrawingAttr DrawingAttr :: Double -> FontAttr -> DRGB -> DRGB -> DrawingAttr line_width :: DrawingAttr -> Double font_props :: DrawingAttr -> FontAttr stroke_colour :: DrawingAttr -> DRGB fill_colour :: DrawingAttr -> DRGB standardAttr :: FontSize -> DrawingAttr strokeAttr :: DrawingAttr -> (DRGB, StrokeAttr) fillAttr :: DrawingAttr -> DRGB textAttr :: DrawingAttr -> (DRGB, FontAttr) -- | A Mark is consider to be the height of a lowercase letter in the -- current font. markHeight :: (Fractional u) => DrawingAttr -> u -- | textDimensions : text -> DrawingAttr -> (width,height) textDimensions :: (Fractional u) => String -> DrawingAttr -> (u, u) instance Eq DrawingAttr instance Show DrawingAttr -- | Graphic type and opertations -- -- ** WARNING ** - this module is highly experimental, and may change -- significantly or even be dropped from future revisions. module Wumpus.Basic.Graphic -- | Note - this representation allows for zero, one or more Primitives to -- be collected together. type Graphic u = H (Primitive u) type DGraphic = Graphic Double type GraphicF u = Point2 u -> Graphic u type DGraphicF = GraphicF Double -- | Composition operator... -- --
-- cc f g = \x y -> f x (g x y) --cc :: (r1 -> a -> ans) -> (r1 -> r2 -> a) -> r1 -> r2 -> ans -- | Reverse application. supply :: u -> (u -> a) -> a -- | Note - a Picture cannot be empty whereas a Graphic can. Hence this -- function returns via Maybe. drawGraphic :: (Real u, Floating u) => Graphic u -> Maybe (Picture u) -- | Unsafe version of drawGraphic - this function throws an -- error when the graphic is empty. drawGraphicU :: (Real u, Floating u) => Graphic u -> Picture u -- | Lift a Primitive to a Graphic wrapG :: Primitive u -> Graphic u -- | The empty graphic. emptyG :: Graphic u -- | Text should not contain newlines. -- -- Note the supplied point is the 'left-baseline'. textline :: (TextLabel t, Num u) => t -> String -> GraphicF u -- | Vector is applied to the point. straightLine :: (Stroke t, Fractional u) => t -> Vec2 u -> GraphicF u -- | Supplied point is center. strokedRectangle :: (Stroke t, Fractional u) => t -> u -> u -> GraphicF u -- | Supplied point is center. filledRectangle :: (Fill t, Fractional u) => t -> u -> u -> GraphicF u -- | Supplied point is bottom-left. rectanglePath :: (Num u) => u -> u -> Point2 u -> Path u -- | strokedCircle : stroked_props * num_subs * radius -> -- GraphicF -- -- Draw a stroked circle made from Bezier curves. num_subs is -- the number of subdivisions per quadrant. -- -- The result is a HOF (GraphicF :: Point -> Graphic) where the point -- is the center. strokedCircle :: (Stroke t, Floating u) => t -> Int -> u -> GraphicF u -- | filledCircle : fill_props * num_subs * radius -> -- GraphicF -- -- Draw a filled circle made from Bezier curves. num_subs is the -- number of subdivisions per quadrant. -- -- The result is a HOF (GraphicF :: Point -> Graphic) where the point -- is the center. filledCircle :: (Fill t, Floating u) => t -> Int -> u -> GraphicF u -- | disk is drawn with Wumpus-Core's ellipse primitive. -- -- This is a efficient representation of circles using PostScript's -- arc or SVG's circle in the generated output. -- However, stroked-circles do not draw well after non-uniform scaling - -- the line width is scaled as well as the shape. -- -- For stroked circles that can be scaled, consider making the circle -- from Bezier curves. disk :: (Ellipse t, Fractional u) => t -> u -> GraphicF u type Point2T u = Point2 u -> Point2 u type DPoint2T = Point2T Double positionWith :: Point2T u -> (Point2 u -> a) -> (Point2 u -> a) disp :: (Num u) => u -> u -> Point2T u vdisp :: (Num u) => u -> Point2T u hdisp :: (Num u) => u -> Point2T u data Rectangle u Rectangle :: !u -> !u -> Rectangle u rect_width :: Rectangle u -> !u rect_height :: Rectangle u -> !u type DRectangle = Rectangle Double -- | grid : stroke_props * xstep * ystep * boundary_rect -> -- GraphicF -- -- The result is a HOF (GraphicF :: Point -> Graphic) where the point -- is bottom-left. grid :: (Stroke t, RealFrac u) => t -> u -> u -> Rectangle u -> GraphicF u -- | border : stroke_props * boundary_rect -> GraphicF -- -- The result is a HOF (GraphicF :: Point -> Graphic) where the point -- is bottom-left. border :: (Stroke t, Num u) => t -> Rectangle u -> GraphicF u type RectangleLoc u = (Rectangle u, Point2 u) type DRectangleLoc = RectangleLoc Double withinRectangleLoc :: (Num u, Ord u) => Point2 u -> RectangleLoc u -> Bool instance (Eq u) => Eq (Rectangle u) instance (Ord u) => Ord (Rectangle u) instance (Show u) => Show (Rectangle u) -- | Intersection of line to line and line to plane module Wumpus.Basic.Utils.Intersection data LineSegment u LS :: (Point2 u) -> (Point2 u) -> LineSegment u data PointSlope u pointSlope :: (Fractional u) => Point2 u -> Radian -> PointSlope u -- | Line in equational form, i.e. Ax + By + C = 0. data LineEqn u lineEqn :: (Num u) => Point2 u -> Point2 u -> LineEqn u toLineEqn :: (Num u) => PointSlope u -> LineEqn u findIntersect :: (Floating u, Real u, Ord u) => Point2 u -> Radian -> [LineSegment u] -> Maybe (Point2 u) intersection :: (Fractional u, Ord u) => LineSegment u -> LineEqn u -> Maybe (Point2 u) rectangleLines :: (Num u) => Point2 u -> u -> u -> [LineSegment u] instance (Eq u) => Eq (IntersectionResult u) instance (Show u) => Show (IntersectionResult u) instance (Eq u) => Eq (LineEqn u) instance (Show u) => Show (LineEqn u) instance (Eq u) => Eq (PointSlope u) instance (Show u) => Show (PointSlope u) instance (Eq u) => Eq (LineSegment u) instance (Ord u) => Ord (LineSegment u) instance (Show u) => Show (LineSegment u) -- | Tracing class covers both cons and snoc tracing module Wumpus.Basic.Monads.TraceClass class TraceM m i | m -> i trace :: (TraceM m i) => H i -> m () trace1 :: (TraceM m i) => i -> m () -- | Class. module Wumpus.Basic.Monads.DrawingCtxClass data DrawingAttr DrawingAttr :: Double -> FontAttr -> DRGB -> DRGB -> DrawingAttr line_width :: DrawingAttr -> Double font_props :: DrawingAttr -> FontAttr stroke_colour :: DrawingAttr -> DRGB fill_colour :: DrawingAttr -> DRGB standardAttr :: FontSize -> DrawingAttr class (Monad m) => DrawingCtxM m askDrawingCtx :: (DrawingCtxM m) => m DrawingAttr localCtx :: (DrawingCtxM m) => DrawingAttr -> m a -> m a withinModifiedCtx :: (DrawingCtxM m) => (DrawingAttr -> DrawingAttr) -> m a -> m a strokeAttr :: (DrawingCtxM m) => m (DRGB, StrokeAttr) fillAttr :: (DrawingCtxM m) => m DRGB textAttr :: (DrawingCtxM m) => m (DRGB, FontAttr) markHeight :: (Fractional u, DrawingCtxM m) => m u textDimensions :: (Fractional u, DrawingCtxM m) => String -> m (u, u) -- | Reader (enviroment) monad for common drawing attributes. module Wumpus.Basic.Monads.DrawingCtxMonad data DrawingCtx a data DrawingCtxT m a runDrawingCtx :: DrawingAttr -> DrawingCtx a -> a runDrawingCtxT :: (Monad m) => DrawingAttr -> DrawingCtxT m a -> m a instance (TurtleScaleM m u) => TurtleScaleM (DrawingCtxT m) u instance (TurtleM m) => TurtleM (DrawingCtxT m) instance (Monad m, TraceM m i) => TraceM (DrawingCtxT m) i instance (Monad m) => DrawingCtxM (DrawingCtxT m) instance DrawingCtxM DrawingCtx instance MonadT DrawingCtxT instance (Monad m) => Monad (DrawingCtxT m) instance Monad DrawingCtx instance (Monad m) => Applicative (DrawingCtxT m) instance Applicative DrawingCtx instance (Monad m) => Functor (DrawingCtxT m) instance Functor DrawingCtx -- | "Trace" monad and monad transformer. -- -- Trace is operationally similar to the Writer monad but it supports -- elementary consing as well as the Writer's monoidal concatenation. -- -- Note, some care is needed to order the output to a trace with respect -- to the Z-order of a drawing. The API here may well be too limited... module Wumpus.Basic.Monads.TraceMonad data Trace i a data TraceT i m a runTrace :: Trace i a -> (a, H i) runTraceT :: (Monad m) => TraceT i m a -> m (a, H i) instance (TurtleScaleM m u) => TurtleScaleM (TraceT i m) u instance (TurtleM m) => TurtleM (TraceT i m) instance (DrawingCtxM m) => DrawingCtxM (TraceT i m) instance (Monad m) => TraceM (TraceT i m) i instance TraceM (Trace i) i instance MonadT (TraceT i) instance (Monad m) => Monad (TraceT i m) instance Monad (Trace i) instance (Monad m) => Applicative (TraceT i m) instance Applicative (Trace i) instance (Monad m) => Functor (TraceT i m) instance Functor (Trace i) -- | Turtle monad and monad transformer. -- -- The Turtle monad embodies the LOGO style of imperative drawing - -- sending commands to update the a cursor. -- -- While Wumpus generally aims for a more compositional, -- "coordinate-free" style of drawing, some types of diagram are more -- easily expressed in the LOGO style. module Wumpus.Basic.Monads.TurtleMonad data Turtle u a data TurtleT u m a runTurtle :: (Num u) => TurtleConfig u -> (Int, Int) -> Turtle u a -> a runTurtleT :: (Monad m, Num u) => TurtleConfig u -> (Int, Int) -> TurtleT u m a -> m a instance (Monad m, TraceM m i) => TraceM (TurtleT u m) i instance (DrawingCtxM m) => DrawingCtxM (TurtleT u m) instance (Monad m) => TurtleScaleM (TurtleT u m) u instance (Monad m) => TurtleM (TurtleT u m) instance TurtleScaleM (Turtle u) u instance TurtleM (Turtle u) instance MonadT (TurtleT u) instance (Monad m) => Monad (TurtleT u m) instance Monad (Turtle u) instance (Monad m) => Applicative (TurtleT u m) instance Applicative (Turtle u) instance (Monad m) => Functor (TurtleT u m) instance Functor (Turtle u) -- | Snoc tracing monad module Wumpus.Basic.Monads.STraceMonad data STrace i a data STraceT i m a runSTrace :: STrace i a -> (a, H i) runSTraceT :: (Monad m) => STraceT i m a -> m (a, H i) instance (TurtleScaleM m u) => TurtleScaleM (STraceT i m) u instance (TurtleM m) => TurtleM (STraceT i m) instance (DrawingCtxM m) => DrawingCtxM (STraceT i m) instance (Monad m) => TraceM (STraceT i m) i instance TraceM (STrace i) i instance MonadT (STraceT i) instance (Monad m) => Monad (STraceT i m) instance Monad (STrace i) instance (Monad m) => Applicative (STraceT i m) instance Applicative (STrace i) instance (Monad m) => Functor (STraceT i m) instance Functor (STrace i) -- | Drawing operations module Wumpus.Basic.Monads.Drawing type MGraphicF m u a = Point2 u -> m a traceG :: (Monad m, TraceM m (Primitive u)) => GraphicF u -> MGraphicF m u () node :: (TraceM m (Primitive u), TurtleScaleM m u, Num u) => MGraphicF m u a -> m a at :: (Num u, TraceM m (Primitive u), TurtleScaleM m u) => MGraphicF m u a -> (Int, Int) -> m a -- | Trace plus DrawingCtx plus Turtle... module Wumpus.Basic.Monads.ConsDrawing data ConsDrawing u a data ConsDrawingT u m a runConsDrawing :: (Num u) => TurtleConfig u -> (Int, Int) -> DrawingAttr -> ConsDrawing u a -> (a, Graphic u) runConsDrawingT :: (Monad m, Num u) => TurtleConfig u -> (Int, Int) -> DrawingAttr -> ConsDrawingT u m a -> m (a, Graphic u) execConsDrawing :: (Num u) => TurtleConfig u -> (Int, Int) -> DrawingAttr -> ConsDrawing u a -> Graphic u execConsDrawingT :: (Monad m, Num u) => TurtleConfig u -> (Int, Int) -> DrawingAttr -> ConsDrawingT u m a -> m (Graphic u) instance (Monad m) => TraceM (ConsDrawingT u m) (Primitive u) instance TraceM (ConsDrawing u) (Primitive u) instance (Monad m) => DrawingCtxM (ConsDrawingT u m) instance DrawingCtxM (ConsDrawing u) instance (Monad m) => TurtleScaleM (ConsDrawingT u m) u instance (Monad m) => TurtleM (ConsDrawingT u m) instance TurtleScaleM (ConsDrawing u) u instance TurtleM (ConsDrawing u) instance MonadT (ConsDrawingT u) instance (Monad m) => Monad (ConsDrawingT u m) instance Monad (ConsDrawing u) instance (Monad m) => Applicative (ConsDrawingT u m) instance Applicative (ConsDrawing u) instance (Monad m) => Functor (ConsDrawingT u m) instance Functor (ConsDrawing u) -- | STrace plus DrawingCtx plus Turtle... module Wumpus.Basic.Monads.SnocDrawing data SnocDrawing u a data SnocDrawingT u m a runSnocDrawing :: (Num u) => TurtleConfig u -> (Int, Int) -> DrawingAttr -> SnocDrawing u a -> (a, Graphic u) runSnocDrawingT :: (Monad m, Num u) => TurtleConfig u -> (Int, Int) -> DrawingAttr -> SnocDrawingT u m a -> m (a, Graphic u) execSnocDrawing :: (Num u) => TurtleConfig u -> (Int, Int) -> DrawingAttr -> SnocDrawing u a -> Graphic u execSnocDrawingT :: (Monad m, Num u) => TurtleConfig u -> (Int, Int) -> DrawingAttr -> SnocDrawingT u m a -> m (Graphic u) instance (Monad m) => TraceM (SnocDrawingT u m) (Primitive u) instance TraceM (SnocDrawing u) (Primitive u) instance (Monad m) => DrawingCtxM (SnocDrawingT u m) instance DrawingCtxM (SnocDrawing u) instance (Monad m) => TurtleScaleM (SnocDrawingT u m) u instance (Monad m) => TurtleM (SnocDrawingT u m) instance TurtleScaleM (SnocDrawing u) u instance TurtleM (SnocDrawing u) instance MonadT (SnocDrawingT u) instance (Monad m) => Monad (SnocDrawingT u m) instance Monad (SnocDrawing u) instance (Monad m) => Applicative (SnocDrawingT u m) instance Applicative (SnocDrawing u) instance (Monad m) => Functor (SnocDrawingT u m) instance Functor (SnocDrawing u) -- | Dots module Wumpus.Basic.Dots dotChar :: (Fractional u) => Char -> DrawingAttr -> GraphicF u dotText :: (Fractional u) => String -> DrawingAttr -> GraphicF u dotHLine :: (Fractional u) => DrawingAttr -> GraphicF u dotVLine :: (Fractional u) => DrawingAttr -> GraphicF u dotX :: (Fractional u) => DrawingAttr -> GraphicF u dotPlus :: (Fractional u) => DrawingAttr -> GraphicF u dotCross :: (Floating u) => DrawingAttr -> GraphicF u dotDiamond :: (Fractional u) => DrawingAttr -> GraphicF u dotFDiamond :: (Fractional u) => DrawingAttr -> GraphicF u -- | Note disk is filled. dotDisk :: (Fractional u) => DrawingAttr -> GraphicF u dotSquare :: (Fractional u) => DrawingAttr -> GraphicF u dotCircle :: (Fractional u) => DrawingAttr -> GraphicF u dotPentagon :: (Floating u) => DrawingAttr -> GraphicF u dotStar :: (Floating u) => DrawingAttr -> GraphicF u dotAsterisk :: (Floating u) => DrawingAttr -> GraphicF u dotOPlus :: (Fractional u) => DrawingAttr -> GraphicF u dotOCross :: (Floating u) => DrawingAttr -> GraphicF u dotFOCross :: (Floating u) => DrawingAttr -> GraphicF u -- | Anchor points on "shapes". -- --