/
colors.js
50 lines (42 loc) · 976 Bytes
/
colors.js
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
'use strict'
const ansi = [
'0,0,0',
'187,0,0',
'0,187,0',
'187,187,0',
'0,0,187',
'187,0,187',
'0,187,187',
'255,255,255',
'85,85,85',
'255,85,85',
'0,255,0',
'255,255,85',
'85,85,255',
'255,85,255',
'85,255,255',
'255,255,255'
]
const colors = []
// 0 to 15 system colors
for (let i = 0; i < 16; i++) colors.push('rgb(' + ansi[i] + ')')
// 16 to 231 RGB 6 x 6 x 6
const levels = [0, 95, 135, 175, 215, 255]
for (let r = 0; r < 6; r++) {
for (let g = 0; g < 6; g++) {
for (let b = 0; b < 6; b++) {
colors.push('#' + [
('0' + parseInt(levels[r])).slice(-2),
('0' + parseInt(levels[g])).slice(-2),
('0' + parseInt(levels[b])).slice(-2)
].join(''))
}
}
}
// 232 to 255 grayscale
const grayscale = [
'08', '12', '1c', '26', '30', '3a', '44', '4e', '58', '62', '6c', '76',
'80', '8a', '94', '9e', 'a8', 'b2', 'bc', 'c6', 'd0', 'da', 'e4', 'ee'
]
for (let hex of grayscale) colors.push('#' + hex.repeat(3))
module.exports = colors