diff options
| author | Rubén Beltran del Río <ben@nsovocal.com> | 2018-06-26 22:00:10 +0000 |
|---|---|---|
| committer | Rubén Beltran del Río <ben@nsovocal.com> | 2018-06-26 22:00:10 +0000 |
| commit | c80b2f4575cfc3d74ec8e0b112943cbd081ffcd7 (patch) | |
| tree | 4d2c7a991fcc6510431af72225f7cea2c450f86a /lib/screens/mirrors.js | |
| parent | be12c97f83026087e0974fc54508b09c3154c9eb (diff) | |
| parent | fd38d4096e65ba5afba8ed1ddc75ed1814ca8c16 (diff) | |
Merge branch 'feature/rbdr-update-docs' into 'master'
Update Documentation
See merge request rbdr/tomato-sauce!1
Diffstat (limited to 'lib/screens/mirrors.js')
| -rw-r--r-- | lib/screens/mirrors.js | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/lib/screens/mirrors.js b/lib/screens/mirrors.js index d683fb6..e842217 100644 --- a/lib/screens/mirrors.js +++ b/lib/screens/mirrors.js @@ -1,30 +1,36 @@ 'use strict'; -// Draws small moving gradient boxes and repeats them. -const Mirrors = function (modulation, width, height, renderer) { - let response = []; +/** + * Draws small moving gradient boxes and repeats them. + * + * @function MirrorsScreen + * @implements IScreen + */ +module.exports = function (modulation, width, height, renderer) { - let scale = 2 + Math.round(Math.random() * 4); - let scaledHeight = Math.floor(height / scale); - let scaledWidth = Math.floor(width / scale); + const response = []; - for (let i = 0; i < scaledHeight; i++) { - let row = []; - for (let j = 0; j < scaledWidth; j++) { - let red = ((modulation + i) * 255 / height) % 255; - let blue = ((modulation + j) * 255 / width) % 255; - let green = ((modulation + i * j) * 255 / (width * height)) % 255; + const scale = 2 + Math.round(Math.random() * 4); + const scaledHeight = Math.floor(height / scale); + const scaledWidth = Math.floor(width / scale); - let cell = [renderer(red, blue, green), ' ']; + for (let i = 0; i < scaledHeight; ++i) { + const row = []; + for (let j = 0; j < scaledWidth; ++j) { + const red = ((modulation + i) * 255 / height) % 255; + const blue = ((modulation + j) * 255 / width) % 255; + const green = ((modulation + i * j) * 255 / (width * height)) % 255; + + const cell = [renderer(red, blue, green), ' ']; row.push(cell.join('')); } let rowText = ''; - for (let j = 0; j < scale; j++) { + for (let j = 0; j < scale; ++j) { rowText += row.reverse().join(''); } - for (let j = 1; j < scale; j++) { + for (let j = 1; j < scale; ++j) { response[j * i] = rowText; response[(height - 1 - (j * i))] = rowText; } @@ -32,5 +38,3 @@ const Mirrors = function (modulation, width, height, renderer) { return response.join('\n'); }; - -module.exports = Mirrors; |