wumpus-core-0.35.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.

As well as Pictures, some elements - e.g. Vectors, Points and BoundingBoxes - are also instances of the affine classes. The implementation of the instances considers that under transformation these objects are implicitly within the standard affine frame (origin at point zero and unit basis vectors for the horizontal and vertical).

This assumption cannot hold for primitives because text is special in PostScript and SVG, so there are no instances of the affine classes for Primitive or PrimElement.

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 (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, Ord u) => Scale (Picture u) 

class Translate t whereSource

Type class for translation.

Methods

translate :: DUnit t -> DUnit t -> t -> tSource

Instances

Num u => Translate (Point2 u) 
Num u => Translate (Vec2 u) 
(Num u, Ord u) => Translate (BoundingBox 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.