]>
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 | ||
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), ' ']; | |
c7b4bd19 BB |
25 | row.push(cell.join('')); |
26 | } | |
27 | ||
28 | let rowText = ''; | |
fd38d409 | 29 | for (let j = 0; j < scale; ++j) { |
c7b4bd19 BB |
30 | rowText += row.reverse().join(''); |
31 | } | |
32 | ||
fd38d409 | 33 | for (let j = 1; j < scale; ++j) { |
c7b4bd19 BB |
34 | response[j * i] = rowText; |
35 | response[(height - 1 - (j * i))] = rowText; | |
36 | } | |
37 | } | |
38 | ||
39 | return response.join('\n'); | |
40 | }; |