on master help sign in
Rename the `Matrix2D` type to `Transform2D`
df5b3f5Evan Czaplicki
libraries/Graphics/Collage.elm+3−3
@@ -4,7 +4,7 @@ module Graphics.Collage where
4import open Basics
4import open Basics
5import List
5import List
6import Either (Either, Left, Right)
6import Either (Either, Left, Right)
7−import Matrix2D (Matrix2D, identity)
7+import Transform2D (Transform2D, identity)
8import Native.Graphics.Collage
8import Native.Graphics.Collage
9import Graphics.Element (Element, Three, Pos, ElementPrim, Properties)
9import Graphics.Element (Element, Three, Pos, ElementPrim, Properties)
10import Color (Color, black, Gradient)
10import Color (Color, black, Gradient)
@@ -76,7 +76,7 @@ data BasicForm
76 | FShape (Either LineStyle FillStyle) Shape
76 | FShape (Either LineStyle FillStyle) Shape
77 | FImage Int Int (Int,Int) String
77 | FImage Int Int (Int,Int) String
78 | FElement Element
78 | FElement Element
79− | FGroup Matrix2D [Form]
79+ | FGroup Transform2D [Form]
80
80
81form : BasicForm -> Form
81form : BasicForm -> Form
82form f = { theta=0, scale=1, x=0, y=0, alpha=1, form=f }
82form f = { theta=0, scale=1, x=0, y=0, alpha=1, form=f }
@@ -122,7 +122,7 @@ group fs = form (FGroup identity fs)
122
122
123-- Flatten many forms into a single `Form` and then apply a matrix
123-- Flatten many forms into a single `Form` and then apply a matrix
124-- transformation.
124-- transformation.
125−groupTransform : Matrix2D -> [Form] -> Form
125+groupTransform : Transform2D -> [Form] -> Form
126groupTransform matrix fs = form (FGroup matrix fs)
126groupTransform matrix fs = form (FGroup matrix fs)
127
127
128-- Rotate a form by a given angle. Rotate takes standard Elm angles (radians)
128-- Rotate a form by a given angle. Rotate takes standard Elm angles (radians)
libraries/Transform2D.elm+17−15
@@ -1,19 +1,21 @@
1
1
2−module Matrix2D where
2+module Transform2D where
3
3
4−import Native.Matrix2D
4+import Native.Transform2D
5
5
6−data Matrix2D = Matrix2D
6+data Transform2D = Transform2D
7
7
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.
9--
11--
10-- / 1 0 \\
12-- / 1 0 \\
11-- \\ 0 1 /
13-- \\ 0 1 /
12−identity : Matrix2D
14+identity : Transform2D
13−identity = Native.Matrix2D.identity
15+identity = Native.Transform2D.identity
14
16
15−-- Creates an arbitrary matrix. This lets you create scales, shears, reflections,
17+-- Creates an arbitrary transformation matrix. This lets you create scales,
16−-- translations, or any other 2D transform.
18+-- shears, reflections, translations, or any other 2D transform.
17--
19--
18-- matrix a b c d dx dy
20-- matrix a b c d dx dy
19--
21--
@@ -21,22 +23,22 @@ identity = Native.Matrix2D.identity
21-- \\ c d /
23-- \\ c d /
22--
24--
23-- And `dx` and `dy` are the translation values.
25-- And `dx` and `dy` are the translation values.
24−matrix : Float -> Float -> Float -> Float -> Float -> Float -> Matrix2D
26+matrix : Float -> Float -> Float -> Float -> Float -> Float -> Transform2D
25−matrix = Native.Matrix2D.matrix
27+matrix = Native.Transform2D.matrix
26
28
27-- Creates a [rotation matrix](http://en.wikipedia.org/wiki/Rotation_matrix).
29-- Creates a [rotation matrix](http://en.wikipedia.org/wiki/Rotation_matrix).
28-- Given an angle t, it creates a counterclockwise rotation matrix:
30-- Given an angle t, it creates a counterclockwise rotation matrix:
29--
31--
30-- / cos t -sin t \\
32-- / cos t -sin t \\
31-- \\ sin t cos t /
33-- \\ sin t cos t /
32−rotation : Float -> Matrix2D
34+rotation : Float -> Transform2D
33−rotation = Native.Matrix2D.rotation
35+rotation = Native.Transform2D.rotation
34
36
35−-- Multiplies two matrices together:
37+-- Multiplies two transforms together:
36--
38--
37-- multiply a b
39-- multiply a b
38--
40--
39-- / a11 a12 \\ . / b11 b12 \\
41-- / a11 a12 \\ . / b11 b12 \\
40-- \\ a21 a22 / \\ b21 b22 /
42-- \\ a21 a22 / \\ b21 b22 /
41−multiply : Matrix2D -> Matrix2D -> Matrix2D
43+multiply : Transform2D -> Transform2D -> Transform2D
42−multiply = Native.Matrix2D.multiply
44+multiply = Native.Transform2D.multiply