]> git.r.bdr.sh - rbdr/tomato-sauce/blobdiff - lib/screens/gradients.js
Ports the basic script to split modules
[rbdr/tomato-sauce] / lib / screens / gradients.js
diff --git a/lib/screens/gradients.js b/lib/screens/gradients.js
new file mode 100644 (file)
index 0000000..5e63d5b
--- /dev/null
@@ -0,0 +1,25 @@
+'use strict';
+
+// Draws moving gradient boxes.
+const Gradients = function (modulation, width, height, renderer) {
+  let response = '';
+
+  for (let i = 0; i < height; i++) {
+    for (let j = 0; j < width; j++) {
+      let red = ((modulation + i) * 255 / height) % 255;
+      let blue = ((modulation + j) * 255 / width) % 255;
+      let green = ((modulation + i * j) * 255 / (width * height)) % 255;
+
+      response = response + renderer(red, blue, green);
+      response = response + ' ';
+    }
+
+    if (i < height - 1) {
+      response = response + '\n';
+    }
+  }
+
+  return response;
+};
+
+module.exports = Gradients;