]> git.r.bdr.sh - rbdr/tomato-sauce/blobdiff - lib/screens/sprinkles.js
Update Documentation
[rbdr/tomato-sauce] / lib / screens / sprinkles.js
index 446f46ec9ff556695c4c6f3d77c1cb2f3abe1bbe..f12200e0fec4597282af96a0cba8b9eac73d3280 100644 (file)
@@ -1,28 +1,32 @@
 'use strict';
 
-// Places random sprinkles in the screen each frame. Same color per
-// frame.
-const Sprinkles = function (modulation, width, height, renderer) {
+/**
+ * Draws random sprinkles in the screen each frame. Same color per
+ * frame.
+ *
+ * @function SprinklesScreen
+ * @implements IScreen
+ */
+module.exports = function (modulation, width, height, renderer) {
+
   let response = '';
 
-  let maxSprinkleCount = (width * height) / 2;
-  let minSprinkleCount = (width * height) / 8;
-  let sprinkleCount = Math.round(Math.random() * (maxSprinkleCount - minSprinkleCount)) + minSprinkleCount;
+  const maxSprinkleCount = (width * height) / 2;
+  const minSprinkleCount = (width * height) / 8;
+  const sprinkleCount = Math.round(Math.random() * (maxSprinkleCount - minSprinkleCount)) + minSprinkleCount;
 
-  let red = Math.floor(Math.random() * 255);
-  let blue = Math.floor(Math.random() * 255);
-  let green = Math.floor(Math.random() * 255);
+  const red = Math.floor(Math.random() * 255);
+  const blue = Math.floor(Math.random() * 255);
+  const green = Math.floor(Math.random() * 255);
 
-  for (let i = 0; i < sprinkleCount; i++) {
-    let x = Math.round(Math.random() * (width - 1)) + 1;
-    let y = Math.round(Math.random() * (height - 1)) + 1;
+  for (let i = 0; i < sprinkleCount; ++i) {
+    const x = Math.round(Math.random() * (width - 1)) + 1;
+    const y = Math.round(Math.random() * (height - 1)) + 1;
 
-    let position = `\x1B[${y};${x}H`; // Move cursor to y,x (CSI y;x H)
+    const position = `\x1B[${y};${x}H`; // Move cursor to y,x (CSI y;x H)
 
     response += `${position}${renderer(red, blue, green)} `;
   }
 
   return response;
 };
-
-module.exports = Sprinkles;