Portability | GHC |
---|---|
Stability | highly unstable |
Maintainer | Stephen Tetley <stephen.tetley@gmail.com> |
Construction of pictures, paths and text labels.
- frame :: (Real u, Floating u, FromPtSize u) => [Primitive u] -> Picture u
- multi :: (Fractional u, Ord u) => [Picture u] -> Picture u
- path :: Point2 u -> [PrimPathSegment u] -> PrimPath u
- lineTo :: Point2 u -> PrimPathSegment u
- curveTo :: Point2 u -> Point2 u -> Point2 u -> PrimPathSegment u
- vertexPath :: [Point2 u] -> PrimPath u
- curvedPath :: [Point2 u] -> PrimPath u
- xlinkhref :: String -> XLink
- class Stroke t where
- zostroke :: Num u => PrimPath u -> Primitive u
- zcstroke :: Num u => PrimPath u -> Primitive u
- class Fill t where
- zfill :: Num u => PrimPath u -> Primitive u
- class Ellipse t where
- ellipse :: Fractional u => t -> u -> u -> Point2 u -> Primitive u
- zellipse :: Num u => u -> u -> Point2 u -> Primitive u
- clip :: (Num u, Ord u) => PrimPath u -> Picture u -> Picture u
- class TextLabel t where
- ztextlabel :: Num u => String -> Point2 u -> Primitive u
- extendBoundary :: (Num u, Ord u) => u -> u -> Picture u -> Picture u
- picOver :: (Num u, Ord u) => Picture u -> Picture u -> Picture u
- picMoveBy :: (Num u, Ord u) => Picture u -> Vec2 u -> Picture u
- picBeside :: (Num u, Ord u) => Picture u -> Picture u -> Picture u
- printPicture :: (Num u, PSUnit u) => Picture u -> IO ()
- illustrateBounds :: (Real u, Floating u, FromPtSize u) => RGBi -> Picture u -> Picture u
- illustrateBoundsPrim :: (Real u, Floating u, FromPtSize u) => RGBi -> Primitive u -> Picture u
- illustrateControlPoints :: (Real u, Floating u, FromPtSize u) => RGBi -> Primitive u -> Picture u
Construction
frame :: (Real u, Floating u, FromPtSize u) => [Primitive u] -> Picture uSource
Lift a list of primitives to a composite picture.
The order of the list maps to the zorder - the front of the list is drawn at the top.
This function throws an error when supplied the empty list.
multi :: (Fractional u, Ord u) => [Picture u] -> Picture uSource
Place multiple pictures within the standard affine frame.
This function throws an error when supplied the empty list.
path :: Point2 u -> [PrimPathSegment u] -> PrimPath uSource
Create a Path from a start point and a list of PathSegments.
lineTo :: Point2 u -> PrimPathSegment uSource
Create a straight-line PathSegment.
vertexPath :: [Point2 u] -> PrimPath uSource
Convert the list of vertices to a path of straight line segments.
curvedPath :: [Point2 u] -> PrimPath uSource
Convert a list of vertices to a path of curve segments. The first point in the list makes the start point, each curve segment thereafter takes 3 points. Spare points at the end are discarded.
Constructing primitives
Create a open, stroked path (ostroke
) or a closed, stroked
path (cstroke
).
ostroke
and cstroke
are overloaded to make attributing
the path more convenient.
Stroke () | |
Stroke RGBi | |
Stroke StrokeAttr | |
Stroke XLink | |
Stroke [StrokeAttr] | |
Stroke ([StrokeAttr], XLink) | |
Stroke (RGBi, [StrokeAttr]) | |
Stroke (RGBi, StrokeAttr) | |
Stroke (RGBi, XLink) | |
Stroke (StrokeAttr, XLink) | |
Stroke (RGBi, [StrokeAttr], XLink) | |
Stroke (RGBi, StrokeAttr, XLink) |
Create a filled path (fill
). Fills only have one
property - colour. But there are various representations of
colour.
fill ()
will fill with the default colour - black.
Create an ellipse, the ellipse will be filled unless the supplied attributes imply a stroked ellipse, e.g.:
ellipse (LineWidth 4) zeroPt 40 40
Note - within Wumpus, ellipses are considered an unfortunate
but useful optimization. Drawing good cicles with Beziers
needs at least eight curves, but drawing them with
PostScript's arc
command is a single operation. For
drawings with many dots (e.g. scatter plots) it seems sensible
to employ this optimaztion.
A deficiency of Wumpus's ellipse is that (non-uniformly) scaling a stroked ellipse also (non-uniformly) scales the pen it is drawn with. Where the ellipse is wider, the pen stroke will be wider too.
ellipse :: Fractional u => t -> u -> u -> Point2 u -> Primitive uSource
Ellipse () | |
Ellipse RGBi | |
Ellipse StrokeAttr | |
Ellipse XLink | |
Ellipse [StrokeAttr] | |
Ellipse ([StrokeAttr], XLink) | |
Ellipse (RGBi, [StrokeAttr]) | |
Ellipse (RGBi, StrokeAttr) | |
Ellipse (RGBi, XLink) | |
Ellipse (StrokeAttr, XLink) | |
Ellipse (RGBi, [StrokeAttr], XLink) |
clip :: (Num u, Ord u) => PrimPath u -> Picture u -> Picture uSource
Clip a picture with respect to the supplied path.
Create a text label. The string should not contain newline
or tab characters. Use multilabel
to create text with
multiple lines.
textlabel
is overloaded to make attributing the label more
convenient.
Unless a FontAttr
is specified, the label will use 14pt
Courier.
The supplied point is is the bottom left corner.
ztextlabel :: Num u => String -> Point2 u -> Primitive uSource
Create a label where the font is Courier
, text size is 14pt
and colour is black.
Operations
extendBoundary :: (Num u, Ord u) => u -> u -> Picture u -> Picture uSource
Extend the bounding box of a picture.
The bounding box is both horizontal directions by x
and
both vertical directions by y
. x
and y
must be positive
This function cannot be used to shrink a boundary.
Picture composition
picOver :: (Num u, Ord u) => Picture u -> Picture u -> Picture uSource
picOver
: picture -> picture -> picture
Draw the first picture on top of the second picture - neither picture will be moved.
picMoveBy :: (Num u, Ord u) => Picture u -> Vec2 u -> Picture uSource
picMoveBy
: picture -> vector -> picture
Move a picture by the supplied vector.
picBeside :: (Num u, Ord u) => Picture u -> Picture u -> Picture uSource
picBeside
: picture -> picture -> picture
Move the second picture to sit at the right side of the first picture
Illustrating pictures and primitives
printPicture :: (Num u, PSUnit u) => Picture u -> IO ()Source
Print the syntax tree of a Picture to the console.
illustrateBounds :: (Real u, Floating u, FromPtSize u) => RGBi -> Picture u -> Picture uSource
illustrateBounds
: colour -> picture -> picture
Draw the picture on top of an image of its bounding box. The bounding box image will be drawn in the supplied colour.
illustrateBoundsPrim :: (Real u, Floating u, FromPtSize u) => RGBi -> Primitive u -> Picture uSource
illustrateBoundsPrim
: colour -> primitive -> picture
Draw the primitive on top of an image of its bounding box. The bounding box image will be drawn in the supplied colour.
The result will be lifted from Primitive to Picture.
illustrateControlPoints :: (Real u, Floating u, FromPtSize u) => RGBi -> Primitive u -> Picture uSource
Generate the control points illustrating the Bezier curves within a picture.
This has no effect on TextLabels.
Pseudo control points are generated for ellipses,
although strictly speaking ellipses do not use Bezier
curves - they are implemented with PostScript's
arc
command.