6 :><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
7 "http://www.w3.org/TR/html4/loose.dtd">
11 <meta http-equiv="content-type" content="utf-8">
12 <title>terminal colour cheat sheet</title>
13 <meta name="description" content="Index of all terminal/console colour codes, with an example result of various environments.">
14 <meta name="keywords" content="color, code, terminal, console, escape, table, xterm, rxvt">
15 <:= stylesheet(qw'light dark') :>
16 <link rel="icon" type="image/png" href="/clip.png">
20 <h1>Terminal colours</h1>
25 # perceived brightness (using ITU-R recommendation 601 luma co-efficients)
27 return $r*.299 + $g*.587 + $b*.114;
32 my @rgb = @_ >= 3 ? @_ : (map {hex} $_[0] =~ /(..)/g);
34 $rgb24 .= sprintf '%X', min($_ / 17 + .5, 15) for @rgb[0..2];
36 $rgb48 .= sprintf '%02X', $_ for @rgb[0..2];
37 my $inverse = sprintf('%X', luminance(@rgb)/255 < .3 ? 12 : 0) x 3;
38 return sprintf '<td style="%s; padding:0 1ex">%s<td style="%s">%s<td style="%s">%s'."\n",
39 "background:#$rgb48; color:#$inverse",
41 "background:#000; color:#$rgb48",
43 "background:#FFF; color:#$rgb48",
49 qw/black maroon green olive navy purple cyan silver
50 gray red lime yellow blue fuchsia aqua white/,
51 qw/reset bold dim italic underline blink fastblink
56 qw/000000 800000 008000 808000 000080 800080 008080 C0C0C0
57 808080 FF0000 00FF00 FFFF00 0000FF FF00FF 00FFFF FFFFFF/,
61 qw/000000 AA0000 00AA00 AA5500 0000AA AA00AA 00AAAA AAAAAA
62 555555 FF5555 55FF55 FFFF55 5555FF FF55FF 55FFFF FFFFFF/,
66 qw/000000 CC0000 00CC00 CCCC00 4682B4 CC00CC 00CCCC E5E5E5
67 4C4C4C FF0000 00FF00 FFFF00 1E90FF FF00FF 00FFFF FFFFFF/,
71 qw/2E3436 CC0000 4E9A06 C4A000 3465A4 75507B 06989A D3D7CF
72 555753 EF2929 8AE234 FCE94F 729FCF AD7FA8 34E2E2 EEEEEC/,
76 for my $term (qw/html cga xterm tango/) {
77 print '<table>', "\n";
78 print "<caption>$term</caption>\n";
79 for my $num (0 .. 15) {
80 my $rgb = $col{$term}[$num + 2];
82 colcell($col{"-$term"}[$num] || $num, $rgb, $col{$term}[0]);
91 <h2>88-colour space</h2>
98 my $index = $r*4*4 + $g*4 + $b + 16;
99 print colcell($index, map {(0, 139, 205, 255)[$_]} $r, $g, $b);
107 print colcell(80, ($_) x 3) for 46, 92, 115, 139, 162, 185, 208, 231;
108 print "</table>\n\n";
113 <div class="section">
114 <h2>256-colour space</h2>
121 my $index = $r*6*6 + $g*6 + $b + 16;
122 print colcell($index, map { $_ && $_*40 + 55 } $r, $g, $b);
129 for my $row (0, 12) {
131 print colcell(232+$_, ($_*10 + 8) x 3) for $row .. $row+11;
140 <a href="/" rel="home">sheet.shiar.nl</a>/termcol.<a href="/source/termcol.plp"
141 rel="code" title="Written in Perl">plp</a>
142 <a href="http://git.shiar.nl/sheet.git/history/HEAD:/termcol.plp"
143 rel="vcs-git" title="Git repository"><:= $VERSION :></a>
144 created by <a href="http://shiar.nl/" rel="author">Shiar</a> •
145 <a href="http://www.fsf.org/licensing/licenses/agpl-3.0.html" rel="copyright"
146 title="Licensed under the GNU Affero General Public License, version 3">AGPLv3</a>