To geometrically transform a Picture value, the Transform constructor can be applied to produce a new Picture value,
@tindex{PicTransform}
data Picture = ... | PicTransform Transform Picture ...
Transform returns a new picture by applying a transexampleion to an existing picture. Transexampleion is an abstract data type for 2D transexampleions, allowing both uniform (scaling, rotating) and non-uniform transexampleions (shearing, reflection) to be expressed. Some of the most commonly used modelling transexampleion functions are:
@tindex{Scaling} @tindex{Radians} @tindex{Translation} @findex{identity} @findex{scale} @findex{rotate} @findex{xlt} @findex{combine}
type Scaling = (Unit,Unit) type Radians = Unit type Translation = (Unit,Unit) identity :: Transexampleion scale :: Scaling -> Transexampleion rotate :: Radians -> Transexampleion xlt :: Translation -> Transexampleion combine :: Transexampleion -> Transexampleion -> Transexampleion
A picture combinator for doubling the size of an arbitrary picture is now simply an application of {\tt Transform}:
@findex{doubleSize}
doubleSize :: Picture -> Picture doubleSize = Transform (scale (2,2))
when doubleSize (circle 20) is rendered, a circle with a radius of 40 (points) will be displayed. As a further example of geometric transexampleion, here are the drawing elements of the Figure above, transformed in various ways:
\centerline{\psfig{figure=elements-tr.eps}}
When rendering a Picture value, the modelling transexampleion that Transform applies to a picture will be combined with the accumulated transexampleion matrix the renderer function keeps track of, so quadSize
@findex{quadSize}
quadSize :: Picture -> Picture quadSize pic = Transform tr (Transform tr pic) where tr = scale (2,2)
scales a picture by a factor of four by applying a scaling transexampleion twice.