1module Transform2D where
2{-| A library for performing [2D matrix transformations][affine].
3It is used primarily with the `groupTransform` function from `Graphics.Collage` and
4allows you to do things like rotation, scaling, translation, shearing, and reflection.
6Note that all the matrices in this library are 3x3 matrices of homogeneous
7coordinates, used for [affine transformations][affine]. Since the bottom row as
8always `0 0 1` in these matrices, it is omitted in the diagrams below.
10 [affine]: http://en.wikipedia.org/wiki/Transformation_matrix#Affine_transformations
13@docs identity, matrix, rotation, translation, scale, scaleX, scaleY
19import Native.Transform2D
21data Transform2D = Transform2D
23{-| Create an identity transform. Transforming by the identity does
24not change anything, but it can come in handy as a default or
31identity = Native.Transform2D.identity
33{-| Creates a transformation matrix. This lets you create transforms
34such as scales, shears, reflections, and translations.
41Note that `x` and `y` are the translation values.
43matrix : Float -> Float -> Float -> Float -> Float -> Float -> Transform2D
44matrix = Native.Transform2D.matrix
46{-| Creates a [rotation matrix](http://en.wikipedia.org/wiki/Rotation_matrix).
47Given an angle t, it creates a counterclockwise rotation matrix:
52rotation : Float -> Transform2D
53rotation = Native.Transform2D.rotation
55{-| Creates a transformation matrix for translation:
62translation : Float -> Float -> Transform2D
63translation x y = matrix 1 0 0 1 x y
65{-| Creates a transformation matrix for scaling by a all directions:
72scale : Float -> Transform2D
73scale s = matrix s 0 0 s 0 0
75{-| Creates a transformation for horizontal scaling -}
76scaleX : Float -> Transform2D
77scaleX x = matrix x 0 0 1 0 0
79{-| Creates a transformation for vertical scaling -}
80scaleY : Float -> Transform2D
81scaleY y = matrix 1 0 0 y 0 0
83{-| Multiplies two transforms together:
87 / ma mb mx \ / na nb nx \
88 | mc md my | . | nc nd ny |
91multiply : Transform2D -> Transform2D -> Transform2D
92multiply = 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