on master help sign in
Rename the `Matrix2D` type to `Transform2D`
commitdf5b3f59327484d9759ef703543ec9c19f11e5d4 authorEvan Czaplicki <info@elm-lang.org> dateMon 19 Aug 2013, 11:57 (13 years ago) parent4722efe
2 files changed+20−18
libraries/Graphics/Collage.elm+3−3 libraries/Transform2D.elm+17−15
libraries/Graphics/Collage.elm+3−3
@@ -4,7 +4,7 @@ module Graphics.Collage where
44import open Basics
55import List
66import Either (Either, Left, Right)
7−import Matrix2D (Matrix2D, identity)
7+import Transform2D (Transform2D, identity)
88import Native.Graphics.Collage
99import Graphics.Element (Element, Three, Pos, ElementPrim, Properties)
1010import Color (Color, black, Gradient)
@@ -76,7 +76,7 @@ data BasicForm
7676 | FShape (Either LineStyle FillStyle) Shape
7777 | FImage Int Int (Int,Int) String
7878 | FElement Element
79− | FGroup Matrix2D [Form]
79+ | FGroup Transform2D [Form]
8080
8181form : BasicForm -> Form
8282form f = { theta=0, scale=1, x=0, y=0, alpha=1, form=f }
@@ -122,7 +122,7 @@ group fs = form (FGroup identity fs)
122122
123123-- Flatten many forms into a single `Form` and then apply a matrix
124124-- transformation.
125−groupTransform : Matrix2D -> [Form] -> Form
125+groupTransform : Transform2D -> [Form] -> Form
126126groupTransform matrix fs = form (FGroup matrix fs)
127127
128128-- Rotate a form by a given angle. Rotate takes standard Elm angles (radians)
libraries/Transform2D.elm+17−15
@@ -1,19 +1,21 @@
11
2−module Matrix2D where
2+module Transform2D where
33
4−import Native.Matrix2D
4+import Native.Transform2D
55
6−data Matrix2D = Matrix2D
6+data Transform2D = Transform2D
77
8−-- Create an identity matrix.
8+-- Create an identity transform. Transforming by the identity does
9+-- not change anything, but it can come in handy as a default or
10+-- base case.
911--
1012-- / 1 0 \\
1113-- \\ 0 1 /
12−identity : Matrix2D
13−identity = Native.Matrix2D.identity
14+identity : Transform2D
15+identity = Native.Transform2D.identity
1416
15−-- Creates an arbitrary matrix. This lets you create scales, shears, reflections,
16−-- translations, or any other 2D transform.
17+-- Creates an arbitrary transformation matrix. This lets you create scales,
18+-- shears, reflections, translations, or any other 2D transform.
1719--
1820-- matrix a b c d dx dy
1921--
@@ -21,22 +23,22 @@ identity = Native.Matrix2D.identity
2123-- \\ c d /
2224--
2325-- And `dx` and `dy` are the translation values.
24−matrix : Float -> Float -> Float -> Float -> Float -> Float -> Matrix2D
25−matrix = Native.Matrix2D.matrix
26+matrix : Float -> Float -> Float -> Float -> Float -> Float -> Transform2D
27+matrix = Native.Transform2D.matrix
2628
2729-- Creates a [rotation matrix](http://en.wikipedia.org/wiki/Rotation_matrix).
2830-- Given an angle t, it creates a counterclockwise rotation matrix:
2931--
3032-- / cos t -sin t \\
3133-- \\ sin t cos t /
32−rotation : Float -> Matrix2D
33−rotation = Native.Matrix2D.rotation
34+rotation : Float -> Transform2D
35+rotation = Native.Transform2D.rotation
3436
35−-- Multiplies two matrices together:
37+-- Multiplies two transforms together:
3638--
3739-- multiply a b
3840--
3941-- / a11 a12 \\ . / b11 b12 \\
4042-- \\ a21 a22 / \\ b21 b22 /
41−multiply : Matrix2D -> Matrix2D -> Matrix2D
42−multiply = Native.Matrix2D.multiply
43+multiply : Transform2D -> Transform2D -> Transform2D
44+multiply = Native.Transform2D.multiply