1module Transform2D ( Transform2D
2 , identity, matrix, multiply
3 , rotation, translation
4 , scale, scaleX, scaleY
6{-| A library for performing [2D matrix transformations][affine].
7It is used primarily with the `groupTransform` function from `Graphics.Collage` and
8allows you to do things like rotation, scaling, translation, shearing, and reflection.
10Note that all the matrices in this library are 3x3 matrices of homogeneous
11coordinates, used for [affine transformations][affine]. Since the bottom row as
12always `0 0 1` in these matrices, it is omitted in the diagrams below.
14 [affine]: http://en.wikipedia.org/wiki/Transformation_matrix#Affine_transformations
17@docs identity, matrix, rotation, translation, scale, scaleX, scaleY
23import Native.Transform2D
25data Transform2D = Transform2D
27{-| Create an identity transform. Transforming by the identity does
28not change anything, but it can come in handy as a default or
35identity = Native.Transform2D.identity
37{-| Creates a transformation matrix. This lets you create transforms
38such as scales, shears, reflections, and translations.
45Note that `x` and `y` are the translation values.
47matrix : Float -> Float -> Float -> Float -> Float -> Float -> Transform2D
48matrix = Native.Transform2D.matrix
50{-| Creates a [rotation matrix](http://en.wikipedia.org/wiki/Rotation_matrix).
51Given an angle t, it creates a counterclockwise rotation matrix:
56rotation : Float -> Transform2D
57rotation = Native.Transform2D.rotation
59{-| Creates a transformation matrix for translation:
66translation : Float -> Float -> Transform2D
67translation x y = matrix 1 0 0 1 x y
69{-| Creates a transformation matrix for scaling by a all directions:
76scale : Float -> Transform2D
77scale s = matrix s 0 0 s 0 0
79{-| Creates a transformation for horizontal scaling -}
80scaleX : Float -> Transform2D
81scaleX x = matrix x 0 0 1 0 0
83{-| Creates a transformation for vertical scaling -}
84scaleY : Float -> Transform2D
85scaleY y = matrix 1 0 0 y 0 0
87{-| Multiplies two transforms together:
91 / ma mb mx \ / na nb nx \
92 | mc md my | . | nc nd ny |
95multiply : Transform2D -> Transform2D -> Transform2D
96multiply = Native.Transform2D.multiply
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list