on master help sign in
Minor bug fixes in RTS and libraries.
d31acc5evancz
libraries/Graphics/Collage.elm+7−7
@@ -7,7 +7,7 @@ import Either
7import Native.Matrix2D as Matrix
7import Native.Matrix2D as Matrix
8import Native.Graphics.Collage as N
8import Native.Graphics.Collage as N
9import Graphics.Element
9import Graphics.Element
10−import Color as Color
10+import Color
11
11
12type Form = {
12type Form = {
13 theta : Float,
13 theta : Float,
@@ -53,7 +53,7 @@ defaultLine = {
53 cap = Flat,
53 cap = Flat,
54 join = Sharp 10,
54 join = Sharp 10,
55 dashing = [],
55 dashing = [],
56− dashOffset = 0,
56+ dashOffset = 0
57 }
57 }
58
58
59-- Create a solid line style with a given color.
59-- Create a solid line style with a given color.
@@ -73,11 +73,11 @@ data BasicForm
73 | FShape (Either LineStyle FillStyle) Shape
73 | FShape (Either LineStyle FillStyle) Shape
74 | FImage Int Int (Int,Int) String
74 | FImage Int Int (Int,Int) String
75 | FElement Element
75 | FElement Element
76− | FGroup Matrix [Form]
76+ | FGroup Matrix2D [Form]
77
77
78form f = { theta = 0, scale = 1, x = 0, y = 0, form = f }
78form f = { theta = 0, scale = 1, x = 0, y = 0, form = f }
79
79
80−fill style shape = form (FShape (Right style) shape)
80+fill style shape = form (FShape (Either.Right style) shape)
81
81
82-- Create a filled in shape.
82-- Create a filled in shape.
83filled : Color -> Shape -> Form
83filled : Color -> Shape -> Form
@@ -94,7 +94,7 @@ gradient grad shape = fill (Gradient grad) shape
94
94
95-- Outline a shape with a given line style.
95-- Outline a shape with a given line style.
96outlined : LineStyle -> Shape -> Form
96outlined : LineStyle -> Shape -> Form
97−outlined style shape = form (FShape (Left style) shape)
97+outlined style shape = form (FShape (Either.Left style) shape)
98
98
99-- Trace a path with a given line style.
99-- Trace a path with a given line style.
100traced : LineStyle -> Path -> Form
100traced : LineStyle -> Path -> Form
@@ -186,7 +186,7 @@ oval w h =
186 hw = w/2
186 hw = w/2
187 hh = h/2
187 hh = h/2
188 f i = (hw * Math.cos (t*i), hh * Math.sin (t*i))
188 f i = (hw * Math.cos (t*i), hh * Math.sin (t*i))
189− in map f [0..n-1]
189+ in List.map f [0..n-1]
190
190
191-- A circle with a given radius.
191-- A circle with a given radius.
192circle : Number a -> Shape
192circle : Number a -> Shape
@@ -202,4 +202,4 @@ ngon n r =
202 let m = toFloat n
202 let m = toFloat n
203 t = 2 * Math.PI / m
203 t = 2 * Math.PI / m
204 f i = ( r * Math.cos (t*i), r * Math.sin (t*i) )
204 f i = ( r * Math.cos (t*i), r * Math.sin (t*i) )
205− in map f [0..n-1]
205+ in List.map f [0..n-1]
libraries/Native/Matrix2D.js+8−1
@@ -58,7 +58,14 @@ Elm.Native.Matrix2D = function(elm) {
58 }
58 }
59 */
59 */
60 function multiply(m, n) {
60 function multiply(m, n) {
61− return transform(m[0], m[3], m[1], m[4], m[2], m[5], n);
61+ var m11 = m[0], m12 = m[1], m21 = m[3], m22 = m[4], mdx = m[2], mdy = m[5];
62+ var n11 = n[0], n12 = n[1], n21 = n[3], n22 = n[4], ndx = n[2], ndy = n[5];
63+ return new A([m11*n11 + m12*n21,
64+ m11*n12 + m12*n22,
65+ m11*ndx + m12*ndy + mdx,
66+ m21*n11 + m22*n21,
67+ m21*n12 + m22*n22,
68+ m21*ndx + m22*ndy + mdy]);
62 }
69 }
63
70
64 return elm.Native.Matrix2D = {
71 return elm.Native.Matrix2D = {
libraries/Native/Prelude.js+1−1
@@ -67,7 +67,7 @@ Elm.Native.Prelude = function(elm) {
67 var prelude = {
67 var prelude = {
68 div:F2(div),
68 div:F2(div),
69 rem:F2(rem),
69 rem:F2(rem),
70− mod:F2(mod),
70+ mod:mod,
71
71
72 pi:Math.PI,
72 pi:Math.PI,
73 e:Math.e,
73 e:Math.e,
libraries/Native/Signal/Touch.js+1−1
@@ -101,8 +101,8 @@ Elm.Native.Touch = function(elm) {
101 node.addEventListener("mousedown", function(e) {
101 node.addEventListener("mousedown", function(e) {
102 node.addEventListener("mousemove", move);
102 node.addEventListener("mousemove", move);
103 e.identifier = mouseID;
103 e.identifier = mouseID;
104− root.value.push(touch(e));
105 start(e);
104 start(e);
105+ root.value.push(touch(e));
106 elm.notify(root.id, root.value);
106 elm.notify(root.id, root.value);
107 });
107 });
108 node.addEventListener("mouseup", function(e) {
108 node.addEventListener("mouseup", function(e) {
runtime/Init.js+5−4
@@ -8,7 +8,9 @@ Elm.fullscreen = function(module) {
8 style.innerHTML = "html,head,body { padding:0; margin:0; }" +
8 style.innerHTML = "html,head,body { padding:0; margin:0; }" +
9 "body { font-family: calibri, helvetica, arial, sans-serif; }";
9 "body { font-family: calibri, helvetica, arial, sans-serif; }";
10 document.head.appendChild(style);
10 document.head.appendChild(style);
11+ var container = document.createElement('div');
12+ document.body.appendChild(container);
11− return init(ElmRuntime.Display.FULLSCREEN, document.body, module);
13+ return init(ElmRuntime.Display.FULLSCREEN, container, module);
12};
14};
13
15
14Elm.byId = function(id, module) {
16Elm.byId = function(id, module) {
@@ -92,15 +94,14 @@ function init(display, container, module) {
92 inputs = ElmRuntime.filterDeadInputs(inputs);
94 inputs = ElmRuntime.filterDeadInputs(inputs);
93
95
94 // Add the visualModel to the DOM
96 // Add the visualModel to the DOM
95− var renderNode = Render.render(visualModel)
97+ container.appendChild(Render.render(visualModel));
96− container.appendChild(renderNode);
97 if (elm.Native.Window) elm.Native.Window.resizeIfNeeded();
98 if (elm.Native.Window) elm.Native.Window.resizeIfNeeded();
98
99
99 // set up updates so that the DOM is adjusted as necessary.
100 // set up updates so that the DOM is adjusted as necessary.
100 var update = Render.update;
101 var update = Render.update;
101 function domUpdate(value) {
102 function domUpdate(value) {
102 ElmRuntime.draw(function(_) {
103 ElmRuntime.draw(function(_) {
103− update(renderNode, visualModel, value);
104+ update(container.firstChild, visualModel, value);
104 visualModel = value;
105 visualModel = value;
105 if (elm.Native.Window) elm.Native.Window.resizeIfNeeded();
106 if (elm.Native.Window) elm.Native.Window.resizeIfNeeded();
106 });
107 });
runtime/Render/Collage.js+3−3
@@ -86,11 +86,11 @@ function gradient(ctx, grad) {
86 var stops = [];
86 var stops = [];
87 if (grad.ctor === 'Linear') {
87 if (grad.ctor === 'Linear') {
88 var p0 = grad._0, p1 = grad._1;
88 var p0 = grad._0, p1 = grad._1;
89− g = ctx.createLinearGradient(p0._0, p0._1, p1._0, p1._1);
89+ g = ctx.createLinearGradient(p0._0, -p0._1, p1._0, -p1._1);
90 stops = fromList(grad._2);
90 stops = fromList(grad._2);
91 } else {
91 } else {
92 var p0 = grad._0, p2 = grad._2;
92 var p0 = grad._0, p2 = grad._2;
93− g = ctx.createRadialGradient(p0._0, p0._1, grad._1, p2._0, p2._1, grad._3);
93+ g = ctx.createRadialGradient(p0._0, -p0._1, grad._1, p2._0, -p2._1, grad._3);
94 stops = fromList(grad._4);
94 stops = fromList(grad._4);
95 }
95 }
96 var len = stops.length;
96 var len = stops.length;
@@ -158,7 +158,7 @@ function formToMatrix(form) {
158
158
159 var theta = form.theta
159 var theta = form.theta
160 if (theta !== 0)
160 if (theta !== 0)
161− matrix = A2( Matrix.multiply, Matrix.rotation(theta), matrix );
161+ matrix = A2( Matrix.multiply, matrix, Matrix.rotation(theta) );
162
162
163 return matrix;
163 return matrix;
164}
164}