-- 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). -- -- Some of the modules (SafeFonts, SVGColours, X11Colours) are relatively -- stable. The core modules of Basic.Graphic (Base, -- PrimGraphic, DrawingContext) seem to support a good -- set primitive functions, but the exact types of drawing objects do not -- feel right at the moment. Other modules (Paths, Chains, Shapes) are -- essentially sketches and are expected to be substantially revised in -- subsequent updates. -- -- Version 0.11.0 is an interim release. It is expected that the next -- release will substantially rework Shapes and likely change the -- Graphic.Base types. As quite a large amount of code has -- already changed since version 0.10.0 (to support better arrowheads and -- connectors) it seems sensible to release 0.11.0 now, rather than have -- a huge delta after Shapes have been reworked again. The current -- versions of Wumpus-Tree and Wumpus-Microprint will -- work with version 0.11.0 if their respective .cabal files are -- edited to bump the version number. There will be no matching releases -- to work automatically with version 0.11.0 of Wumpus-Basic. -- -- Changelog: -- --
-- 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,11,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 type DPath = Path Double length :: (Num u) => Path u -> u append :: (Floating u) => Path u -> Path u -> Path u pconcat :: (Floating u) => Path u -> [Path u] -> Path u line :: (Floating u) => Point2 u -> Point2 u -> Path u curve :: (Floating u, Ord u) => Point2 u -> Point2 u -> Point2 u -> Point2 u -> Path u -- | traceLinePoints throws a runtime error if the supplied list is -- empty. traceLinePoints :: (Floating u) => [Point2 u] -> Path u -- | traceCurvePoints consumes 4 points from the list on the intial -- step (start, control1, control2, end) then steps through the list -- taking 3 points at a time thereafter (control1,control2, end). -- Leftover points are discarded. -- -- traceCurvePoints throws a runtime error if the supplied list is -- has less than 4 elements (start, control1, control2, end). traceCurvePoints :: (Floating u, Ord u) => [Point2 u] -> Path u curveByAngles :: (Floating u, Ord u) => Point2 u -> Radian -> Radian -> Point2 u -> Path u -- | Turn a Path into an ordinary PrimPath. -- -- 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 -> PrimPath u tipL :: Path u -> Point2 u tipR :: Path u -> Point2 u -- | Shorten both ends... -- -- u should be less-than half the path length shortenBoth :: (Real u, Floating u) => u -> Path u -> Path u -- | Note - shortening a line from the left by greater-than-or-equal its -- length is operationally equivalent to making a zero-length line at the -- end point. shortenL :: (Real u, Floating u) => u -> Path u -> Path u -- | Note - shortening a line from the right by greater-than-or-equal its -- length is operationally equivalent to making a zero-length line at the -- start point. shortenR :: (Real u, Floating u) => u -> Path u -> Path u -- | Direction of empty path is considered to be 0. directionL :: (Real u, Floating u) => Path u -> Radian -- | Direction of empty path is considered to be 0. directionR :: (Real u, Floating u) => Path u -> Radian midway :: (Real u, Floating u) => Path u -> (Point2 u, Radian) midway_ :: (Real u, Floating u) => Path u -> Point2 u atstart :: (Real u, Floating u) => Path u -> (Point2 u, Radian) atstart_ :: Path u -> Point2 u atend :: (Real u, Floating u) => Path u -> (Point2 u, Radian) atend_ :: Path u -> Point2 u data PathViewL u PathOneL :: (PathSegment u) -> PathViewL u (:<<) :: PathSegment u -> Path u -> PathViewL u type DPathViewL = PathViewL Double data PathViewR u PathOneR :: (PathSegment u) -> PathViewR u (:>>) :: Path u -> PathSegment u -> PathViewR u type DPathViewR = PathViewR Double data PathSegment u Line1 :: (Point2 u) -> (Point2 u) -> PathSegment u Curve1 :: (Point2 u) -> (Point2 u) -> (Point2 u) -> (Point2 u) -> PathSegment u type DPathSegment = PathSegment Double pathViewL :: (Num u) => Path u -> PathViewL u pathViewR :: (Num u) => Path u -> PathViewR u instance (Eq u) => Eq (PathSegment u) instance (Ord u) => Ord (PathSegment u) instance (Show u) => Show (PathSegment u) instance (Eq u) => Eq (PathViewR u) instance (Ord u) => Ord (PathViewR u) instance (Show u) => Show (PathViewR u) instance (Eq u) => Eq (PathViewL u) instance (Ord u) => Ord (PathViewL u) instance (Show u) => Show (PathViewL 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) -- | Library of connector paths... -- -- ** WARNING ** this module is an experiment, and may change -- significantly or even be dropped from future revisions. module Wumpus.Basic.Paths.Connectors type ConnectorPath u = Point2 u -> Point2 u -> Path u connect :: (Floating u) => ConnectorPath u vhconn :: (Floating u) => ConnectorPath u hvconn :: (Floating u) => ConnectorPath u vhvconn :: (Floating u) => u -> ConnectorPath u hvhconn :: (Floating u) => u -> ConnectorPath u curveconn :: (Floating u, Ord u) => Radian -> Radian -> ConnectorPath u joint :: (Real u, Floating u) => u -> ConnectorPath 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 times_roman :: FontFace -- | Times Italic times_italic :: FontFace -- | Times Bold times_bold :: FontFace -- | Times Bold Italic times_bold_italic :: FontFace -- | Helvetica helvetica :: FontFace -- | Helvetica Oblique helvetica_oblique :: FontFace -- | Helvetica Bold helvetica_bold :: FontFace -- | Helvetica Bold Oblique helvetica_bold_oblique :: FontFace -- | Courier courier :: FontFace -- | Courier Oblique courier_oblique :: FontFace -- | Courier Bold courier_bold :: FontFace -- | Courier Bold Oblique courier_bold_oblique :: 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 -- | Build paths monadically. -- -- ** 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 :: (Floating u) => Point2 u -> PathM u a -> (a, Path u) execPath :: (Floating u) => Point2 u -> PathM u a -> Path u tip :: PathM u (Point2 u) lineto :: (Floating u) => Point2 u -> PathM u () rlineto :: (Floating u) => Vec2 u -> PathM u () hline :: (Floating u) => u -> PathM u () vline :: (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) -- | 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) -- | 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 stroke_colour :: DrawingContext -> RGBi fill_colour :: DrawingContext -> RGBi line_spacing_factor :: DrawingContext -> Double type DrawingContextF = DrawingContext -> DrawingContext standardContext :: FontSize -> DrawingContext default_drawing_context :: 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 :: DrawingContextF ultrathick :: DrawingContextF thin :: DrawingContextF capButt :: DrawingContextF capRound :: DrawingContextF capSquare :: DrawingContextF joinMiter :: DrawingContextF joinRound :: DrawingContextF joinBevel :: DrawingContextF dashPattern :: DashPattern -> DrawingContextF unit_dash_pattern :: DashPattern phase :: Int -> DashPattern -> DashPattern dphase :: Int -> DashPattern -> DashPattern doublegaps :: DashPattern -> DashPattern doubledashes :: DashPattern -> DashPattern fontsize :: Int -> DrawingContextF fontface :: FontFace -> DrawingContextF -- | Set the font size to double the current size, note the font size also -- controls the size of dots, arrowsheads etc. doublesize :: DrawingContextF -- | 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 :: DrawingContextF swapColours :: DrawingContextF bothStrokeColour :: DrawingContextF bothFillColour :: DrawingContextF strokeColour :: RGBi -> DrawingContextF fillColour :: RGBi -> DrawingContextF instance Eq DrawingContext instance Show DrawingContext -- | Base types for Drawing Objects, Graphics / Images (a Graphic that also -- returns an answer), etc. -- -- Base classes for monadic drawing. -- -- Notes on prefix and suffix names: -- -- Function types suffixed F are functions from same-to-same, -- e.g.: -- --
-- type Point2F u = Point2 u -> Point2 u ---- -- Functional types subfixed R are functions from some static -- context to the answer type (c.f the ReaderMonad), e.g.: -- --
-- newtype DrawingR a = DrawingR { getDrawingR :: DrawingContext -> a }
--
--
-- The suffix M is used for classes defining monadic actions.
--
-- The prefix Loc indicates a functional type from Point2 to
-- something...
--
-- The prefix ThetaLoc indicates a functional type from
-- Direction (radian) then Point to something...
--
-- ** WARNING ** - some names are expected to change.
module Wumpus.Basic.Graphic.Base
-- | DUnit is always for fully saturated type constructors, so (seemingly)
-- an equivalent type family is needed for monads.
-- | 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 (Applicative m, Monad m) => DrawingCtxM m :: (* -> *)
askDC :: (DrawingCtxM m) => m DrawingContext
localize :: (DrawingCtxM m) => (DrawingContext -> DrawingContext) -> m a -> m a
-- | Project a value out of a context.
asksDC :: (DrawingCtxM m) => (DrawingContext -> a) -> m a
-- | A monad that supplies points, e.g. a turtle monad.
class (Monad m) => PointSupplyM m :: (* -> *)
position :: (PointSupplyM m, u ~ (MonUnit m)) => m (Point2 u)
-- | 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 DrawingR.
--
-- -- DrawingR :: DrawingContext -> a --data DrawingR a type LocDrawingR u a = Point2 u -> DrawingR a type DLocDrawingR a = LocDrawingR Double a -- | Run a Drawing Function with the supplied Drawing -- Context. runDrawingR :: DrawingContext -> DrawingR a -> a type Graphic u = DrawingR (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 -- | 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 = DrawingR (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 :: DrawingR a -> Graphic u -> Image u a intoLocImage :: LocDrawingR u a -> LocGraphic u -> LocImage u a xlinkImage :: XLink -> Image u a -> Image u a type ConnectorDrawingR u a = Point2 u -> Point2 u -> DrawingR a type DConnectorDrawingR a = ConnectorDrawingR Double a -- | ConnectorGraphic is a connector drawn between two points contructing a -- Graphic. type ConnectorGraphic u = Point2 u -> Point2 u -> Graphic u type DConnectorGraphic = ConnectorGraphic Double -- | ConImage is a connector drawn between two points constructing an -- Image. type ConnectorImage u a = Point2 u -> Point2 u -> Image u a type DConnectorImage a = ConnectorImage Double a intoConnectorImage :: ConnectorDrawingR u a -> ConnectorGraphic u -> ConnectorImage u a type ThetaLocDrawingR u a = Radian -> LocDrawingR u a type DThetaLocDrawingR a = ThetaLocDrawingR Double a -- | A function from Radian -\> Point -\> Graphic... type ThetaLocGraphic u = Radian -> LocGraphic u type DThetaLocGraphic = ThetaLocGraphic Double type ThetaLocImage u a = Radian -> LocImage u a type DThetaLocImage a = ThetaLocImage Double a instance DrawingCtxM DrawingR instance Monad DrawingR instance Applicative DrawingR instance (Monoid a) => Monoid (DrawingR a) instance Functor DrawingR instance Monoid (HPrim u) -- | Reader monad over (angular) direction. module Wumpus.Basic.Graphic.DirectionContext class (Monad m) => DirectionM m localTheta :: (DirectionM m) => Radian -> m a -> m a asksTheta :: (DirectionM m) => (Radian -> a) -> m a parallel :: (DirectionM m, Floating u) => u -> m (Vec2 u) perpendicular :: (DirectionM m, Floating u) => u -> m (Vec2 u) data Direction a runDirection :: Radian -> Direction a -> a data DirectionT m a runDirectionT :: Radian -> DirectionT m a -> m a displacePerp :: (DirectionM m, Floating u) => u -> Point2 u -> m (Point2 u) displacePara :: (DirectionM m, Floating u) => u -> Point2 u -> m (Point2 u) instance (Monad m, TraceM m) => TraceM (DirectionT m) instance (DrawingCtxM m) => DrawingCtxM (DirectionT m) instance (Monad m) => DirectionM (DirectionT m) instance (Monad m) => Monad (DirectionT m) instance (Monad m) => Applicative (DirectionT m) instance (Monad m) => Functor (DirectionT m) instance DirectionM Direction instance Monad Direction instance Applicative Direction instance Functor Direction -- | Scaling in X and Y module Wumpus.Basic.Graphic.ScalingContext -- | Scaling... class (Monad m) => 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) 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) -- | Run the drawing returning only the output it produces, drop any answer -- from the monadic computation. execDrawing :: DrawingContext -> Drawing u a -> HPrim u -- | Run the drawing ignoring the output it produces, return the answer -- from the monadic computation. -- -- Note - this useful for testing, generally one would want the opposite -- behaviour (return the drawing, ignore than the answer). evalDrawing :: DrawingContext -> Drawing u a -> a runDrawingT :: (Monad m) => DrawingContext -> DrawingT u m a -> m (a, HPrim u) execDrawingT :: (Monad m) => DrawingContext -> DrawingT u m a -> m (HPrim u) evalDrawingT :: (Monad m) => DrawingContext -> DrawingT u m a -> m a -- | 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 -- | Forgetful drawi. drawi_ :: (TraceM m, DrawingCtxM m, u ~ (MonUnit m)) => Image u a -> m () -- | Hyperlink version of drawi. xdrawi :: (TraceM m, DrawingCtxM m, u ~ (MonUnit m)) => XLink -> Image u a -> m a -- | Forgetful xdrawi. xdrawi_ :: (TraceM m, DrawingCtxM m, u ~ (MonUnit m)) => XLink -> Image u a -> m () at :: LocGraphic u -> Point2 u -> Graphic u ati :: LocImage u a -> Point2 u -> Image 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 :: (DrawingCtxM m) => m (RGBi, FontAttr) -- | Because textAttr is so commonly used here is a functional -- version that avoids tupling. withTextAttr :: (DrawingCtxM m) => (RGBi -> FontAttr -> a) -> m a strokeAttr :: (DrawingCtxM m) => m (RGBi, StrokeAttr) withStrokeAttr :: (DrawingCtxM m) => (RGBi -> StrokeAttr -> a) -> m a fillAttr :: (DrawingCtxM m) => m RGBi withFillAttr :: (DrawingCtxM m) => (RGBi -> a) -> m a borderedAttr :: (DrawingCtxM m) => m (RGBi, StrokeAttr, RGBi) withBorderedAttr :: (DrawingCtxM m) => (RGBi -> StrokeAttr -> RGBi -> a) -> m a lineWidth :: (DrawingCtxM m) => m Double fontSize :: (DrawingCtxM m) => m Int -- | The mark height is the height of a lowercase letter in the -- current font. -- -- Arrowheads, dots etc. should generally be drawn at the mark height. markHeight :: (DrawingCtxM m, FromPtSize u) => m u markHalfHeight :: (DrawingCtxM m, Fractional u, FromPtSize u) => m u -- | Vertical distance between baselines of consecutive text lines. baselineSpacing :: (DrawingCtxM m, Fractional u) => m u monoCharWidth :: (DrawingCtxM m, FromPtSize u) => m u monoSpacerWidth :: (DrawingCtxM m, FromPtSize u) => m u monoTextWidth :: (DrawingCtxM m, FromPtSize u) => Int -> m u monoTextLength :: (DrawingCtxM m, FromPtSize u) => String -> m u monoTextHeight :: (DrawingCtxM m, FromPtSize u) => m u monoNumeralHeight :: (DrawingCtxM m, FromPtSize u) => m u -- | Height of a lower case 'x' in Courier. -- -- 'x' has no ascenders or descenders. monoLowerxHeight :: (DrawingCtxM m, FromPtSize u) => m u monoDescenderDepth :: (DrawingCtxM m, FromPtSize u) => m 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 :: (DrawingCtxM m, Num u, Ord u, FromPtSize u) => String -> m (u, u) monoMultiLineTextHeight :: (DrawingCtxM m, Fractional u, FromPtSize u) => Int -> m u -- | The default padding is half of the char width. monoDefaultPadding :: (DrawingCtxM m, Fractional u, FromPtSize u) => m u -- | Vector from baseline left to center monoVecToCenter :: (DrawingCtxM m, Fractional u, Ord u, FromPtSize u) => String -> m (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, text is left-aligned. 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 curveBetween :: (Fractional u) => Point2 u -> Point2 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 -- | Shim import module for Paths. module Wumpus.Basic.Paths -- | 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) -- | Drawing round cornered polygons. module Wumpus.Basic.Paths.RoundCorners -- | The length of the control-point vector wants to be slighly longer than -- half of d (d - being the distance between the truncated -- points and the corner). cornerCurve :: (Real u, Floating u) => Point2 u -> Point2 u -> Point2 u -> Path u illustratePath :: (Fractional u) => Path u -> Graphic u -- | roundEvery throws a runtime error if the input list has less -- than 3 eleemnts. roundEvery :: (Real u, Floating u) => u -> [Point2 u] -> Path u -- | Common core for shapes -- -- ** WARNING ** - the types of Shapes and Plaintext are not ideal and -- are pending revision. module Wumpus.Basic.Shapes.Base -- | Note - this formulation prevents rounded corner shapes... -- -- Currently shapes that aren't paths: -- --
-- Coordinate -- FreeLabel ---- -- Alternative -- --
-- out_fun :: ShapeCTM u -> (Path u,sh) ---- -- All shapes expect FreeLabel are oblivious to the DrawingContext for -- the shape data Shape u t Shape :: ShapeCTM u -> (ShapeCTM u -> Path u) -> (ShapeCTM u -> t u) -> Shape u t src_ctm :: Shape u t -> ShapeCTM u path_fun :: Shape u t -> ShapeCTM u -> Path u cons_fun :: Shape u t -> ShapeCTM u -> t u type ShapeConstructor u t = ShapeCTM u -> t u borderedShape :: (Num u) => Shape u t -> Image u (t u) filledShape :: (Num u) => Shape u t -> Image u (t u) strokedShape :: (Num u) => Shape u t -> Image u (t u) 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 instance (Eq u) => Eq (ShapeCTM u) instance (Ord u) => Ord (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 data Arrowhead u Arrowhead :: DrawingR u -> ThetaLocGraphic u -> Arrowhead u retract_dist :: Arrowhead u -> DrawingR u arrow_draw :: Arrowhead u -> ThetaLocGraphic u arrowheadTip :: Arrowhead u -> Radian -> LocGraphic u tri90 :: (Floating u, Real u, FromPtSize u) => Arrowhead u tri60 :: (Floating u, Real u, FromPtSize u) => Arrowhead u tri45 :: (Floating u, Real u, FromPtSize u) => Arrowhead u otri90 :: (Floating u, Real u, FromPtSize u) => Arrowhead u otri60 :: (Floating u, Real u, FromPtSize u) => Arrowhead u otri45 :: (Floating u, Real u, FromPtSize u) => Arrowhead u barb90 :: (Floating u, Real u, FromPtSize u) => Arrowhead u barb60 :: (Floating u, Real u, FromPtSize u) => Arrowhead u barb45 :: (Floating u, Real u, FromPtSize u) => Arrowhead u perp :: (Floating u, FromPtSize u) => Arrowhead u rbracket :: (Floating u, FromPtSize u) => Arrowhead u -- | Draw arrows. -- -- ** WARNING ** - the types are wrong here and need more thought. module Wumpus.Basic.Arrows.Connectors data Connector u -- | connector with no arrow heads. connector :: ConnectorPath u -> Connector u leftArrow :: ConnectorPath u -> Arrowhead u -> Connector u rightArrow :: ConnectorPath u -> Arrowhead u -> Connector u -- | Same tip both ends. dblArrow :: ConnectorPath u -> Arrowhead u -> Connector u leftrightArrow :: ConnectorPath u -> Arrowhead u -> Arrowhead u -> Connector u strokeConnector :: (Real u, Floating u) => Connector u -> ConnectorImage u (Path u) -- | Shim module for arrow connectors and arrowheads. module Wumpus.Basic.Arrows -- | 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 -- | 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) -- | Coordinate is a bit like a shape but does not generate a path and -- cannot be scaled or rotated (it can be translated). -- -- ** WARNING ** - the types of Shapes and Coordinate are not ideal and -- are pending revision. module Wumpus.Basic.Shapes.Coordinate -- | Coordinate data CoordinateAnchor u type DCoordinateAnchor = CoordinateAnchor Double data Coordinate u type DCoordinate = Coordinate Double coordinate :: (Num u) => Point2 u -> Coordinate u coordinateMark :: (Real u, Floating u) => Coordinate u -> Image u (CoordinateAnchor u) instance (Eq u) => Eq (Coordinate u) instance (Ord u) => Ord (Coordinate u) instance (Show u) => Show (Coordinate u) instance (Eq u) => Eq (CoordinateAnchor u) instance (Ord u) => Ord (CoordinateAnchor u) instance (Show u) => Show (CoordinateAnchor u) instance (Num u) => Translate (Coordinate u) instance (Real u, Floating u) => CenterAnchor (CoordinateAnchor u) -- | Simple shapes - rectangle, circle diamond, ellipse. -- -- ** WARNING ** - the types of Shapes and Plaintext are not ideal and -- are pending revision. module Wumpus.Basic.Shapes.Derived data Rectangle u type DRectangle = Rectangle Double -- | rectangle : width * height -> shape rectangle :: (Real u, Floating u) => u -> u -> Shape u Rectangle -- | rectangle : round_length * width * height -> shape -- rrectangle :: (Real u, Floating u) => u -> u -> u -> Shape u Rectangle mkRectangle :: u -> u -> ShapeConstructor u Rectangle data Circle u type DCircle = Circle Double -- | circle : radius -> shape circle :: (Real u, Floating u) => u -> Shape u Circle data Diamond u type DDiamond = Diamond Double -- | diamond : half_width * half_height -> shape -- -- Note - args might change to tull_width and full_height... diamond :: (Real u, Floating u) => u -> u -> Shape u Diamond -- | rdiamond : round_length * half_width * half_height -> -- shape -- -- Note - args might change to full_width and full_height... rdiamond :: (Real u, Floating u) => u -> u -> u -> Shape u Diamond data Ellipse u type DEllipse = Ellipse Double -- | ellipse : x_radii * y_radii -> shape ellipse :: (Real u, Floating u) => u -> u -> Shape u Ellipse instance (Eq u) => Eq (Circle u) instance (Show u) => Show (Circle u) instance (Eq u) => Eq (Rectangle u) instance (Ord u) => Ord (Rectangle u) instance (Show u) => Show (Rectangle u) instance (Real u, Floating u) => CardinalAnchor2 (Ellipse u) instance (Real u, Floating u) => CardinalAnchor (Ellipse u) instance (Real u, Floating u) => RadialAnchor (Ellipse 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) => CardinalAnchor2 (Circle u) instance (Real u, Floating u) => CardinalAnchor (Circle u) instance (Real u, Floating u) => RadialAnchor (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) -- | Plaintext is a bit like a shape but does not generate a path and -- cannot be scaled (it can be rotated or translated). -- -- ** WARNING ** - the types of Shapes and Plaintext are not ideal and -- are pending revision. module Wumpus.Basic.Shapes.Plaintext data PlaintextAnchor u type DPlaintextAnchor = PlaintextAnchor Double data Plaintext u type DPlaintext = Plaintext Double plaintext :: (Num u) => String -> Plaintext u drawText :: (Real u, Floating u, FromPtSize u) => Plaintext u -> Image u (PlaintextAnchor u) instance (Eq u) => Eq (Plaintext u) instance (Ord u) => Ord (Plaintext u) instance (Show u) => Show (Plaintext u) instance (Num u) => Translate (Plaintext u) instance Rotate (Plaintext u) instance (Real u, Floating u) => RadialAnchor (PlaintextAnchor u) instance (Real u, Floating u) => CardinalAnchor2 (PlaintextAnchor u) instance (Real u, Floating u) => CardinalAnchor (PlaintextAnchor u) instance (Real u, Floating u) => CenterAnchor (PlaintextAnchor u) -- | Shim module for Shapes. module Wumpus.Basic.Shapes