]>
git.r.bdr.sh - rbdr/tomato-sauce/blob - lib/screens/mirrors.js
e8422177cafafef3408f09cf347792f928a59647
4 * Draws small moving gradient boxes and repeats them.
6 * @function MirrorsScreen
9 module
.exports = function (modulation
, width
, height
, renderer
) {
13 const scale
= 2 + Math
.round(Math
.random() * 4);
14 const scaledHeight
= Math
.floor(height
/ scale
);
15 const scaledWidth
= Math
.floor(width
/ scale
);
17 for (let i
= 0; i
< scaledHeight
; ++i
) {
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;
24 const cell
= [renderer(red
, blue
, green
), ' '];
25 row
.push(cell
.join(''));
29 for (let j
= 0; j
< scale
; ++j
) {
30 rowText
+= row
.reverse().join('');
33 for (let j
= 1; j
< scale
; ++j
) {
34 response
[j
* i
] = rowText
;
35 response
[(height
- 1 - (j
* i
))] = rowText
;
39 return response
.join('\n');