Portability | GHC |
---|---|
Stability | unstable |
Maintainer | stephen.tetley@gmail.com |
This module re-exports types and functions from Wumpus.Core.PictureInternal but makes them opaque. Contructors are provided by Wumpus.Core.Picture.
Note - whilst the Picture types support the Eq class the implementations are not efficient, e.g. In the case of Primitive, one of the constructors has to unwind a functional Hughes list. The Eq instance is considered a legacy feature (or burden) as the types have expanded.
- data Picture
- data FontCtx
- data Primitive
- data XLink
- data PrimPath
- data PrimPathSegment
- data AbsPathSegment
- data PrimLabel
- type KerningChar = (Double, EscapedChar)
- class Format a where
- format :: a -> Doc
- stringformat :: String -> Doc
Picture types
Picture is a rose tree. Leaves themselves are attributed with colour, line-width etc. The unit of a Picture is fixed to Double representing PostScript's Point unit. Output is always gewnerated with PostScript points - other units are converted to PostScript points before building the Picture.
By attributing leaves with their drawing properties, Wumpus's picture representaion is not directly matched to PostScript. PostScript has a global graphics state (that allows local modifaction) from where drawing properties are inherited. Wumpus has no attribute inheritance.
Omitting some details of the list representation, Picture is a simple non-empty rose tree via:
tree = Leaf [primitive] | Picture [tree]
Set the font delta for SVG rendering.
Note - this does not change the default colour or font style. It is solely a backdoor into the SVG renderer to potential allow some code size reductions.
Wumpus's drawings are built from two fundamental primitives: paths (straight line segments and Bezier curves) and labels (single lines of text).
Ellipses are a included as a primitive only for optimization
- drawing a reasonable circle with Bezier curves needs at
least eight curves. This is inconvenient for drawing dots
which can otherwise be drawn with a single arc
command.
Wumpus does not follow PostScript employing arc as a general path primitive - arcs are used only to draw ellipses. This is because arcs do not enjoy the nice properties of Bezier curves, whereby the affine transformation of a Bezier curve can simply be achieved by the affine transformation of it's control points.
Ellipses are represented by their center, half-width and half-height. Half-width and half-height are used so the bounding box can be calculated using only multiplication, and thus initially only obliging a Num constraint on the unit. Though typically for affine transformations a Fractional constraint is also obliged.
Clipping is represented by a pair of the clipping path and the primitive embedded within the path.
To represent XLink hyperlinks, Primitives can be annotated with some a hyperlink (likewise a passive font change for better SVG code generation) and grouped - a hyperlinked arrow would want the tip and the arrow body both to be incorporated in thelink even though they are two drawing primitives.
This means that Primitives aren't strictly primitive as the actual implementation is a tree.
Primitives can be grouped with hyperlinks in SVG output.
Note - this is always printed as xlink:href=...
. Other
types of xlink can be modelled with the unrestrained
SvgAnno type.
PrimPath - a list of path segments and a CTM.
Start point is the dx - dy of the CTM.
data PrimPathSegment Source
PrimPathSegment - either a relative cubic Bezier curve-to or a relative line-to.
data AbsPathSegment Source
AbsPathSegment - either a cubic Bezier curve or a line.
Note this data type is transitory - it is only used as a convenience to build relative paths. Hence the unit type is parametric.
Label - represented by baseline-left point and text.
Baseline-left is the dx * dy of the PrimCTM.
type KerningChar = (Double, EscapedChar)Source
A Char (possibly escaped) paired with its displacement from the previous KerningChar.
Format Double | |
Format Int | |
Format Integer | |
Format EscapedChar | |
Format EscapedText | |
Format Radian | |
Format RGBi | |
Format EllipseProps | |
Format LabelProps | |
Format PathProps | |
Format PrimCTM | |
Format PrimEllipse | |
Format LabelBody | |
Format PrimLabel | |
Format PrimPathSegment | |
Format PrimPath | |
Format XLink | |
Format Primitive | |
Format Picture | |
Format u => Format (Matrix3'3 u) | |
Format u => Format (Point2 u) | |
Format u => Format (Vec2 u) | |
Format u => Format (BoundingBox u) |
stringformat :: String -> DocSource
stringformat
: String -> Doc
The format combinators are not exported by Wumpus-Core,
however for debugging unit types might need to be made
instances of the Format
class.
To define Format instances render the unit type to a String
then use stringformat
, e.g:
instance Format Pica where format a = stringformat (show a)