]> git.r.bdr.sh - rbdr/tomato-sauce/blame - lib/screens/gradients.js
Update code and dpendencies
[rbdr/tomato-sauce] / lib / screens / gradients.js
CommitLineData
c7b4bd19
BB
1'use strict';
2
fd38d409
RBR
3/**
4 * Draws moving gradient boxes
5 *
6 * @function GradientsScreen
7 * @implements IScreen
8 */
9module.exports = function (modulation, width, height, renderer) {
10
a0666be3 11 let response = '';
c7b4bd19 12
a0666be3
RBR
13 for (let i = 0; i < height; ++i) {
14 for (let j = 0; j < width; ++j) {
15 const red = ((modulation + i) * 255 / height) % 255;
16 const blue = ((modulation + j) * 255 / width) % 255;
17 const green = ((modulation + i * j) * 255 / (width * height)) % 255;
c7b4bd19 18
a0666be3
RBR
19 response = response + renderer(red, blue, green);
20 response = response + ' ';
21 }
c7b4bd19 22
a0666be3
RBR
23 if (i < height - 1) {
24 response = response + '\n';
25 }
c7b4bd19 26 }
c7b4bd19 27
a0666be3 28 return response;
c7b4bd19 29};