Rasterific-0.7.4.2: A pure haskell drawing engine.

Safe HaskellNone
LanguageHaskell2010

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 .

Synopsis

Documentation

applyTransformation :: Transformation -> Point -> Point #

Effectively transform a point given a transformation.

applyVectorTransformation :: Transformation -> Vector -> Vector #

Effectively transform a vector given a transformation. The translation part won't be applied.

translate :: Vector -> Transformation #

Perform a translation of the given primitives.

fill . transform (applyTransformation $ translate (V2 100 100))
     $ rectangle (V2 40 40) 40 40

scale :: Float -> Float -> Transformation #

Perform a scaling of the given primitives.

fill . transform (applyTransformation $ scale 2 2)
     $ rectangle (V2 40 40) 40 40

rotate #

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

rotateCenter #

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

skewX :: Float -> Transformation #

Skew transformation along the X axis.

fill . transform (applyTransformation $ skewX 0.3)
     $ rectangle (V2 50 50) 80 80

skewY :: Float -> Transformation #

Skew transformation along the Y axis.

fill . transform (applyTransformation $ skewY 0.3)
     $ rectangle (V2 50 50) 80 80

toNewXBase :: Vector -> Transformation #

Given a new X-acis vector, create a rotation matrix to get into this new base, assuming an Y basis orthonormal to the X one.

inverseTransformation :: Transformation -> Maybe Transformation #

Inverse a transformation (if possible)