-- 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 was released to Hackage -- prematurely - designing a higher-level drawing library turns out to be -- much more demanding than designing a low-level one (Wumpus-Core). -- -- A few of the modules (SafeFonts, SVGColours, X11Colours) are fairly -- stable others simply aren't and may even disappear in subsequent -- updates. -- -- Changelog: -- --
    --
  1. 8.0 to 0.9.0:
  2. --
-- -- -- --
    --
  1. 7.0 to 0.8.0:
  2. --
-- -- @package wumpus-basic @version 0.9.0 -- | Composition operators for Pictures. -- -- Note - empty pictures cannot exist in Wumpus hence the list -- functions in this module are always supplied with an initial picture, -- as well as the (possibly empty) list. module Wumpus.Basic.PictureLanguage -- | Horizontal alignment - align to the top, center or bottom. data HAlign HTop :: HAlign HCenter :: HAlign HBottom :: HAlign -- | Vertical alignment - align to the left, center or bottom. data VAlign VLeft :: VAlign VCenter :: VAlign VRight :: VAlign -- | The center of a picture. centerPoint :: (Fractional u) => Picture u -> Point2 u -- |
--   a `over` b
--   
-- -- Place 'picture' a over b. The idea of over here is in terms -- z-ordering, nither picture a or b are actually moved. over :: (Num u, Ord u) => Picture u -> Picture u -> Picture u -- |
--   a `under` b
--   
-- -- Similarly under draws the first picture behind the second but -- move neither. -- -- under was previously beneath. under :: (Num u, Ord u) => Picture u -> Picture u -> Picture u -- | Draw a centered over b - a is moved, b is static. -- --
--   a `centerOver` b 
--   
-- -- centerOver was previously the (-@-) operator. centerOver :: (Fractional u, Ord u) => Picture u -> Picture u -> Picture u -- |
--   a `nextToH` b
--   
-- -- Horizontal composition - move b, placing it to the right of -- a. -- -- nextToH was previously the (->-) operator. nextToH :: (Num u, Ord u) => Picture u -> Picture u -> Picture u -- |
--   a `nextToV` b
--   
-- -- Vertical composition - move b, placing it below a. -- -- nextToV was previously the (--) operator. nextToV :: (Num u, Ord u) => Picture u -> Picture u -> Picture u -- | Place the picture at the supplied point. -- -- atPoint was previous the at operator. atPoint :: (Num u, Ord u) => Picture u -> Point2 u -> Picture u -- | Center the picture at the supplied point. centeredAt :: (Fractional u, Ord u) => Picture u -> Point2 u -> Picture u -- |
--   xs `stackOver` x
--   
-- -- Stack the list of pictures xs over x. -- -- Note, the first picture in the list is drawn at the top, all the -- pictures in the list are drawn 'over' x. No pictures are -- moved -- --
--   [p1,p2,p3] stackOver p4 => [p1,p2,p3,p4]
--   
stackOver :: (Num u, Ord u) => [Picture u] -> Picture u -> Picture u -- |
--   x `zconcat` xs
--   
-- -- Concatenate x over the list of pictures xs. -- -- x is drawn at the top. No pictures are moved. -- --
--   p1 zconcat [p2,p3,p4] => [p1,p2,p3,p4]
--   
zconcat :: (Num u, Ord u) => Picture u -> [Picture u] -> Picture u -- | Concatenate the list pictures xs horizontally with -- nextToH starting at x. hcat :: (Num u, Ord u) => Picture u -> [Picture u] -> Picture u -- | Concatenate the list of pictures xs vertically with -- nextToV starting at x. vcat :: (Num u, Ord u) => Picture u -> [Picture u] -> Picture u -- | 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. stackOverCenter :: (Fractional u, Ord u) => [Picture u] -> Picture u -> Picture u -- |
--   hspace n a b
--   
-- -- Horizontal composition - move b, placing it to the right of -- a with a horizontal gap of n separating the -- pictures. hspace :: (Num u, Ord u) => u -> Picture u -> Picture u -> Picture u -- |
--   vspace n a b
--   
-- -- Vertical composition - move b, placing it below a -- with a vertical gap of n separating the pictures. vspace :: (Num u, Ord u) => u -> Picture u -> Picture u -> Picture u -- |
--   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, Ord u) => u -> Picture u -> [Picture u] -> Picture u -- |
--   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, Ord u) => u -> Picture u -> [Picture u] -> Picture u -- |
--   alignH align a b
--   
-- -- Horizontal composition - move b, placing it to the right of -- a and align it with the top, center or bottom of a. alignH :: (Fractional u, Ord u) => HAlign -> Picture u -> Picture u -> Picture u -- |
--   alignV align a b
--   
-- -- Vertical composition - move b, placing it below a -- and align it with the left, center or right of a. alignV :: (Fractional u, Ord u) => VAlign -> Picture u -> Picture u -> Picture u -- |
--   alignHSep align sep a b
--   
-- -- Spacing version of alignH - move b to the right of a -- separated by sep units, align b according to -- align. alignHSep :: (Fractional u, Ord u) => HAlign -> u -> Picture u -> Picture u -> Picture u -- |
--   alignHSep align sep a b
--   
-- -- Spacing version of alignV - move b below a separated -- by sep units, align b according to align. alignVSep :: (Fractional u, Ord u) => VAlign -> u -> Picture u -> Picture u -> Picture u -- | Variant of hcat that aligns the pictures as well as -- concatenating them. hcatA :: (Fractional u, Ord u) => HAlign -> Picture u -> [Picture u] -> Picture u -- | Variant of vcat that aligns the pictures as well as -- concatenating them. vcatA :: (Fractional u, Ord u) => VAlign -> Picture u -> [Picture u] -> Picture u -- | Variant of hsep that aligns the pictures as well as -- concatenating and spacing them. hsepA :: (Fractional u, Ord u) => HAlign -> u -> Picture u -> [Picture u] -> Picture u -- | Variant of vsep that aligns the pictures as well as -- concatenating and spacing them. vsepA :: (Fractional u, Ord u) => VAlign -> u -> Picture u -> [Picture u] -> Picture u instance Eq VAlign instance Show VAlign instance Eq HAlign instance Show HAlign -- | Version number module Wumpus.Basic.VersionNumber -- | Version number -- --
--   (0,9,0)
--   
wumpus_basic_version :: (Int, Int, Int) -- | Extended path type - more amenable for complex drawings than the type -- in Wumpus-Core. -- -- ** WARNING ** this module is an experiment, and may change -- significantly or even be dropped from future revisions. module Wumpus.Basic.Paths.Base data Path u Path :: u -> Seq (PathSeg u) -> Path u path_length :: Path u -> u path_elements :: Path u -> Seq (PathSeg u) data PathSeg u LineSeg :: u -> (Line u) -> PathSeg u CurveSeg :: u -> (Curve u) -> PathSeg u data Curve u Curve :: Point2 u -> Point2 u -> Point2 u -> Point2 u -> Curve u curve_start :: Curve u -> Point2 u ctrl_point1 :: Curve u -> Point2 u ctrl_point2 :: Curve u -> Point2 u curve_end :: Curve u -> Point2 u data Line u Line :: Point2 u -> Point2 u -> Line u line_start :: Line u -> Point2 u line_end :: Line u -> Point2 u emptyPath :: (Num u) => Path u pline :: (Floating u) => Point2 u -> Point2 u -> PathSeg u pcurve :: (Floating u, Ord u) => Point2 u -> Point2 u -> Point2 u -> Point2 u -> PathSeg u addSegment :: (Num u) => Path u -> PathSeg u -> Path u segmentLength :: PathSeg u -> u segmentStart :: PathSeg u -> Point2 u segmentEnd :: PathSeg u -> Point2 u -- | Turn a BasicPath into an ordinary Path. -- -- An empty path returns Nothing - the path representation in Wumpus-Core -- does not allow empty paths - a path must always have at least start -- point. -- -- Assumes path is properly formed - i.e. end point of one segment is the -- same point as the start point of the next segment. toPrimPath :: Path u -> Maybe (PrimPath u) toPrimPathU :: Path u -> PrimPath u -- | Curve subdivision via de Casteljau's algorithm. subdivide :: (Fractional u) => Curve u -> (Curve u, Curve u) -- | subdivide with an affine weight along the line... subdividet :: (Real u) => u -> Curve u -> (Curve u, Curve u) instance (Eq u) => Eq (Line u) instance (Ord u) => Ord (Line u) instance (Show u) => Show (Line u) instance (Eq u) => Eq (Curve u) instance (Ord u) => Ord (Curve u) instance (Show u) => Show (Curve u) instance (Eq u) => Eq (PathSeg u) instance (Ord u) => Ord (PathSeg u) instance (Show u) => Show (PathSeg u) instance (Eq u) => Eq (Path u) instance (Ord u) => Ord (Path u) instance (Show u) => Show (Path u) -- | Build paths. -- -- ** WARNING ** this module is an experiment, and may change -- significantly or even be dropped from future revisions. module Wumpus.Basic.Paths.Construction data PathM u a runPath :: (Num u) => Point2 u -> PathM u a -> (a, Path u) execPath :: (Num u) => Point2 u -> PathM u a -> Path u lineto :: (Floating u) => Point2 u -> PathM u () rlineto :: (Floating u) => Vec2 u -> PathM u () vline :: (Floating u) => u -> PathM u () hline :: (Floating u) => u -> PathM u () bezierto :: (Floating u, Ord u) => Point2 u -> Point2 u -> Point2 u -> PathM u () curveto :: (Floating u, Ord u) => Radian -> Radian -> Point2 u -> PathM u () verticalHorizontal :: (Floating u) => Point2 u -> PathM u () horizontalVertical :: (Floating u) => Point2 u -> PathM u () instance Monad (PathM u) instance Applicative (PathM u) instance Functor (PathM u) -- | 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. -- -- Note - as turtle drawing with Wumpus is a local effect, there -- is only one instance of TurtleM. Potentially TurtleM will be removed -- and the functions implemented directly. module Wumpus.Basic.Monads.TurtleClass type Coord = (Int, Int) 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 () 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 () -- | Safe to use fonts. module Wumpus.Basic.SafeFonts -- | Times-Roman timesRoman :: FontFace -- | Times Italic timesItalic :: FontFace -- | Times Bold timesBold :: FontFace -- | Times Bold Italic timesBoldItalic :: FontFace -- | Helvetica helvetica :: FontFace -- | Helvetica Oblique helveticaOblique :: FontFace -- | Helvetica Bold helveticaBold :: FontFace -- | Helvetica Bold Oblique helveticaBoldOblique :: FontFace -- | Courier courier :: FontFace -- | Courier Oblique courierOblique :: FontFace -- | Courier Bold courierBold :: FontFace -- | Courier Bold Oblique courierBoldOblique :: FontFace -- | Symbol -- -- Note - Symbol does not appear to be well supported by some SVG -- renders. Seemingly Chrome is fine but Firefox defaults to some serif -- font. symbol :: FontFace -- | 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 -- | The X11 'named colours', as rgb [0,1] values module Wumpus.Basic.Colour.X11Colours antique_white1 :: RGBi antique_white2 :: RGBi antique_white3 :: RGBi antique_white4 :: RGBi aquamarine1 :: RGBi aquamarine2 :: RGBi aquamarine3 :: RGBi aquamarine4 :: RGBi azure1 :: RGBi azure2 :: RGBi azure3 :: RGBi azure4 :: RGBi bisque1 :: RGBi bisque2 :: RGBi bisque3 :: RGBi bisque4 :: RGBi blue1 :: RGBi blue2 :: RGBi blue3 :: RGBi blue4 :: RGBi brown1 :: RGBi brown2 :: RGBi brown3 :: RGBi brown4 :: RGBi burlywood1 :: RGBi burlywood2 :: RGBi burlywood3 :: RGBi burlywood4 :: RGBi cadet_blue1 :: RGBi cadet_blue2 :: RGBi cadet_blue3 :: RGBi cadet_blue4 :: RGBi chartreuse1 :: RGBi chartreuse2 :: RGBi chartreuse3 :: RGBi chartreuse4 :: RGBi chocolate1 :: RGBi chocolate2 :: RGBi chocolate3 :: RGBi chocolate4 :: RGBi coral1 :: RGBi coral2 :: RGBi coral3 :: RGBi coral4 :: RGBi cornsilk1 :: RGBi cornsilk2 :: RGBi cornsilk3 :: RGBi cornsilk4 :: RGBi cyan1 :: RGBi cyan2 :: RGBi cyan3 :: RGBi cyan4 :: RGBi dark_goldenrod1 :: RGBi dark_goldenrod2 :: RGBi dark_goldenrod3 :: RGBi dark_goldenrod4 :: RGBi dark_olive_green1 :: RGBi dark_olive_green2 :: RGBi dark_olive_green3 :: RGBi dark_olive_green4 :: RGBi dark_orange1 :: RGBi dark_orange2 :: RGBi dark_orange3 :: RGBi dark_orange4 :: RGBi dark_orchid1 :: RGBi dark_orchid2 :: RGBi dark_orchid3 :: RGBi dark_orchid4 :: RGBi dark_sea_green1 :: RGBi dark_sea_green2 :: RGBi dark_sea_green3 :: RGBi dark_sea_green4 :: RGBi dark_slate_gray1 :: RGBi dark_slate_gray2 :: RGBi dark_slate_gray3 :: RGBi dark_slate_gray4 :: RGBi deep_pink1 :: RGBi deep_pink2 :: RGBi deep_pink3 :: RGBi deep_pink4 :: RGBi deep_sky_blue1 :: RGBi deep_sky_blue2 :: RGBi deep_sky_blue3 :: RGBi deep_sky_blue4 :: RGBi dodger_blue1 :: RGBi dodger_blue2 :: RGBi dodger_blue3 :: RGBi dodger_blue4 :: RGBi firebrick1 :: RGBi firebrick2 :: RGBi firebrick3 :: RGBi firebrick4 :: RGBi gold1 :: RGBi gold2 :: RGBi gold3 :: RGBi gold4 :: RGBi goldenrod1 :: RGBi goldenrod2 :: RGBi goldenrod3 :: RGBi goldenrod4 :: RGBi green1 :: RGBi green2 :: RGBi green3 :: RGBi green4 :: RGBi honeydew1 :: RGBi honeydew2 :: RGBi honeydew3 :: RGBi honeydew4 :: RGBi hot_pink1 :: RGBi hot_pink2 :: RGBi hot_pink3 :: RGBi hot_pink4 :: RGBi indian_red1 :: RGBi indian_red2 :: RGBi indian_red3 :: RGBi indian_red4 :: RGBi ivory1 :: RGBi ivory2 :: RGBi ivory3 :: RGBi ivory4 :: RGBi khaki1 :: RGBi khaki2 :: RGBi khaki3 :: RGBi khaki4 :: RGBi lavender_blush1 :: RGBi lavender_blush2 :: RGBi lavender_blush3 :: RGBi lavender_blush4 :: RGBi lemon_chiffon1 :: RGBi lemon_chiffon2 :: RGBi lemon_chiffon3 :: RGBi lemon_chiffon4 :: RGBi light_blue1 :: RGBi light_blue2 :: RGBi light_blue3 :: RGBi light_blue4 :: RGBi light_cyan1 :: RGBi light_cyan2 :: RGBi light_cyan3 :: RGBi light_cyan4 :: RGBi light_goldenrod1 :: RGBi light_goldenrod2 :: RGBi light_goldenrod3 :: RGBi light_goldenrod4 :: RGBi light_pink1 :: RGBi light_pink2 :: RGBi light_pink3 :: RGBi light_pink4 :: RGBi light_salmon1 :: RGBi light_salmon2 :: RGBi light_salmon3 :: RGBi light_salmon4 :: RGBi light_sky_blue1 :: RGBi light_sky_blue2 :: RGBi light_sky_blue3 :: RGBi light_sky_blue4 :: RGBi light_steel_blue1 :: RGBi light_steel_blue2 :: RGBi light_steel_blue3 :: RGBi light_steel_blue4 :: RGBi light_yellow1 :: RGBi light_yellow2 :: RGBi light_yellow3 :: RGBi light_yellow4 :: RGBi magenta1 :: RGBi magenta2 :: RGBi magenta3 :: RGBi magenta4 :: RGBi maroon1 :: RGBi maroon2 :: RGBi maroon3 :: RGBi maroon4 :: RGBi medium_orchid1 :: RGBi medium_orchid2 :: RGBi medium_orchid3 :: RGBi medium_orchid4 :: RGBi medium_purple1 :: RGBi medium_purple2 :: RGBi medium_purple3 :: RGBi medium_purple4 :: RGBi misty_rose1 :: RGBi misty_rose2 :: RGBi misty_rose3 :: RGBi misty_rose4 :: RGBi navajo_white1 :: RGBi navajo_white2 :: RGBi navajo_white3 :: RGBi navajo_white4 :: RGBi olive_drab1 :: RGBi olive_drab2 :: RGBi olive_drab3 :: RGBi olive_drab4 :: RGBi orange1 :: RGBi orange2 :: RGBi orange3 :: RGBi orange4 :: RGBi orange_red1 :: RGBi orange_red2 :: RGBi orange_red3 :: RGBi orange_red4 :: RGBi orchid1 :: RGBi orchid2 :: RGBi orchid3 :: RGBi orchid4 :: RGBi pale_green1 :: RGBi pale_green2 :: RGBi pale_green3 :: RGBi pale_green4 :: RGBi pale_turquoise1 :: RGBi pale_turquoise2 :: RGBi pale_turquoise3 :: RGBi pale_turquoise4 :: RGBi pale_violet_red1 :: RGBi pale_violet_red2 :: RGBi pale_violet_red3 :: RGBi pale_violet_red4 :: RGBi peach_puff1 :: RGBi peach_puff2 :: RGBi peach_puff3 :: RGBi peach_puff4 :: RGBi pink1 :: RGBi pink2 :: RGBi pink3 :: RGBi pink4 :: RGBi plum1 :: RGBi plum2 :: RGBi plum3 :: RGBi plum4 :: RGBi purple1 :: RGBi purple2 :: RGBi purple3 :: RGBi purple4 :: RGBi red1 :: RGBi red2 :: RGBi red3 :: RGBi red4 :: RGBi rosy_brown1 :: RGBi rosy_brown2 :: RGBi rosy_brown3 :: RGBi rosy_brown4 :: RGBi royal_blue1 :: RGBi royal_blue2 :: RGBi royal_blue3 :: RGBi royal_blue4 :: RGBi salmon1 :: RGBi salmon2 :: RGBi salmon3 :: RGBi salmon4 :: RGBi sea_green1 :: RGBi sea_green2 :: RGBi sea_green3 :: RGBi sea_green4 :: RGBi seashell1 :: RGBi seashell2 :: RGBi seashell3 :: RGBi seashell4 :: RGBi sienna1 :: RGBi sienna2 :: RGBi sienna3 :: RGBi sienna4 :: RGBi sky_blue1 :: RGBi sky_blue2 :: RGBi sky_blue3 :: RGBi sky_blue4 :: RGBi slate_blue1 :: RGBi slate_blue2 :: RGBi slate_blue3 :: RGBi slate_blue4 :: RGBi slate_gray1 :: RGBi slate_gray2 :: RGBi slate_gray3 :: RGBi slate_gray4 :: RGBi snow1 :: RGBi snow2 :: RGBi snow3 :: RGBi snow4 :: RGBi spring_green1 :: RGBi spring_green2 :: RGBi spring_green3 :: RGBi spring_green4 :: RGBi steel_blue1 :: RGBi steel_blue2 :: RGBi steel_blue3 :: RGBi steel_blue4 :: RGBi tan1 :: RGBi tan2 :: RGBi tan3 :: RGBi tan4 :: RGBi thistle1 :: RGBi thistle2 :: RGBi thistle3 :: RGBi thistle4 :: RGBi tomato1 :: RGBi tomato2 :: RGBi tomato3 :: RGBi tomato4 :: RGBi turquoise1 :: RGBi turquoise2 :: RGBi turquoise3 :: RGBi turquoise4 :: RGBi violet_red1 :: RGBi violet_red2 :: RGBi violet_red3 :: RGBi violet_red4 :: RGBi wheat1 :: RGBi wheat2 :: RGBi wheat3 :: RGBi wheat4 :: RGBi yellow1 :: RGBi yellow2 :: RGBi yellow3 :: RGBi yellow4 :: RGBi -- | The SVG 'named colours', as rgb [0,1] values module Wumpus.Basic.Colour.SVGColours alice_blue :: RGBi antique_white :: RGBi aqua :: RGBi aquamarine :: RGBi azure :: RGBi beige :: RGBi bisque :: RGBi black :: RGBi blanched_almond :: RGBi blue :: RGBi blue_violet :: RGBi brown :: RGBi burlywood :: RGBi cadet_blue :: RGBi chartreuse :: RGBi chocolate :: RGBi coral :: RGBi cornflower_blue :: RGBi cornsilk :: RGBi crimson :: RGBi cyan :: RGBi dark_blue :: RGBi dark_cyan :: RGBi dark_goldenrod :: RGBi dark_gray :: RGBi dark_green :: RGBi dark_grey :: RGBi dark_khaki :: RGBi dark_magenta :: RGBi dark_olive_green :: RGBi dark_orange :: RGBi dark_orchid :: RGBi dark_red :: RGBi dark_salmon :: RGBi dark_sea_green :: RGBi dark_slate_blue :: RGBi dark_slate_gray :: RGBi dark_slate_grey :: RGBi dark_turquoise :: RGBi dark_violet :: RGBi deep_pink :: RGBi deep_sky_blue :: RGBi dim_gray :: RGBi dim_grey :: RGBi dodger_blue :: RGBi firebrick :: RGBi floral_white :: RGBi forest_green :: RGBi fuchsia :: RGBi gainsboro :: RGBi ghost_white :: RGBi gold :: RGBi goldenrod :: RGBi gray :: RGBi grey :: RGBi green :: RGBi green_yellow :: RGBi honeydew :: RGBi hot_pink :: RGBi indian_red :: RGBi indigo :: RGBi ivory :: RGBi khaki :: RGBi lavender :: RGBi lavender_blush :: RGBi lawn_green :: RGBi lemon_chiffon :: RGBi light_blue :: RGBi light_coral :: RGBi light_cyan :: RGBi light_goldenrod_yellow :: RGBi light_gray :: RGBi light_green :: RGBi light_grey :: RGBi light_pink :: RGBi light_salmon :: RGBi light_sea_green :: RGBi light_sky_blue :: RGBi light_slate_gray :: RGBi light_slate_grey :: RGBi light_steel_blue :: RGBi light_yellow :: RGBi lime :: RGBi lime_green :: RGBi linen :: RGBi magenta :: RGBi maroon :: RGBi medium_aquamarine :: RGBi medium_blue :: RGBi medium_orchid :: RGBi medium_purple :: RGBi medium_sea_green :: RGBi medium_slate_blue :: RGBi medium_spring_green :: RGBi medium_turquoise :: RGBi medium_violet_red :: RGBi midnight_blue :: RGBi mintcream :: RGBi mistyrose :: RGBi moccasin :: RGBi navajo_white :: RGBi navy :: RGBi old_lace :: RGBi olive :: RGBi olive_drab :: RGBi orange :: RGBi orange_red :: RGBi orchid :: RGBi pale_goldenrod :: RGBi pale_green :: RGBi pale_turquoise :: RGBi pale_violet_red :: RGBi papaya_whip :: RGBi peach_puff :: RGBi peru :: RGBi pink :: RGBi plum :: RGBi powder_blue :: RGBi purple :: RGBi red :: RGBi rosy_brown :: RGBi royal_blue :: RGBi saddle_brown :: RGBi salmon :: RGBi sandy_brown :: RGBi sea_green :: RGBi seashell :: RGBi sienna :: RGBi silver :: RGBi sky_blue :: RGBi slate_blue :: RGBi slate_gray :: RGBi slate_grey :: RGBi snow :: RGBi spring_green :: RGBi steel_blue :: RGBi tan :: RGBi teal :: RGBi thistle :: RGBi tomato :: RGBi turquoise :: RGBi violet :: RGBi wheat :: RGBi white :: RGBi whitesmoke :: RGBi yellow :: RGBi yellow_green :: RGBi -- | Drawing attributes -- -- ** WARNING ** - this module needs systematic naming schemes both for -- update functions (primaryColour, ...) and for synthesized selectors -- (e.g. lowerxHeight). The current names will change. module Wumpus.Basic.Graphic.DrawingContext data DrawingContext DrawingContext :: StrokeAttr -> FontAttr -> RGBi -> RGBi -> Double -> DrawingContext stroke_props :: DrawingContext -> StrokeAttr font_props :: DrawingContext -> FontAttr primary_colour :: DrawingContext -> RGBi secondary_colour :: DrawingContext -> RGBi line_spacing_factor :: DrawingContext -> Double standardContext :: FontSize -> DrawingContext -- | Set the line width to a thick. -- -- Note this context update is oblivious - operationally the line -- width is set to exactly 2.0. thick :: DrawingContext -> DrawingContext ultrathick :: DrawingContext -> DrawingContext thin :: DrawingContext -> DrawingContext dashPattern :: DashPattern -> DrawingContext -> DrawingContext unit_dash_pattern :: DashPattern phase :: Int -> DashPattern -> DashPattern dphase :: Int -> DashPattern -> DashPattern doublegaps :: DashPattern -> DashPattern doubledashes :: DashPattern -> DashPattern fontsize :: Int -> DrawingContext -> DrawingContext fontface :: FontFace -> DrawingContext -> DrawingContext -- | Set the font size to double the current size, note the font size also -- controls the size of dots, arrowsheads etc. doublesize :: DrawingContext -> DrawingContext -- | Set the font size to half the current size, note the font size also -- controls the size of dots, arrowsheads etc. -- -- As fontsize is an integer this is not exact - half size of 15pt type -- is 7pt. halfsize :: DrawingContext -> DrawingContext swapColours :: DrawingContext -> DrawingContext bothPrimary :: DrawingContext -> DrawingContext bothSecondary :: DrawingContext -> DrawingContext primaryColour :: RGBi -> DrawingContext -> DrawingContext secondaryColour :: RGBi -> DrawingContext -> DrawingContext instance Eq DrawingContext instance Show DrawingContext -- | Base types for Drawing Objects, Graphics / Images (a Graphic that also -- returns an answer), etc. -- -- ** WARNING ** - some names are expected to change particularly the -- naming of the append and concat functions. module Wumpus.Basic.Graphic.BaseTypes -- | Graphics objects, even simple ones (line, arrow, dot) might need more -- than one primitive (path or text label) for their construction. Hence, -- the primary representation that all the others are built upon must -- support concatenation of primitives. -- -- Wumpus-Core has a type Picture - made from one or more Primitives - -- but Pictures include support for affine frames. For drawing many -- simple graphics (dots, connector lines...) that do not need individual -- affine transformations this is a penalty. A list of Primitives is -- therefore more suitable representation, and a Hughes list which -- supports efficient concatenation is wise. data HPrim u hprimToList :: HPrim u -> [PrimElement u] singleH :: PrimElement u -> HPrim u -- | Point transformation function. type Point2F u = Point2 u -> Point2 u type DPoint2F = Point2F Double -- | Drawings in Wumpus-Basic have an implicit graphics state the -- DrawingContext, the most primitive building block is a -- function from the DrawingContext to some polymorphic answer. -- -- This functional type is represented concretely as DrawingF. -- --
--   DrawingF :: DrawingContext -> a 
--   
data DrawingF a type LocDrawingF u a = Point2 u -> DrawingF a type DLocDrawingF a = LocDrawingF Double a -- | Run a Drawing Function with the supplied Drawing -- Context. runDF :: DrawingContext -> DrawingF a -> a -- | Wrap a value into a DrawingF. -- -- Note the value is pure it does depend on the DrawingContext (it -- is context free). pureDF :: a -> DrawingF a askDF :: DrawingF DrawingContext asksDF :: (DrawingContext -> a) -> DrawingF a localDF :: (DrawingContext -> DrawingContext) -> DrawingF a -> DrawingF a type Graphic u = DrawingF (HPrim u) type DGraphic = Graphic Double runGraphic :: DrawingContext -> Graphic u -> HPrim u xlinkGraphic :: XLink -> Graphic u -> Graphic u -- | Commonly graphics take a start point as well as a drawing context. -- -- Here they are called a LocGraphic - graphic with a (starting) -- location. type LocGraphic u = Point2 u -> Graphic u type DLocGraphic = LocGraphic Double localLG :: (DrawingContext -> DrawingContext) -> LocGraphic u -> LocGraphic u -- | Composition operator for LocGraphic - both LocGraphics are drawn at -- the same origin and the results concatenated. lgappend :: LocGraphic u -> LocGraphic u -> LocGraphic u -- | Images return a value as well as drawing. A node is a typical -- example - nodes are drawing but the also support taking anchor points. type Image u a = DrawingF (a, HPrim u) type DImage a = Image Double a type LocImage u a = Point2 u -> Image u a type DLocImage a = LocImage Double a runImage :: DrawingContext -> Image u a -> (a, HPrim u) intoImage :: DrawingF a -> Graphic u -> Image u a intoLocImage :: LocDrawingF u a -> LocGraphic u -> LocImage u a xlinkImage :: XLink -> Image u a -> Image u a type ConnDrawingF u a = Point2 u -> Point2 u -> DrawingF a type DConnDrawingF a = ConnDrawingF Double a -- | ConnGraphic is a connector drawn between two points contructing a -- Graphic. type ConnGraphic u = Point2 u -> Point2 u -> Graphic u type DConnGraphic = ConnGraphic Double -- | ConImage is a connector drawn between two points constructing an -- Image. type ConnImage u a = Point2 u -> Point2 u -> Image u a type DConnImage a = ConnImage Double a intoConnImage :: ConnDrawingF u a -> ConnGraphic u -> ConnImage u a instance Monad DrawingF instance Applicative DrawingF instance (Monoid a) => Monoid (DrawingF a) instance Functor DrawingF instance Monoid (HPrim u) -- | Base classes and type families. -- -- Drawing is always built on TraceM and DrawingCtxM, it may use -- PointSupplyM for chains or turtle drawing. module Wumpus.Basic.Graphic.BaseClasses -- | Collect elementary graphics as part of a larger drawing. -- -- TraceM works much like a writer monad. class (Monad m) => TraceM m :: (* -> *) trace :: (TraceM m) => HPrim (MonUnit m) -> m () class (Monad m) => DrawingCtxM m :: (* -> *) askCtx :: (DrawingCtxM m) => m DrawingContext localCtx :: (DrawingCtxM m) => (DrawingContext -> DrawingContext) -> m a -> m a -- | Project a value out of a context. asksCtx :: (DrawingCtxM m) => (DrawingContext -> a) -> m a -- | Scaling... class ScalingM m where { type family XDim m :: *; type family YDim m :: *; } scaleX :: (ScalingM m, u ~ (MonUnit m), ux ~ (XDim m)) => ux -> m u scaleY :: (ScalingM m, u ~ (MonUnit m), uy ~ (YDim m)) => uy -> m u scalePt :: (ScalingM m, u ~ (MonUnit m), ux ~ (XDim m), uy ~ (YDim m)) => ux -> uy -> m (Point2 u) scaleVec :: (ScalingM m, u ~ (MonUnit m), ux ~ (XDim m), uy ~ (YDim m)) => ux -> uy -> m (Vec2 u) -- | A monad that supplies points, e.g. a turtle monad. class (Monad m) => PointSupplyM m :: (* -> *) position :: (PointSupplyM m, u ~ (MonUnit m)) => m (Point2 u) -- | Scaling in X and Y module Wumpus.Basic.Graphic.ScalingContext data ScalingContext ux uy u ScalingContext :: (ux -> u) -> (uy -> u) -> ScalingContext ux uy u scale_in_x :: ScalingContext ux uy u -> ux -> u scale_in_y :: ScalingContext ux uy u -> uy -> u data Scaling ux uy u a runScaling :: ScalingContext ux uy u -> Scaling ux uy u a -> a data ScalingT ux uy u m a runScalingT :: ScalingContext ux uy u -> ScalingT ux uy u m a -> m a regularScalingContext :: (Num u) => u -> ScalingContext u u u coordinateScalingContext :: (Num u) => u -> u -> ScalingContext Int Int u unitX :: (ScalingM m, Num ux, ux ~ (XDim m), u ~ (MonUnit m)) => m u unitY :: (ScalingM m, Num uy, uy ~ (YDim m), u ~ (MonUnit m)) => m u instance (u ~ MonUnit m, Monad m, TraceM m) => TraceM (ScalingT ux uy u m) instance (DrawingCtxM m) => DrawingCtxM (ScalingT ux uy u m) instance (Monad m) => ScalingM (ScalingT ux uy u m) instance (Monad m) => Monad (ScalingT ux uy u m) instance (Monad m) => Applicative (ScalingT ux uy u m) instance (Monad m) => Functor (ScalingT ux uy u m) instance ScalingM (Scaling ux uy u) instance Monad (Scaling ux uy u) instance Applicative (Scaling ux uy u) instance Functor (Scaling ux uy u) -- | Drawing with trace - a Writer like monad collecting -- intermediate graphics - and drawing context - a reader monad of -- attributes - font_face, fill_colour etc. module Wumpus.Basic.Graphic.Drawing data Drawing u a data DrawingT u m a runDrawing :: DrawingContext -> Drawing u a -> (a, HPrim u) execDrawing :: DrawingContext -> Drawing u a -> HPrim u runDrawingT :: (Monad m) => DrawingContext -> DrawingT u m a -> m (a, HPrim u) execDrawingT :: (Monad m) => DrawingContext -> DrawingT u m a -> m (HPrim u) -- | Run the Drawing generating a Picture within a "font delta -- context" using the font-family and font-size from the intial -- DrawingContext. -- -- Using a font delta context can reduce the code size of the -- generated SVG file (PostScript ignores the FDC). runFdcDrawing :: (Real u, Floating u, FromPtSize u) => DrawingContext -> Drawing u a -> (a, Maybe (Picture u)) -- | exec version of runFdcContext. execFdcDrawing :: (Real u, Floating u, FromPtSize u) => DrawingContext -> Drawing u a -> Maybe (Picture u) -- | Transformer version of runFdcDrawing. runFdcDrawingT :: (Real u, Floating u, FromPtSize u, Monad m) => DrawingContext -> DrawingT u m a -> m (a, Maybe (Picture u)) -- | Transformer version of execFdcDrawing. execFdcDrawingT :: (Real u, Floating u, FromPtSize u, Monad m) => DrawingContext -> DrawingT u m a -> m (Maybe (Picture u)) -- | Unsafe promotion of HPrim to Picture. -- -- If the HPrim is empty, a run-time error is thrown. liftToPictureU :: (Real u, Floating u, FromPtSize u) => HPrim u -> Picture u -- | Safe promotion of HPrim to (Maybe Picture). -- -- If the HPrim is empty, then Nothing is returned. liftToPictureMb :: (Real u, Floating u, FromPtSize u) => HPrim u -> Maybe (Picture u) -- | Unsafe promotion of (Maybe Picture) to -- Picture. -- -- This is equivalent to: -- --
--   fromMaybe (error "empty") $ pic
--   
-- -- This function is solely a convenience, using it saves one import and a -- few characters. -- -- If the supplied value is Nothing a run-time error is thrown. mbPictureU :: (Real u, Floating u, FromPtSize u) => Maybe (Picture u) -> Picture u -- | Draw a Graphic taking the drawing style from the drawing -- context. -- -- This operation is analogeous to tell in a Writer monad. draw :: (TraceM m, DrawingCtxM m, u ~ (MonUnit m)) => Graphic u -> m () -- | Hyperlink version of draw. xdraw :: (TraceM m, DrawingCtxM m, u ~ (MonUnit m)) => XLink -> Graphic u -> m () -- | Draw an Image taking the drawing style from the drawing -- context. -- -- The graphic representation of the Image is drawn in the Trace monad, -- and the result is returned. drawi :: (TraceM m, DrawingCtxM m, u ~ (MonUnit m)) => Image u a -> m a -- | Hyperlink version of drawi. xdrawi :: (TraceM m, DrawingCtxM m, u ~ (MonUnit m)) => XLink -> Image u a -> m a at :: LocGraphic u -> Point2 u -> Graphic u ati :: LocImage u a -> Point2 u -> Image u a conn :: ConnImage u a -> Point2 u -> LocImage u a node :: (TraceM m, DrawingCtxM m, PointSupplyM m, u ~ (MonUnit m)) => LocGraphic u -> m () nodei :: (TraceM m, DrawingCtxM m, PointSupplyM m, u ~ (MonUnit m)) => LocImage u a -> m a instance (Monad m) => DrawingCtxM (DrawingT u m) instance DrawingCtxM (Drawing u) instance (Monad m) => TraceM (DrawingT u m) instance TraceM (Drawing u) instance (Monad m) => Monad (DrawingT u m) instance Monad (Drawing u) instance (Monad m) => Applicative (DrawingT u m) instance Applicative (Drawing u) instance (Monad m) => Functor (DrawingT u m) instance Functor (Drawing u) -- | Querying the Drawing Context. module Wumpus.Basic.Graphic.Query textAttr :: DrawingF (RGBi, FontAttr) -- | Because textAttr is so commonly used here is a functional -- version that avoids tupling. withTextAttr :: (RGBi -> FontAttr -> a) -> DrawingF a strokeAttr :: DrawingF (RGBi, StrokeAttr) withStrokeAttr :: (RGBi -> StrokeAttr -> a) -> DrawingF a fillAttr :: DrawingF RGBi withFillAttr :: (RGBi -> a) -> DrawingF a borderedAttr :: DrawingF (RGBi, StrokeAttr, RGBi) withBorderedAttr :: (RGBi -> StrokeAttr -> RGBi -> a) -> DrawingF a lineWidth :: DrawingF Double fontSize :: DrawingF Int -- | A Mark is consider to be the height of a lowercase letter in the -- current font. -- -- Note better to use xlowerHeight markHeight :: (FromPtSize u) => DrawingF u lineSpacing :: (Fractional u) => DrawingF u monoCharWidth :: (FromPtSize u) => DrawingF u monoSpacerWidth :: (FromPtSize u) => DrawingF u monoTextWidth :: (FromPtSize u) => Int -> DrawingF u monoTextLength :: (FromPtSize u) => String -> DrawingF u monoTextHeight :: (FromPtSize u) => DrawingF u monoNumeralHeight :: (FromPtSize u) => DrawingF u -- | Height of a lower case 'x' in Courier. -- -- 'x' has no ascenders or descenders. monoLowerxHeight :: (FromPtSize u) => DrawingF u monoDescenderDepth :: (FromPtSize u) => DrawingF u -- | Query the dimensions of the text using the current font size but using -- metrics derived from Courier. -- -- Note - the width will generally be a over-estimate for non-monospaced -- fonts. monoTextDimensions :: (Num u, Ord u, FromPtSize u) => String -> DrawingF (u, u) -- | Vector from baseline left to center monoVecToCenter :: (Fractional u, Ord u, FromPtSize u) => String -> DrawingF (Vec2 u) -- | Elementary functions for the Graphic and LocGraphic types. -- -- The functions here are generally analogeous to the Picture API in -- Wumpus.Core, but here they exploit the implicit -- DrawingContext. module Wumpus.Basic.Graphic.PrimGraphic drawGraphic :: (Real u, Floating u, FromPtSize u) => DrawingContext -> Graphic u -> Maybe (Picture u) drawGraphicU :: (Real u, Floating u, FromPtSize u) => DrawingContext -> Graphic u -> Picture u openStroke :: (Num u) => PrimPath u -> Graphic u closedStroke :: (Num u) => PrimPath u -> Graphic u filledPath :: (Num u) => PrimPath u -> Graphic u borderedPath :: (Num u) => PrimPath u -> Graphic u textline :: (Num u) => String -> LocGraphic u -- | As textline but the supplied point is the center. -- -- Centered is inexact - it is calculated with monospaced font metrics. centermonoTextline :: (Fractional u, Ord u, FromPtSize u) => String -> LocGraphic u -- | Point is the baseline left of the bottom line. textlineMulti :: (Fractional u) => [String] -> LocGraphic u hkernline :: (Num u) => [KerningChar u] -> LocGraphic u vkernline :: (Num u) => [KerningChar u] -> LocGraphic u strokedEllipse :: (Num u) => u -> u -> LocGraphic u filledEllipse :: (Num u) => u -> u -> LocGraphic u borderedEllipse :: (Num u) => u -> u -> LocGraphic u -- | Supplying a point to a CFGraphic takes it to a regular -- Graphic. supplyPt :: Point2 u -> LocGraphic u -> Graphic u localPoint :: (Point2 u -> Point2 u) -> LocGraphic u -> LocGraphic u vecdisplace :: (Num u) => Vec2 u -> Point2 u -> Point2 u displace :: (Num u) => u -> u -> Point2 u -> Point2 u hdisplace :: (Num u) => u -> Point2 u -> Point2 u vdisplace :: (Num u) => u -> Point2 u -> Point2 u straightLine :: (Fractional u) => Vec2 u -> LocGraphic u straightLineBetween :: (Fractional u) => Point2 u -> Point2 u -> Graphic u -- | Supplied point is bottom left. strokedRectangle :: (Fractional u) => u -> u -> LocGraphic u -- | Supplied point is bottom left. filledRectangle :: (Fractional u) => u -> u -> LocGraphic u -- | Supplied point is bottom left. borderedRectangle :: (Fractional u) => u -> u -> LocGraphic u -- | Supplied point is center. Circle is drawn with Bezier curves. strokedCircle :: (Floating u) => Int -> u -> LocGraphic u -- | Supplied point is center. Circle is drawn with Bezier curves. filledCircle :: (Floating u) => Int -> u -> LocGraphic u -- | Supplied point is center. Circle is drawn with Bezier curves. borderedCircle :: (Floating u) => Int -> u -> LocGraphic 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. strokedDisk :: (Num u) => u -> LocGraphic u filledDisk :: (Num u) => u -> LocGraphic u borderedDisk :: (Num u) => u -> LocGraphic 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] -- | Calculate the counter-clockwise angle between two points and the -- x-axis. langle :: (Floating u, Real u) => Point2 u -> Point2 u -> Radian 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) -- | Import shim for Wumpus.Basic.Graphic modules. module Wumpus.Basic.Graphic -- | Generate points in an iterated chain. -- -- WARNING - very unstable. module Wumpus.Basic.Chains.Base data Chain ux uy u type LocChain ux uy u = Point2 u -> Chain ux uy u chain :: BivariateAlg ux uy -> Chain ux uy u chainFrom :: (Num u) => BivariateAlg ux uy -> LocChain ux uy u unchain :: ScalingContext ux uy u -> Chain ux uy u -> [Point2 u] -- | Chains are built as unfolds - AnaAlg avoids the pair constructor in -- the usual definition of unfoldr and makes the state strict. -- -- It is expected that all Chains built on unfolds will terminate. data AnaAlg st a Done :: AnaAlg st a Step :: a -> !st -> AnaAlg st a -- | IterAlg is a variant of AnaAlg that builds infinite sequences -- (iterations). -- -- When lifted to a Chain an iteration is bounded by a count so it will -- terminate. data IterAlg st a IterStep :: a -> !st -> IterAlg st a data BivariateAlg ux uy bivariate :: st -> (st -> AnaAlg st (ux, uy)) -> BivariateAlg ux uy data SequenceAlg a iteration :: (a -> a) -> a -> SequenceAlg a bounded :: Int -> SequenceAlg (ux, uy) -> BivariateAlg ux uy pairOnXs :: (ux -> uy) -> SequenceAlg ux -> SequenceAlg (ux, uy) pairOnYs :: (r -> l) -> SequenceAlg r -> SequenceAlg (l, r) -- | Generate points in an iterated chain. -- -- WARNING - very unstable. module Wumpus.Basic.Chains.Derived univariateX :: (Fractional uy, Num ux, Num u) => [ux] -> LocChain ux uy u univariateY :: (Fractional ux, Num uy, Num u) => [uy] -> LocChain ux uy u tableDown :: Int -> Int -> Chain Int Int u tableRight :: (Num u) => Int -> Int -> Chain Int Int u horizontal :: Int -> Chain Int Int u vertical :: Int -> Chain Int Int u horizontals :: (Num ua, Num u) => [ua] -> LocChain ua ua u verticals :: (Num ua, Num u) => [ua] -> LocChain ua ua u rescale :: (Fractional a) => a -> a -> a -> a -> a -> a -- | Shim module. -- -- WARNING - very unstable. module Wumpus.Basic.Chains -- | Marks - dots without anchor handles. -- -- ** WARNING ** - names are expected to change - filled and -- background-filled marks need a naming convention. module Wumpus.Basic.Dots.Primitive markChar :: (Fractional u, Ord u, FromPtSize u) => Char -> LocGraphic u markText :: (Fractional u, Ord u, FromPtSize u) => String -> LocGraphic u markHLine :: (Fractional u, FromPtSize u) => LocGraphic u markVLine :: (Fractional u, FromPtSize u) => LocGraphic u markX :: (Fractional u, FromPtSize u) => LocGraphic u markPlus :: (Fractional u, FromPtSize u) => LocGraphic u markCross :: (Floating u, FromPtSize u) => LocGraphic u markDiamond :: (Fractional u, FromPtSize u) => LocGraphic u markFDiamond :: (Fractional u, FromPtSize u) => LocGraphic u markBDiamond :: (Fractional u, FromPtSize u) => LocGraphic u -- | Note disk is filled. markDisk :: (Fractional u, FromPtSize u) => LocGraphic u markSquare :: (Fractional u, FromPtSize u) => LocGraphic u markCircle :: (Fractional u, FromPtSize u) => LocGraphic u markPentagon :: (Floating u, FromPtSize u) => LocGraphic u markStar :: (Floating u, FromPtSize u) => LocGraphic u markAsterisk :: (Floating u, FromPtSize u) => LocGraphic u markOPlus :: (Fractional u, FromPtSize u) => LocGraphic u markOCross :: (Floating u, FromPtSize u) => LocGraphic u markFOCross :: (Floating u, FromPtSize u) => LocGraphic u -- | Turtle 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. -- -- Turtle is only a transformer - it is intended to be run within a -- Drawing. module Wumpus.Basic.Monads.TurtleMonad data TurtleT u m a runTurtleT :: (Monad m, Num u) => (Int, Int) -> ScalingContext Int Int u -> TurtleT u m a -> m a instance (u ~ MonUnit m, Monad m, Num u) => PointSupplyM (TurtleT u m) instance (u ~ MonUnit m, Monad m, TraceM m) => TraceM (TurtleT u m) instance (DrawingCtxM m) => DrawingCtxM (TurtleT u m) instance (Monad m) => TurtleM (TurtleT u m) instance (Monad m) => Monad (TurtleT u m) instance (Monad m) => Applicative (TurtleT u m) instance (Monad m) => Functor (TurtleT u m) -- | Extended path type - more amenable for complex drawings than the type -- in Wumpus-Core. -- -- ** WARNING ** this module is an experiment, and may change -- significantly or even be dropped from future revisions. module Wumpus.Basic.Paths.Connectors type ConnPath u = Point2 u -> Point2 u -> Path u connectS :: (Floating u) => ConnPath u vhconn :: (Floating u) => ConnPath u hvconn :: (Floating u) => ConnPath u arbv :: (Floating u) => u -> ConnPath u arbh :: (Floating u) => u -> ConnPath u curveconn :: (Floating u, Ord u) => Radian -> Radian -> ConnPath u joint :: (Real u, Floating u) => u -> ConnPath u pathGraphic :: (Num u) => ConnPath u -> ConnGraphic u -- | Closes and fills a path fillPath :: (Num u) => Path u -> Graphic u shorten :: (Real u, Floating u, Ord u) => u -> Path u -> Path u shortenL :: (Real u, Floating u, Ord u) => u -> Path u -> Path u shortenR :: (Real u, Floating u, Ord u) => u -> Path u -> Path u midpoint :: (Real u, Floating u) => Path u -> Point2 u directionL :: (Real u, Floating u) => Path u -> Radian directionR :: (Real u, Floating u) => Path u -> Radian -- | Shim import module for Paths. module Wumpus.Basic.Paths -- | Common core for shapes module Wumpus.Basic.Shapes.Base data Shape u sh Shape :: ShapeCTM u -> (ShapeCTM u -> Image u sh) -> Shape u sh src_ctm :: Shape u sh -> ShapeCTM u out_fun :: Shape u sh -> ShapeCTM u -> Image u sh drawShape :: Shape u sh -> Image u sh data ShapeCTM u ShapeCTM :: !u -> !u -> !u -> !u -> Radian -> ShapeCTM u ctm_trans_x :: ShapeCTM u -> !u ctm_trans_y :: ShapeCTM u -> !u ctm_scale_x :: ShapeCTM u -> !u ctm_scale_y :: ShapeCTM u -> !u ctm_rotation :: ShapeCTM u -> Radian identityCTM :: (Num u) => ShapeCTM u ctmDisplace :: (Real u, Floating u) => Point2 u -> ShapeCTM u -> Point2 u ctmCenter :: (Real u, Floating u) => ShapeCTM u -> Point2 u data ShapeLabel u runShapeLabel :: ShapeCTM u -> ShapeLabel u -> Graphic u nolabel :: ShapeLabel u -- | No scaling - change font size if needed. shapelabel :: (Real u, Floating u, FromPtSize u) => String -> ShapeLabel u instance (Eq u) => Eq (ShapeCTM u) instance (Show u) => Show (ShapeCTM u) instance (Num u) => Translate (Shape u sh) instance (Num u) => Scale (Shape u sh) instance (Real u, Floating u) => Rotate (Shape u sh) -- | LRText monad - left-to-right text, with kerning. -- -- Note - because Wumpus has no access to the metrics data inside a font -- file, the default spacing is not good and it is expected that kerning -- will need to be added per-letter for variable width fonts. -- -- This module makes precise horizontal text spacing *possible*, it does -- not make it *easy*. module Wumpus.Basic.Text.LRText data LRText u a runLRText :: (Num u, FromPtSize u) => LRText u a -> LocImage u a execLRText :: (Num u, FromPtSize u) => LRText u a -> LocGraphic u kern :: (Num u) => u -> LRText u () char :: (Num u) => Char -> LRText u () escInt :: (Num u) => Int -> LRText u () escName :: (Num u) => String -> LRText u () symb :: (Num u) => Char -> LRText u () symbEscInt :: (Num u) => Int -> LRText u () symbEscName :: (Num u) => String -> LRText u () instance Monad (LRText u) instance Applicative (LRText u) instance Functor (LRText u) -- | Named literals from Symbol font, drawn with the LRText monad. -- -- Note - Symbol font handling and precise letter placing in SVG viewers -- is mixed. Chrome works well good, Firefox (3.6.3) and Safari (5.0.1) -- are unsatisfactory. module Wumpus.Basic.Text.LRSymbol -- | Note - prints as 'A'. uAlpha :: (Num u) => LRText u () -- | Note - prints as 'B'. uBeta :: (Num u) => LRText u () -- | Note - prints as 'X'. uChi :: (Num u) => LRText u () uDelta :: (Num u) => LRText u () -- | Note - prints as 'E'. uEpsilon :: (Num u) => LRText u () -- | Note - prints as 'H'. uEta :: (Num u) => LRText u () -- | Note - does not appear to print in Chrome. uEuro :: (Num u) => LRText u () uGamma :: (Num u) => LRText u () uIfraktur :: (Num u) => LRText u () -- | Note - prints as 'I'. uIota :: (Num u) => LRText u () -- | Note - prints as 'K'. uKappa :: (Num u) => LRText u () uLambda :: (Num u) => LRText u () -- | Note - prints as 'M'. uMu :: (Num u) => LRText u () -- | Note - prints as 'N'. uNu :: (Num u) => LRText u () uOmega :: (Num u) => LRText u () uOmicron :: (Num u) => LRText u () uPhi :: (Num u) => LRText u () uPi :: (Num u) => LRText u () uPsi :: (Num u) => LRText u () uRfraktur :: (Num u) => LRText u () uRho :: (Num u) => LRText u () uSigma :: (Num u) => LRText u () uTau :: (Num u) => LRText u () uTheta :: (Num u) => LRText u () -- | Note - prints as 'Y'. uUpsilon :: (Num u) => LRText u () -- | Note - this is the pretty Upsilon. uUpsilon1 :: (Num u) => LRText u () uXi :: (Num u) => LRText u () uZeta :: (Num u) => LRText u () alpha :: (Num u) => LRText u () beta :: (Num u) => LRText u () gamma :: (Num u) => LRText u () delta :: (Num u) => LRText u () epsilon :: (Num u) => LRText u () zeta :: (Num u) => LRText u () eta :: (Num u) => LRText u () theta :: (Num u) => LRText u () iota :: (Num u) => LRText u () kappa :: (Num u) => LRText u () lambda :: (Num u) => LRText u () mu :: (Num u) => LRText u () nu :: (Num u) => LRText u () xi :: (Num u) => LRText u () pi :: (Num u) => LRText u () rho :: (Num u) => LRText u () sigma :: (Num u) => LRText u () tau :: (Num u) => LRText u () upsilon :: (Num u) => LRText u () phi :: (Num u) => LRText u () chi :: (Num u) => LRText u () psi :: (Num u) => LRText u () omega :: (Num u) => LRText u () aleph :: (Num u) => LRText u () ampersand :: (Num u) => LRText u () angle :: (Num u) => LRText u () angleleft :: (Num u) => LRText u () angleright :: (Num u) => LRText u () approxequal :: (Num u) => LRText u () arrowboth :: (Num u) => LRText u () arrowdblboth :: (Num u) => LRText u () arrowdbldown :: (Num u) => LRText u () arrowdblleft :: (Num u) => LRText u () arrowdblright :: (Num u) => LRText u () arrowdblup :: (Num u) => LRText u () arrowdown :: (Num u) => LRText u () arrowleft :: (Num u) => LRText u () arrowright :: (Num u) => LRText u () arrowup :: (Num u) => LRText u () asteriskmath :: (Num u) => LRText u () bar :: (Num u) => LRText u () braceleft :: (Num u) => LRText u () braceright :: (Num u) => LRText u () bracketleft :: (Num u) => LRText u () bracketright :: (Num u) => LRText u () bullet :: (Num u) => LRText u () carriagereturn :: (Num u) => LRText u () circlemultiply :: (Num u) => LRText u () circleplus :: (Num u) => LRText u () club :: (Num u) => LRText u () colon :: (Num u) => LRText u () comma :: (Num u) => LRText u () congruent :: (Num u) => LRText u () copyrightsans :: (Num u) => LRText u () copyrightserif :: (Num u) => LRText u () degree :: (Num u) => LRText u () diamond :: (Num u) => LRText u () divide :: (Num u) => LRText u () dotmath :: (Num u) => LRText u () eight :: (Num u) => LRText u () element :: (Num u) => LRText u () ellipsis :: (Num u) => LRText u () emptyset :: (Num u) => LRText u () equal :: (Num u) => LRText u () equivalence :: (Num u) => LRText u () exclam :: (Num u) => LRText u () existential :: (Num u) => LRText u () five :: (Num u) => LRText u () florin :: (Num u) => LRText u () four :: (Num u) => LRText u () fraction :: (Num u) => LRText u () gradient :: (Num u) => LRText u () greater :: (Num u) => LRText u () greaterequal :: (Num u) => LRText u () heart :: (Num u) => LRText u () infinity :: (Num u) => LRText u () integral :: (Num u) => LRText u () intersection :: (Num u) => LRText u () less :: (Num u) => LRText u () lessequal :: (Num u) => LRText u () logicaland :: (Num u) => LRText u () logicalnot :: (Num u) => LRText u () logicalor :: (Num u) => LRText u () lozenge :: (Num u) => LRText u () minus :: (Num u) => LRText u () minute :: (Num u) => LRText u () multiply :: (Num u) => LRText u () nine :: (Num u) => LRText u () notelement :: (Num u) => LRText u () notequal :: (Num u) => LRText u () notsubset :: (Num u) => LRText u () numbersign :: (Num u) => LRText u () omega1 :: (Num u) => LRText u () omicron :: (Num u) => LRText u () one :: (Num u) => LRText u () parenleft :: (Num u) => LRText u () parenright :: (Num u) => LRText u () partialdiff :: (Num u) => LRText u () percent :: (Num u) => LRText u () period :: (Num u) => LRText u () perpendicular :: (Num u) => LRText u () phi1 :: (Num u) => LRText u () plus :: (Num u) => LRText u () plusminus :: (Num u) => LRText u () product :: (Num u) => LRText u () propersubset :: (Num u) => LRText u () propersuperset :: (Num u) => LRText u () proportional :: (Num u) => LRText u () question :: (Num u) => LRText u () radical :: (Num u) => LRText u () radicalex :: (Num u) => LRText u () reflexsubset :: (Num u) => LRText u () reflexsuperset :: (Num u) => LRText u () registersans :: (Num u) => LRText u () registerserif :: (Num u) => LRText u () second :: (Num u) => LRText u () semicolon :: (Num u) => LRText u () seven :: (Num u) => LRText u () sigma1 :: (Num u) => LRText u () similar :: (Num u) => LRText u () six :: (Num u) => LRText u () slash :: (Num u) => LRText u () space :: (Num u) => LRText u () spade :: (Num u) => LRText u () suchthat :: (Num u) => LRText u () summation :: (Num u) => LRText u () therefore :: (Num u) => LRText u () theta1 :: (Num u) => LRText u () three :: (Num u) => LRText u () trademarksans :: (Num u) => LRText u () trademarkserif :: (Num u) => LRText u () two :: (Num u) => LRText u () underscore :: (Num u) => LRText u () union :: (Num u) => LRText u () universal :: (Num u) => LRText u () weierstrass :: (Num u) => LRText u () zero :: (Num u) => LRText u () -- | Anchor points on shapes. -- -- ** WARNING ** this module is an experiment, and may change -- significantly or even be dropped from future revisions. module Wumpus.Basic.Arrows.Tips tri90 :: (Floating u, Real u, FromPtSize u) => Radian -> LocGraphic u tri60 :: (Floating u, Real u, FromPtSize u) => Radian -> LocGraphic u tri45 :: (Floating u, Real u, FromPtSize u) => Radian -> LocGraphic u otri90 :: (Floating u, Real u, FromPtSize u) => Radian -> LocGraphic u otri60 :: (Floating u, Real u, FromPtSize u) => Radian -> LocGraphic u otri45 :: (Floating u, Real u, FromPtSize u) => Radian -> LocGraphic u barb90 :: (Floating u, Real u, FromPtSize u) => Radian -> LocGraphic u barb60 :: (Floating u, Real u, FromPtSize u) => Radian -> LocGraphic u barb45 :: (Floating u, Real u, FromPtSize u) => Radian -> LocGraphic u perp :: (Floating u, FromPtSize u) => Radian -> LocGraphic u -- | Anchor points on shapes. -- -- ** WARNING ** this module is an experiment, and may change -- significantly or even be dropped from future revisions. module Wumpus.Basic.Arrows line :: (Num u) => ConnPath u -> ConnImage u (Path u) arrowTri90 :: (Real u, Floating u, FromPtSize u) => ConnPath u -> ConnImage u (Path u) arrowTri60 :: (Real u, Floating u, FromPtSize u) => ConnPath u -> ConnImage u (Path u) arrowTri45 :: (Real u, Floating u, FromPtSize u) => ConnPath u -> ConnImage u (Path u) arrowOTri90 :: (Real u, Floating u, FromPtSize u) => ConnPath u -> ConnImage u (Path u) arrowOTri60 :: (Real u, Floating u, FromPtSize u) => ConnPath u -> ConnImage u (Path u) arrowOTri45 :: (Real u, Floating u, FromPtSize u) => ConnPath u -> ConnImage u (Path u) arrowBarb90 :: (Real u, Floating u, FromPtSize u) => ConnPath u -> ConnImage u (Path u) arrowBarb60 :: (Real u, Floating u, FromPtSize u) => ConnPath u -> ConnImage u (Path u) arrowBarb45 :: (Real u, Floating u, FromPtSize u) => ConnPath u -> ConnImage u (Path u) arrowPerp :: (Real u, Floating u, FromPtSize u) => ConnPath u -> ConnImage u (Path u) -- | Anchor points on shapes. -- -- ** WARNING ** this module is an experiment, and may change -- significantly or even be dropped from future revisions. module Wumpus.Basic.Anchors class CenterAnchor t center :: (CenterAnchor t, (DUnit t) ~ u) => t -> Point2 u class CardinalAnchor t north :: (CardinalAnchor t, (DUnit t) ~ u) => t -> Point2 u south :: (CardinalAnchor t, (DUnit t) ~ u) => t -> Point2 u east :: (CardinalAnchor t, (DUnit t) ~ u) => t -> Point2 u west :: (CardinalAnchor t, (DUnit t) ~ u) => t -> Point2 u class CardinalAnchor2 t northeast :: (CardinalAnchor2 t, (DUnit t) ~ u) => t -> Point2 u southeast :: (CardinalAnchor2 t, (DUnit t) ~ u) => t -> Point2 u southwest :: (CardinalAnchor2 t, (DUnit t) ~ u) => t -> Point2 u northwest :: (CardinalAnchor2 t, (DUnit t) ~ u) => t -> Point2 u -- | textAnchor is the Bottom left corner on the baseline. class TextAnchor t baselineSW :: (TextAnchor t, (DUnit t) ~ u) => t -> Point2 u -- | Anchor on a border that can be identified with and angle. class RadialAnchor t radialAnchor :: (RadialAnchor t, (DUnit t) ~ u) => Radian -> t -> Point2 u northwards :: (Real u, Floating u, CenterAnchor t, CardinalAnchor t, u ~ (DUnit t)) => u -> t -> Point2 u southwards :: (Real u, Floating u, CenterAnchor t, CardinalAnchor t, u ~ (DUnit t)) => u -> t -> Point2 u eastwards :: (Real u, Floating u, CenterAnchor t, CardinalAnchor t, u ~ (DUnit t)) => u -> t -> Point2 u westwards :: (Real u, Floating u, CenterAnchor t, CardinalAnchor t, u ~ (DUnit t)) => u -> t -> Point2 u northeastwards :: (Real u, Floating u, CenterAnchor t, CardinalAnchor2 t, u ~ (DUnit t)) => u -> t -> Point2 u southeastwards :: (Real u, Floating u, CenterAnchor t, CardinalAnchor2 t, u ~ (DUnit t)) => u -> t -> Point2 u southwestwards :: (Real u, Floating u, CenterAnchor t, CardinalAnchor2 t, u ~ (DUnit t)) => u -> t -> Point2 u northwestwards :: (Real u, Floating u, CenterAnchor t, CardinalAnchor2 t, u ~ (DUnit t)) => u -> t -> Point2 u radialConnectorPoints :: (Real u, Floating u, CenterAnchor t1, RadialAnchor t1, CenterAnchor t2, RadialAnchor t2, u ~ (DUnit t1), (DUnit t1) ~ (DUnit t2)) => t1 -> t2 -> (Point2 u, Point2 u) -- | Dots with anchors. -- -- In many cases a surrounding circle is used to locate anchor points - -- this could be improved to use the actual dot border at some point. module Wumpus.Basic.Dots data DotAnchor u type DotLocImage u = LocImage u (DotAnchor u) type DDotLocImage = DotLocImage Double dotChar :: (Floating u, Real u, FromPtSize u) => Char -> DotLocImage u dotText :: (Floating u, Real u, FromPtSize u) => String -> DotLocImage u dotHLine :: (Floating u, FromPtSize u) => DotLocImage u dotVLine :: (Floating u, FromPtSize u) => DotLocImage u dotX :: (Floating u, FromPtSize u) => DotLocImage u dotPlus :: (Floating u, FromPtSize u) => DotLocImage u dotCross :: (Floating u, FromPtSize u) => DotLocImage u dotDiamond :: (Floating u, FromPtSize u) => DotLocImage u dotFDiamond :: (Floating u, FromPtSize u) => DotLocImage u dotDisk :: (Floating u, FromPtSize u) => DotLocImage u dotSquare :: (Floating u, Real u, FromPtSize u) => DotLocImage u dotCircle :: (Floating u, FromPtSize u) => DotLocImage u dotPentagon :: (Floating u, FromPtSize u) => DotLocImage u dotStar :: (Floating u, FromPtSize u) => DotLocImage u dotAsterisk :: (Floating u, FromPtSize u) => DotLocImage u dotOPlus :: (Floating u, FromPtSize u) => DotLocImage u dotOCross :: (Floating u, FromPtSize u) => DotLocImage u dotFOCross :: (Floating u, FromPtSize u) => DotLocImage u instance Eq Cardinal instance Show Cardinal instance CardinalAnchor2 (DotAnchor u) instance CardinalAnchor (DotAnchor u) instance RadialAnchor (DotAnchor u) instance CenterAnchor (DotAnchor u) module Wumpus.Basic.Shapes.Derived data Rectangle u type DRectangle = Rectangle Double rectangle :: (Real u, Floating u) => u -> u -> Shape u (Rectangle u) lrectangle :: (Real u, Floating u, FromPtSize u) => u -> u -> String -> Shape u (Rectangle u) data Circle u type DCircle = Circle Double circle :: (Real u, Floating u) => u -> Shape u (Circle u) lcircle :: (Real u, Floating u, FromPtSize u) => u -> String -> Shape u (Circle u) -- | Coordinate data Coordinate u type DCoordinate = Coordinate Double coordinate :: (Real u, Floating u) => Shape u (Coordinate u) data Diamond u type DDiamond = Diamond Double diamond :: (Real u, Floating u) => u -> u -> Shape u (Diamond u) ldiamond :: (Real u, Floating u, FromPtSize u) => u -> u -> String -> Shape u (Diamond u) data Ellipse u type DEllipse = Ellipse Double ellipse :: (Real u, Floating u) => u -> u -> Shape u (Ellipse u) lellipse :: (Real u, Floating u, FromPtSize u) => u -> u -> String -> Shape u (Ellipse u) data FreeLabel u type DFreeLabel = FreeLabel Double freelabel :: (Real u, Floating u, FromPtSize u) => String -> Shape u (FreeLabel u) instance (Eq u) => Eq (Circle u) instance (Show u) => Show (Circle u) instance (Eq u) => Eq (Rectangle u) instance (Show u) => Show (Rectangle u) instance (Real u, Floating u) => RadialAnchor (FreeLabel u) instance (Real u, Floating u) => CardinalAnchor2 (FreeLabel u) instance (Real u, Floating u) => CardinalAnchor (FreeLabel u) instance (Real u, Floating u) => CenterAnchor (FreeLabel u) instance (Real u, Floating u) => CenterAnchor (Ellipse u) instance (Real u, Floating u) => CardinalAnchor (Diamond u) instance (Real u, Floating u) => CenterAnchor (Diamond u) instance (Real u, Floating u) => CenterAnchor (Coordinate u) instance (Real u, Floating u) => CardinalAnchor2 (Circle u) instance (Real u, Floating u) => RadialAnchor (Circle u) instance (Real u, Floating u) => CardinalAnchor (Circle u) instance (Real u, Floating u) => CenterAnchor (Circle u) instance (Real u, Floating u) => RadialAnchor (Rectangle u) instance (Real u, Floating u) => CardinalAnchor2 (Rectangle u) instance (Real u, Floating u) => CardinalAnchor (Rectangle u) instance (Real u, Floating u) => CenterAnchor (Rectangle u)