| 13 | }; |
| 14 | |
| 15 | const prepColors = input => { |
| 16 | const base = (input && input.length ? input : ['#A6C8FF', '#5227FF', '#FF9FFC']).slice(0, MAX_COLORS); |
| 17 | const count = base.length; |
| 18 | const arr = []; |
| 19 | for (let i = 0; i < MAX_COLORS; i++) arr.push(hexToRGB(base[Math.min(i, base.length - 1)])); |
| 20 | const avg = [0, 0, 0]; |
| 21 | for (let i = 0; i < count; i++) { |
| 22 | avg[0] += arr[i][0]; |
| 23 | avg[1] += arr[i][1]; |
| 24 | avg[2] += arr[i][2]; |
| 25 | } |
| 26 | avg[0] /= count; |
| 27 | avg[1] /= count; |
| 28 | avg[2] /= count; |
| 29 | return { arr, count, avg }; |
| 30 | }; |
| 31 | |
| 32 | const vertex = ` |
| 33 | attribute vec2 position; |