Portability | GHC |
---|---|
Stability | unstable |
Maintainer | stephen.tetley@gmail.com |
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!
- class Transform t where
- class Rotate t where
- class RotateAbout t where
- rotateAbout :: u ~ DUnit t => Radian -> Point2 u -> t -> t
- class Scale t where
- class Translate t where
- rotate30 :: Rotate t => t -> t
- rotate30About :: (RotateAbout t, DUnit t ~ u) => Point2 u -> t -> t
- rotate45 :: Rotate t => t -> t
- rotate45About :: (RotateAbout t, DUnit t ~ u) => Point2 u -> t -> t
- rotate60 :: Rotate t => t -> t
- rotate60About :: (RotateAbout t, DUnit t ~ u) => Point2 u -> t -> t
- rotate90 :: Rotate t => t -> t
- rotate90About :: (RotateAbout t, DUnit t ~ u) => Point2 u -> t -> t
- rotate120 :: Rotate t => t -> t
- rotate120About :: (RotateAbout t, DUnit t ~ u) => Point2 u -> t -> t
- uniformScale :: (Scale t, DUnit t ~ u) => u -> t -> t
- reflectX :: (Num u, Scale t, DUnit t ~ u) => t -> t
- reflectY :: (Num u, Scale t, DUnit t ~ u) => t -> t
- translateBy :: (Translate t, DUnit t ~ u) => Vec2 u -> t -> t
- reflectXPlane :: (Num u, Scale t, Translate t, u ~ DUnit t) => Point2 u -> t -> t
- reflectYPlane :: (Num u, Scale t, Translate t, u ~ DUnit t) => Point2 u -> t -> t
Type classes
Apply a matrix transformation directly.
Type class for rotation.
class RotateAbout t whereSource
Type class for rotation about a point.
rotateAbout :: u ~ DUnit t => Radian -> Point2 u -> t -> tSource
(Floating u, Real u) => RotateAbout (Point2 u) | |
(Floating u, Real u) => RotateAbout (Vec2 u) | |
(Real u, Floating u) => RotateAbout (BoundingBox u) | |
(Real u, Floating u) => RotateAbout (Picture u) |
Type class for scaling.
Type class for translation.
Common rotations
rotate30About :: (RotateAbout t, DUnit t ~ u) => Point2 u -> t -> tSource
Rotate by 30 degrees about the supplied point.
rotate45About :: (RotateAbout t, DUnit t ~ u) => Point2 u -> t -> tSource
Rotate by 45 degrees about the supplied point.
rotate60About :: (RotateAbout t, DUnit t ~ u) => Point2 u -> t -> tSource
Rotate by 60 degrees about the supplied point.
rotate90About :: (RotateAbout t, DUnit t ~ u) => Point2 u -> t -> tSource
Rotate by 90 degrees about the supplied point.
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.
Translate by a vector
translateBy :: (Translate t, DUnit t ~ u) => Vec2 u -> t -> tSource
Translate by the x and y components of a vector.