]>
git.r.bdr.sh - rbdr/tomato-sauce/blob - lib/screens/mirrors.js
d683fb63c2d165b7eb0b2ab84e47f9d24537ac3b
3 // Draws small moving gradient boxes and repeats them.
4 const Mirrors = function (modulation
, width
, height
, renderer
) {
7 let scale
= 2 + Math
.round(Math
.random() * 4);
8 let scaledHeight
= Math
.floor(height
/ scale
);
9 let scaledWidth
= Math
.floor(width
/ scale
);
11 for (let i
= 0; i
< scaledHeight
; i
++) {
13 for (let j
= 0; j
< scaledWidth
; j
++) {
14 let red
= ((modulation
+ i
) * 255 / height
) % 255;
15 let blue
= ((modulation
+ j
) * 255 / width
) % 255;
16 let green
= ((modulation
+ i
* j
) * 255 / (width
* height
)) % 255;
18 let cell
= [renderer(red
, blue
, green
), ' '];
19 row
.push(cell
.join(''));
23 for (let j
= 0; j
< scale
; j
++) {
24 rowText
+= row
.reverse().join('');
27 for (let j
= 1; j
< scale
; j
++) {
28 response
[j
* i
] = rowText
;
29 response
[(height
- 1 - (j
* i
))] = rowText
;
33 return response
.join('\n');
36 module
.exports
= Mirrors
;