]>
Commit | Line | Data |
---|---|---|
c7b4bd19 BB |
1 | 'use strict'; |
2 | ||
fd38d409 RBR |
3 | /** |
4 | * Draws small moving gradient boxes and repeats them. | |
5 | * | |
6 | * @function MirrorsScreen | |
7 | * @implements IScreen | |
8 | */ | |
9 | module.exports = function (modulation, width, height, renderer) { | |
10 | ||
a0666be3 RBR |
11 | const response = []; |
12 | ||
13 | const scale = 2 + Math.round(Math.random() * 4); | |
14 | const scaledHeight = Math.floor(height / scale); | |
15 | const scaledWidth = Math.floor(width / scale); | |
16 | ||
17 | for (let i = 0; i < scaledHeight; ++i) { | |
18 | const row = []; | |
19 | for (let j = 0; j < scaledWidth; ++j) { | |
20 | const red = ((modulation + i) * 255 / height) % 255; | |
21 | const blue = ((modulation + j) * 255 / width) % 255; | |
22 | const green = ((modulation + i * j) * 255 / (width * height)) % 255; | |
23 | ||
24 | const cell = [renderer(red, blue, green), ' ']; | |
25 | row.push(cell.join('')); | |
26 | } | |
27 | ||
28 | let rowText = ''; | |
29 | for (let j = 0; j < scale; ++j) { | |
30 | rowText += row.reverse().join(''); | |
31 | } | |
32 | ||
33 | for (let j = 1; j < scale; ++j) { | |
34 | response[j * i] = rowText; | |
35 | response[(height - 1 - (j * i))] = rowText; | |
36 | } | |
c7b4bd19 | 37 | } |
c7b4bd19 | 38 | |
a0666be3 | 39 | return response.join('\n'); |
c7b4bd19 | 40 | }; |