on master help sign in
Add Transform2D translation
f0b38aeMichael Sondergaard
libraries/Native/Transform2D.js+4−1
@@ -37,7 +37,9 @@ Elm.Native.Transform2D.make = function(elm) {
37 var s = Math.sin(t);
37 var s = Math.sin(t);
38 return new A([c, -s, 0, s, c, 0]);
38 return new A([c, -s, 0, s, c, 0]);
39 }
39 }
40−
40+ function translation(x,y) {
41+ return new A([1,0,x,0,1,y]);
42+ }
41 function rotate(t,m) {
43 function rotate(t,m) {
42 var c = Math.cos(t);
44 var c = Math.cos(t);
43 var s = Math.sin(t);
45 var s = Math.sin(t);
@@ -84,6 +86,7 @@ Elm.Native.Transform2D.make = function(elm) {
84 identity:identity,
86 identity:identity,
85 matrix:F6(matrix),
87 matrix:F6(matrix),
86 rotation:rotation,
88 rotation:rotation,
89+ translation:F2(translation),
87 multiply:F2(multiply)
90 multiply:F2(multiply)
88 /*
91 /*
89 transform:F7(transform),
92 transform:F7(transform),
libraries/Transform2D.elm+4−1
@@ -46,6 +46,9 @@ Given an angle t, it creates a counterclockwise rotation matrix:
46rotation : Float -> Transform2D
46rotation : Float -> Transform2D
47rotation = Native.Transform2D.rotation
47rotation = Native.Transform2D.rotation
48
48
49+translation : Float -> Float -> Transform2D
50+translation = Native.Transform2D.translation
51+
49{-| Multiplies two transforms together:
52{-| Multiplies two transforms together:
50
53
51 multiply a b
54 multiply a b
@@ -54,4 +57,4 @@ rotation = Native.Transform2D.rotation
54 \ a21 a22 / \ b21 b22 /
57 \ a21 a22 / \ b21 b22 /
55-}
58-}
56multiply : Transform2D -> Transform2D -> Transform2D
59multiply : Transform2D -> Transform2D -> Transform2D
57−multiply = Native.Transform2D.multiply
60+multiply = Native.Transform2D.multiply