wumpus-core-0.40.0: Pure Haskell PostScript and SVG generation.

PortabilityGHC
Stabilityunstable
Maintainerstephen.tetley@gmail.com

Wumpus.Core.AffineTrans

Contents

Description

Affine transformations.

The common affine transformations represented as type classes - scaling, rotation, translation.

Internally, when a Picture is composed and transformed, Wumpus only transforms the bounding box - transformations of the picture content (paths or text labels) are communicated to PostScript or SVG for final rendering. This is because Wumpus has no access to the paths that make fonts so cannot transform them directly.

Other elements - Vectors, Points, BoundingBoxes and Primtives - are also instances of the affine classes. However, generally Wumpus transforms these elements directly rather than delegating the transformation to PostScript or SVG (the situation for the Label primitive is more complicated - the start point is transformed by Wumpus but a matrix transformation is sent to PostScript to manipulate the opaque character objects).

Note - transformations on Primitives are applied to the control points of the primitive not the drawing. A scaled, stroked path will be drawn with at the standard line width rather than with a thicker line. Also, text may not render pleasantly after it has been transformed, PostScript references seem to caution against transforming text and recommend changing /scalefont instead of scaling via a transfomation.

To generate efficient PostScript, Wumpus relies on the matrix representations of the affine transformations being invertible. Do not scale elements by zero!

Synopsis

Type classes

class Transform t whereSource

Apply a matrix transformation directly.

Methods

transform :: u ~ DUnit t => Matrix3'3 u -> t -> tSource

Instances

Num u => Transform (Point2 u) 
Num u => Transform (Vec2 u) 
(Num u, Ord u) => Transform (BoundingBox u) 
(Num u, Ord u) => Transform (Picture u) 

class Rotate t whereSource

Type class for rotation.

Methods

rotate :: Radian -> t -> tSource

Instances

(Floating u, Real u) => Rotate (Point2 u) 
(Floating u, Real u) => Rotate (Vec2 u) 
(Real u, Floating u) => Rotate (BoundingBox u) 
(Real u, Floating u) => Rotate (Primitive u) 
(Real u, Floating u) => Rotate (Picture u) 

class RotateAbout t whereSource

Type class for rotation about a point.

Methods

rotateAbout :: u ~ DUnit t => Radian -> Point2 u -> t -> tSource

Instances

class Scale t whereSource

Type class for scaling.

Methods

scale :: u ~ DUnit t => u -> u -> t -> tSource

Instances

Num u => Scale (Point2 u) 
Num u => Scale (Vec2 u) 
(Num u, Ord u) => Scale (BoundingBox u) 
Num u => Scale (Primitive u) 
(Num u, Ord u) => Scale (Picture u) 

class Translate t whereSource

Type class for translation.

Methods

translate :: u ~ DUnit t => u -> u -> t -> tSource

Instances

Num u => Translate (Point2 u) 
Num u => Translate (Vec2 u) 
(Num u, Ord u) => Translate (BoundingBox u) 
Num u => Translate (Primitive u) 
(Num u, Ord u) => Translate (Picture u) 

Common rotations

rotate30 :: Rotate t => t -> tSource

Rotate by 30 degrees about the origin.

rotate30About :: (RotateAbout t, DUnit t ~ u) => Point2 u -> t -> tSource

Rotate by 30 degrees about the supplied point.

rotate45 :: Rotate t => t -> tSource

Rotate by 45 degrees about the origin.

rotate45About :: (RotateAbout t, DUnit t ~ u) => Point2 u -> t -> tSource

Rotate by 45 degrees about the supplied point.

rotate60 :: Rotate t => t -> tSource

Rotate by 60 degrees about the origin.

rotate60About :: (RotateAbout t, DUnit t ~ u) => Point2 u -> t -> tSource

Rotate by 60 degrees about the supplied point.

rotate90 :: Rotate t => t -> tSource

Rotate by 90 degrees about the origin.

rotate90About :: (RotateAbout t, DUnit t ~ u) => Point2 u -> t -> tSource

Rotate by 90 degrees about the supplied point.

rotate120 :: Rotate t => t -> tSource

Rotate by 120 degrees about the origin.

rotate120About :: (RotateAbout t, DUnit t ~ u) => Point2 u -> t -> tSource

Rotate by 120 degrees about the supplied point.

Common scalings

uniformScale :: (Scale t, DUnit t ~ u) => u -> t -> tSource

Scale both x and y dimensions by the same amount.

reflectX :: (Num u, Scale t, DUnit t ~ u) => t -> tSource

Reflect in the X-plane about the origin.

reflectY :: (Num u, Scale t, DUnit t ~ u) => t -> tSource

Reflect in the Y-plane about the origin.

Translate by a vector

translateBy :: (Translate t, DUnit t ~ u) => Vec2 u -> t -> tSource

Translate by the x and y components of a vector.

Reflections in supplied plane rather than about the origin

reflectXPlane :: (Num u, Scale t, Translate t, u ~ DUnit t) => Point2 u -> t -> tSource

Reflect in the X plane that intersects the supplied point.

reflectYPlane :: (Num u, Scale t, Translate t, u ~ DUnit t) => Point2 u -> t -> tSource

Reflect in the Y plane that intersects the supplied point.