Module

Graphics.CanvasAction.Transformation

Package
purescript-canvas-action
Repository
3ddyy/purescript-canvas-action

This module defines a free monad for working with canvas transformations in a more pleasant way. Construct transforms with the various functions, like translate, scale and matrixTransform. There are also alternate functions (denoted by a '), which take the dedicated data type for that transform, instead of Numbers, as arguments. Perform a transform with runTransform, or use transformed to also reset the transformation matrix to its previous value afterwards.

#TransformationF Source

#resetTransform Source

resetTransform :: Transformation

Reset the transformation matrix to its default value

#setTransform Source

setTransform :: Number -> Number -> Number -> Number -> Number -> Number -> Transformation

Construct a Transformation from six Numbers representing a matrix transformation, replacing the current matrix

#setTransform' Source

setTransform' :: MatrixTransform -> Transformation

Construct a Transformation from a MatrixTransform, replacing the current matrix

#getTransform Source

getTransform :: TransformationM MatrixTransform

Get the current transformation matrix

#translate Source

translate :: Number -> Number -> Transformation

Construct a Transformation from two Numbers representing translation

#translate' Source

translate' :: TranslateTransform -> Transformation

Construct a Transformation from a TranslateTransform

#scale Source

scale :: Number -> Number -> Transformation

Construct a Transformation from two Numbers representing scaling

#scale' Source

scale' :: ScaleTransform -> Transformation

Construct a Transformation from a ScaleTransform

#skew Source

skew :: Number -> Number -> Transformation

Construct a Transformation from two Numbers representing skew

#skew' Source

skew' :: SkewTransform -> Transformation

Construct a Transformation from a SkewTransform

#rotate Source

rotate :: Number -> Transformation

Construct a Transformation from a Number representing radians rotated

#matrixTransform Source

matrixTransform :: Number -> Number -> Number -> Number -> Number -> Number -> Transformation

Construct a Transformation from six Numbers representing a matrix transformation, multiplying the new matrix with the current matrix

#matrixTransform' Source

matrixTransform' :: MatrixTransform -> Transformation

Construct a Transformation from a MatrixTransform, multiplying the new matrix with the current matrix

#runTransform Source

runTransform :: forall m. MonadCanvasAction m => MonadRec m => TransformationM ~> m

Run a transformation

#transformed Source

transformed :: forall a m. MonadCanvasAction m => MonadRec m => Transformation -> m a -> m a

Run a transformation on a MonadCanvasAction, transforming back afterwards