From 9f835820dc04661f50bbe48c2e2b85ed788d9e91 Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Mon, 26 Dec 2016 17:31:32 +0000 Subject: [PATCH] Alter all js to use new es6 module syntax --- Random.js | 3 +++ Star.js | 4 ++++ Starlight-Renderer.js | 7 +++++++ Vector.js | 2 +- 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Random.js b/Random.js index 5196271..1ea0655 100644 --- a/Random.js +++ b/Random.js @@ -1,3 +1,5 @@ +"use strict"; + /** * Bounded random number generator. Has 3 forms: * @@ -18,3 +20,4 @@ function random(a,b,c,d) {d=Math.random();if(typeof a!="number")return d;a=typeof b=="number"?d*(a-b)+b:d*a;a=(typeof b!="number"?b:c)?a:Math.floor(a);return a;} +export default random; diff --git a/Star.js b/Star.js index c1f29cb..9bb4e0a 100644 --- a/Star.js +++ b/Star.js @@ -1,5 +1,7 @@ "use strict"; +import Vector from './Vector'; + class Star { constructor(inCanvas, inPosition, inSize) @@ -28,3 +30,5 @@ class Star context.restore(); } } + +export default Star; diff --git a/Starlight-Renderer.js b/Starlight-Renderer.js index 56a00cc..251f280 100644 --- a/Starlight-Renderer.js +++ b/Starlight-Renderer.js @@ -1,5 +1,12 @@ "use strict"; +import random from './Random'; // Bounded random number generation +import Vector from './Vector'; // 2D vector class +// Subclasses +import Star from './Star'; + +// ~~~ + class StarlightRenderer { constructor(canvas) diff --git a/Vector.js b/Vector.js index d159ff9..1ce67d4 100644 --- a/Vector.js +++ b/Vector.js @@ -215,4 +215,4 @@ class Vector { } } // Make Vector.js Node.js friendly -if (typeof module != "undefined" && module.exports) module.exports = Vector; +export default Vector;