Portability | GHC with TypeFamilies and more |
---|---|

Stability | unstable |

Maintainer | stephen.tetley@gmail.com |

Affine transformations.

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

Unlike other functional graphics systems (e.g. Clastic), Wumpus performs the affine transformations as matrix operations. This simplifies the implementation of pictures (Wumpus.Core.PictureInternal). When a picture is composed and transformed, transformations will be performed only on the bounding box in Wumpus but the transformation of the picture content (paths or text labels) will be communicated to PostScript or SVG to render. This is because Wumpus has no access to the paths that make fonts so cannot transform them directly.

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

- class Rotate t where
- class RotateAbout t where
- rotateAbout :: Radian -> Point2 (DUnit t) -> 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

Type class for rotation.

class RotateAbout t whereSource

Type class for rotation about a point.

rotateAbout :: Radian -> Point2 (DUnit t) -> t -> tSource

(Floating a, Real a) => RotateAbout (Point2 a) | |

(Floating a, Real a) => RotateAbout (Vec2 a) | |

(Floating u, Real u) => RotateAbout (Picture u) |

Type class for scaling.

Type class for translations.

# 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.