-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | 2D graphics library with integrated TikZ output. -- -- A high-level and easy to use graphics library with integrated TikZ -- output. -- -- Craftwerk is a high-level 2D vector graphics library for output of -- TikZ pictures that can be typeset using (pdf)LaTeX. The TikZ library -- and documentation can be found at: -- http://sourceforge.net/projects/pgf. -- -- Craftwerk tries to encapsulate the graphics backend such that figures -- can also be rendered with a Cairo backend and quickly displayed in a -- Gtk window. The aim is to support TikZ and Cairo seamlessly as -- possible, meaning that graphics produced with either backend should -- look as similar as possible. Other backends are easily written and the -- aim is to provide generic fallback functions for features that are not -- natively supported by some backend. -- -- Thanks to Jannis Harder for some contributions and ideas to the -- library. @package craftwerk @version 0.1 -- | Craftwerk uses the Data.Colour package to represent colours in -- styles. module Graphics.Craftwerk.Core.Color -- | The colour type used by Craftwerk type FigureColor = Colour Double -- | Returns the i-th of 16 basic named colours (i % 16 to be precise). integralColor :: Integral a => a -> FigureColor -- | Styles in craftwerk are nodes in the figure tree and the style at the -- node is applied to all subnodes. If a field of a style is empty (i.e -- its value is Nothing) the value of the next parent style node -- is applied. module Graphics.Craftwerk.Core.Style -- | A record holding all possible properties. data StyleProperties StyleProperties :: Maybe Double -> Maybe FigureColor -> Maybe FigureColor -> Maybe Bool -> Maybe Bool -> Maybe Bool -> Maybe Bool -> Maybe [Double] -> Maybe Double -> Maybe LineCap -> Maybe LineJoin -> Maybe Double -> Maybe ArrowTips -> StyleProperties lineWidth :: StyleProperties -> Maybe Double lineColor :: StyleProperties -> Maybe FigureColor fillColor :: StyleProperties -> Maybe FigureColor fill :: StyleProperties -> Maybe Bool stroke :: StyleProperties -> Maybe Bool clip :: StyleProperties -> Maybe Bool closePath :: StyleProperties -> Maybe Bool dashes :: StyleProperties -> Maybe [Double] dashPhase :: StyleProperties -> Maybe Double lineCap :: StyleProperties -> Maybe LineCap lineJoin :: StyleProperties -> Maybe LineJoin miterLimit :: StyleProperties -> Maybe Double arrowTips :: StyleProperties -> Maybe ArrowTips data LineCap CapRect :: LineCap CapButt :: LineCap CapRound :: LineCap data LineJoin JoinRound :: LineJoin JoinBevel :: LineJoin JoinMiter :: LineJoin data ArrowTip TipNone :: ArrowTip TipDefault :: ArrowTip -- | A style where no property has been set. emptyStyle :: StyleProperties -- | Alias for empty style, makes style construction nicer. newStyle :: StyleProperties -- | The default style used at the root node of any Figure. defaultStyle :: StyleProperties setLineWidth :: Maybe Double -> StyleProperties fillOnly :: StyleProperties strokeOnly :: StyleProperties -- | Alias for 'Just True' to make style specification more convenient. yes :: Maybe Bool -- | Alias for 'Just False' to make style specification more convenient. no :: Maybe Bool -- | Make a rgb color property. rgb :: Double -> Double -> Double -> Maybe FigureColor -- | Alias for Just width :: Double -> Maybe Double -- | Width 0.2. verythin :: Maybe Double -- | Width 0.4. thin :: Maybe Double -- | Width 0.6. semithick :: Maybe Double -- | Width 0.8. thick :: Maybe Double -- | Width 1.2. verythick :: Maybe Double -- | Width 1.6. ultrathick :: Maybe Double -- | Alias for Just. limit :: Double -> Maybe Double -- | Alias for Just. phase :: Double -> Maybe Double -- | Read a property from a style property record returning the value of -- the default style if the value is Nothing. getProperty :: StyleProperties -> (StyleProperties -> Maybe a) -> a -- | Merge two property records, where the second argument overwrites -- fields of the first unless a field is Nothing. mergeProperties :: StyleProperties -> StyleProperties -> StyleProperties -- | Arrow tip styles can be specified by using the notation 'arrow -- (<==)' arrow :: (ArrowDummy -> ArrowTips) -> Maybe ArrowTips (<=>) :: ArrowDummy -> ArrowTips (===) :: ArrowDummy -> ArrowTips (==>) :: ArrowDummy -> ArrowTips (<==) :: ArrowDummy -> ArrowTips instance Show ArrowDummy instance Show ArrowTip instance Eq ArrowTip instance Show LineCap instance Eq LineCap instance Show LineJoin instance Eq LineJoin instance Show StyleProperties instance Eq StyleProperties -- | A Figure is a description of a 2D vector graphic. Affine -- transformations and styles apply to all subfigures. When a subfigure -- of a style node contains another style node the style properties will -- be overwritten where the deeper node specifies it. module Graphics.Craftwerk.Core.Figure type Point = (Double, Double) type Vector = Point type Line = [Point] type Path = [Segment] -- | Path creation data Segment MoveTo :: Point -> Segment LineSegment :: Point -> Segment ArcSegment :: Point -> Double -> Double -> Double -> Segment CurveSegment :: Point -> Point -> Point -> Segment -- | The main datatype describing an arbitrary figure. data Figure Blank :: Figure Transform :: Transform -> Figure -> Figure Canvas :: Transform -> Figure -> Figure Composition :: [Figure] -> Figure Style :: StyleProperties -> Figure -> Figure Path :: Path -> Figure Circle :: Point -> Double -> Figure Grid :: Vector -> Double -> Double -> Figure Text :: String -> Figure NoDecorations :: Figure -> Figure data Transform Rotate :: Double -> Transform Scale :: Vector -> Transform Translate :: Vector -> Transform blank :: Figure -- | Transforms a coordinate transformation 'Transform t f' into a canvas -- transformation 'Canvas t f'. canvas :: Figure -> Figure -- | Applies a coordinate rotation. rotate :: Double -> Figure -> Figure -- | Applies a coordinate scaling. scale :: Vector -> Figure -> Figure -- | Applies a coordinate translation. translate :: Vector -> Figure -> Figure -- | Combines figures which are drawn in the order of the figures in the -- list. composition :: [Figure] -> Figure -- | Applies a style to the given figure style :: StyleProperties -> Figure -> Figure -- | Generate a figure from a path. path :: Path -> Figure -- | Generates a MoveTo segment moveTo :: Point -> Segment -- | Generates a LineSegment segment. lineTo :: Point -> Segment -- | Generates an ArcSegment segment. arc :: Point -> Double -> Double -> Double -> Segment -- | Generates a CurveSegment segment. curveTo :: Point -> Point -> Point -> Segment -- | Converts a line to a figure line :: Line -> Figure -- | Generate a circle figure at a point with given radius. circle :: Point -> Double -> Figure -- | Generate a grid spanning from (0,0) to (x,y) taking steps (xs,ys). grid :: Vector -> Vector -> Figure -- | Generate a text at (0,0) text :: String -> Figure point :: Double -> Double -> Point lineToPath :: Line -> Path -- | Construct a rectangle path from origin and extent. rectangle :: Point -> Vector -> Line -- | Rectangle with origin (0,0) and extent (1,1) unitRectangle :: Line instance Show Segment instance Eq Segment instance Show Transform instance Eq Transform instance Show Figure instance Eq Figure instance Monoid Figure -- | Convert a figure to a LaTeX TikZ -- (http://sourceforge.net/projects/pgf/develop) string. module Graphics.Craftwerk.Core.Driver.Tikz -- | Convert a Craftwerk Figure to a TikZ picture environment string figureToTikzPicture :: Figure -> String -- | Functions that convert figures into figures that use less primitives -- such that drivers only need to implement basic functionalities. module Graphics.Craftwerk.Core.Driver.Generic -- | At the moment only Circle and Grid figures are converted -- to paths. genericFigure :: Figure -> Figure -- | Creates arrow tip figure for a given path arrowTipsForPath :: [Segment] -> Double -> (ArrowTip, ArrowTip) -> Figure -- | Angle conversion radians :: Floating a => a -> a -- | Angle conversion degree :: Floating a => a -> a instance Eq Tangent instance Show Tangent -- | A high-level and easy to use graphics library with several backends, -- currently including TikZ, Cairo (craftwerk-cairo) with Gtk UI -- (craftwerk-gtk) and Gloss (craftwerk-gloss). module Graphics.Craftwerk.Core