on master help sign in
Add Transform2D translation

I'm unsure of why so much code is commented out in Transform2D. A more mature version of this module could generally be useful for doing collision detection/modelling scenegraphs outside of the Collage interface.

commitf0b38aeb3c980bd943f0fa2320ebe35d92068c06 authorMichael Sondergaard <msond@cs.au.dk> dateMon 21 Oct 2013, 13:59 (13 years ago) parent71fb0a3
2 files changed+8−2
libraries/Native/Transform2D.js+4−1 libraries/Transform2D.elm+4−1
libraries/Native/Transform2D.js+4−1
@@ -37,7 +37,9 @@ Elm.Native.Transform2D.make = function(elm) {
3737 var s = Math.sin(t);
3838 return new A([c, -s, 0, s, c, 0]);
3939 }
40−
40+ function translation(x,y) {
41+ return new A([1,0,x,0,1,y]);
42+ }
4143 function rotate(t,m) {
4244 var c = Math.cos(t);
4345 var s = Math.sin(t);
@@ -84,6 +86,7 @@ Elm.Native.Transform2D.make = function(elm) {
8486 identity:identity,
8587 matrix:F6(matrix),
8688 rotation:rotation,
89+ translation:F2(translation),
8790 multiply:F2(multiply)
8891 /*
8992 transform:F7(transform),
libraries/Transform2D.elm+4−1
@@ -46,6 +46,9 @@ Given an angle t, it creates a counterclockwise rotation matrix:
4646rotation : Float -> Transform2D
4747rotation = Native.Transform2D.rotation
4848
49+translation : Float -> Float -> Transform2D
50+translation = Native.Transform2D.translation
51+
4952{-| Multiplies two transforms together:
5053
5154 multiply a b
@@ -54,4 +57,4 @@ rotation = Native.Transform2D.rotation
5457 \ a21 a22 / \ b21 b22 /
5558-}
5659multiply : Transform2D -> Transform2D -> Transform2D
57−multiply = Native.Transform2D.multiply
60+multiply = Native.Transform2D.multiply