aboutsummaryrefslogtreecommitdiff
path: root/lib/screens/random.js
blob: 6ac706f039ddc5720050a2750373615c2a151073 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
'use strict';

// random colors
const Random = function (modulation, width, height, renderer) {
  let response = '';

  for (let i = 0; i < height; i++) {
    for (let j = 0; j < width; j++) {
      let red = Math.floor(Math.random() * 255);
      let blue = Math.floor(Math.random() * 255);
      let green = Math.floor(Math.random() * 255);

      response = response + renderer(red, blue, green);
      response = response + ' ';
    }

    if (i < height - 1) {
      response = response + '\n';
    }
  }

  return response;
};

module.exports = Random;