| Safe Haskell | None |
|---|
Graphics.Rasterific.Transformations
Description
This module provide some helpers in order to perform basic geometric transformation on the drawable primitives.
You can combine the transformation is mappend or
the `(<>)` operator from Data.Monoid .
- data Transformation = Transformation {
- _transformA :: !Float
- _transformC :: !Float
- _transformE :: !Float
- _transformB :: !Float
- _transformD :: !Float
- _transformF :: !Float
- applyTransformation :: Transformation -> Point -> Point
- translate :: Vector -> Transformation
- scale :: Float -> Float -> Transformation
- rotate :: Float -> Transformation
- rotateCenter :: Float -> Point -> Transformation
- inverseTransformation :: Transformation -> Transformation
Documentation
data Transformation Source
Represent a 3*3 matrix for homogenous coordinates.
| A C E | | B D F | | 0 0 1 |
Constructors
| Transformation | |
Fields
| |
Instances
applyTransformation :: Transformation -> Point -> PointSource
Effectively transform a point given a transformation.
translate :: Vector -> TransformationSource
Perform a translation of the given primitives.
fill . transform (applyTransformation $ translate (V2 100 100))
$ rectangle (V2 40 40) 40 40
scale :: Float -> Float -> TransformationSource
Perform a scaling of the given primitives.
fill . transform (applyTransformation $ scale 2 2)
$ rectangle (V2 40 40) 40 40
Arguments
| :: Float | Rotation angle in radian. |
| -> Transformation |
Create a transformation representing a rotation on the plane.
fill . transform (applyTransformation $ rotate 0.2)
$ rectangle (V2 40 40) 120 120
Arguments
| :: Float | Rotation angle in radian |
| -> Point | Rotation center |
| -> Transformation |
Create a transformation representing a rotation on the plane. The rotation center is given in parameter
fill . transform (applyTransformation $ rotateCenter 0.2 (V2 200 200))
$ rectangle (V2 40 40) 120 120
inverseTransformation :: Transformation -> TransformationSource
Inverse a transformation (if possible)