termcol: define iterm palette
[sheet.git] / termcol.inc.pl
1 use strict;
2 use 5.010;
3 use Shiar_Sheet::Colour '1.02';
4
5 my @msxorder = ( 0,6,12,10,4,13,7,14 , 1,8,2,11,5,9,3,15 );
6
7 +{
8         html => {
9                 title => 'HTML keywords (inherited by CSS≥2.1 and SVG), mostly identical to X11',
10                 href => 'http://www.w3.org/TR/css3-color/#html4',
11                 list => [qw(
12                         000000:black 800000:maroon  008000:green 808000:olive
13                         000080:navy  800080:purple  008080:cyan  C0C0C0:silver
14                         808080:gray  FF0000:red     00FF00:lime  FFFF00:yellow
15                         0000FF:blue  FF00FF:fuchsia 00FFFF:aqua  FFFFFF:white
16                 )],
17         },
18         cga => {
19                 # linux console, kde?
20                 list => [qw(
21                         000000 AA0000 00AA00 AA5500 0000AA AA00AA 00AAAA AAAAAA
22                         555555 FF5555 55FF55 FFFF55 5555FF FF55FF 55FFFF FFFFFF
23                 )],
24                 # reset bold dim italic underline blink fastblink reverse hidden
25         },
26         xterm => {
27                 # rxvt except for blues
28                 list => [qw(
29                         000000 CC0000 00CC00 CCCC00 4682B4 CC00CC 00CCCC E5E5E5
30                         4C4C4C FF0000 00FF00 FFFF00 1E90FF FF00FF 00FFFF FFFFFF
31                 )],
32         },
33         tango => {
34                 # default Gnome theme
35                 list => [qw(
36                         2E3436 CC0000 4E9A06 C4A000 3465A4 75507B 06989A D3D7CF
37                         555753 EF2929 8AE234 FCE94F 729FCF AD7FA8 34E2E2 EEEEEC
38                 )],
39         },
40         xkcd => {
41                 title => 'human averages in xkcd survey results',
42                 href => 'http://blog.xkcd.com/2010/05/03/color-survey-results/',
43                 list => [qw(
44                         000000:black 650021:maroon  15b01a:green 6e750e:olive
45                         01153e:navy  7e1e9c:purple  029386:teal  c5c9c7:silver
46                         929591:grey  e50000:red     aaff32:lime  ffff14:yellow
47                         0343df:blue  ed0dd9:fuchsia 00ffff:cyan  ffffff:white
48                 )],
49         },
50         android => {
51                 href => 'http://developer.android.com/guide/practices/ui_guidelines/icon_design.html',
52                 title => 'recommended colour palette for Android icons',
53                 list => [qw(
54                         FFFFFF:white   BFBFBF:light   808080:medium  404040:dark
55                         000000:black   6699FF:blue1   3366CC:blue2   003399:blue3
56                         99CC33:green1  00CC00:green2  669933:green3  FFCC00:orange1
57                         FF9900:orange2 FF6600:orange3 CC0000:red
58                 )],
59         },
60         app => {
61                 name => 'Term.app',
62                 list => [qw(
63                         000000 C23621 25BC24 ADAD27 492EE1 D338D3 33BBC8 CBCCCD
64                         818383 FC391F 31E722 EAEC23 5833FF F935F8 14F0F0 E9EBEB
65                 )],
66         },
67         iterm => {
68                 name => 'iTerm',
69                 title => 'iTerm v2.2.1',
70                 list => [qw(
71                         000000 CA1B00 00C200 C7C400 0325C7 CA31C7 00C6C8 C7C7C7
72                         686868 FF6E68 5EFA68 FFFB67 6971FF FF77FF 61FDFF FFFFFF
73                 )],
74         },
75         putty => {
76                 name => 'PuTTY',
77                 list => [qw(
78                         000000 BB0000 00BB00 BBBB00 0000BB BB00BB 00BBBB BBBBBB
79                         555555 FF5555 55FF55 FFFF55 5555FF FF55FF 55FFFF FFFFFF
80                 )],
81         },
82         slutty => {
83                 name => 'SluTTY',
84                 href => 'http://www.npjh.com/slutty.html',
85                 title => 'PuTTY fork with light colour scheme',
86                 list => [qw(
87                         000000 9C1D1D 6C9446 AC9A47 335786 8F6496 486768 E0DCDC
88                         2F2F2F CD5757 8FC35B D1C45E 5C81A9 BC95B7 76CBCB EEEEEC
89                 )],
90         },
91         mirc => {
92                 name => 'mIRC',
93                 href => 'http://www.mirc.com/colors.html',
94                 list => [qw(
95                         FFFFFF 000000 00007F 009300 FF0000 7F0000 9C009C FC7F00
96                         FFFF00 00FC00 009393 00FFFF 0000FC FF00FF 7F7F7F D2D2D2
97                 )],
98                 ansiorder => [ 1,5,3,7,2,6,10,15 , 14,4,9,8,12,13,11,0  ],
99         },
100         mac2 => {
101                 name => 'MacII',
102                 list => [qw(
103                         FFFFFF FBF305 FF6403 DD0907 F20884 4700A5 0000D3 02ABEA
104                         1FB714 006412 562C05 90713A C0C0C0 808080 404040 000000
105                 )],
106                 ansiorder => [ 15,3,9,11,6,5,7,12 , 14,2,8,1,10,4,13,0 ],
107         },
108         risc => {
109                 name => 'RISC',  # v2/3
110                 list => [qw(
111                         FFFFFF DDDDDD BBBBBB 999999 777777 555555 333333 000000
112                         004499 EEEE00 00CC00 DD0000 EEEEBB 558800 FFBB00 00BBFF
113                 )],
114                 ansiorder => [ 7,5,13,14,4,3,2,1 , 6,11,10,9,8,12,15,0 ],
115         },
116         c64 => {
117                 name => 'C=64',  # commodore 64/128
118                 list => [ map {
119                         # 5-bit luma ± 2-bit colour angle
120                         my ($y, $neg, $hue) = split /(-)|\+/;
121
122                         # convert to yuv
123                         my ($u, $v) = (0, 0);
124                         if (defined $hue) {
125                                 my $RAD = 3.14159;
126                                 $hue *= $RAD / 8;
127                                 $hue += $RAD if $neg;
128                                 $u = cos $hue;
129                                 $v = sin $hue;
130                         }
131
132                         # convert to rgb
133                         $y *= 255 / 32;
134                         $_ = $_ * 127.5 + 128 for $u, $v;
135                         Shiar_Sheet::Colour->newyuv($y, $u, $v)->rgb48;
136                 } qw(
137                         0    32  10+5 20-5 12+2 16-2 8+0  24-0
138                         12+6 8+7 16+5 10   15   24-2 15+0 20
139                 )],
140                 ansiorder => [ 0,2,5,9,6,4,3,15 , 11,10,13,7,14,8,12,1 ],
141         },
142         msx1 => {
143                 name => 'MSX',
144                 list => [ map {
145                         my ($y, @c) = split /;/;
146                         $y *= 255;
147                         $_ = ($_ - .47) / .53 * 127.5 + 128 for @c;
148                         Shiar_Sheet::Colour->newyuv($y, @c)->rgb48;
149                 } qw(
150                         0.00;0.47;0.47 0.00;0.47;0.47 0.53;0.20;0.07 0.67;0.27;0.17
151                         0.40;1.00;0.40 0.53;0.93;0.43 0.47;0.30;0.83 0.73;0.70;0.00
152                         0.53;0.27;0.93 0.67;0.27;0.93 0.73;0.07;0.57 0.80;0.17;0.57
153                         0.47;0.23;0.13 0.53;0.67;0.73 0.80;0.47;0.47 1.00;0.47;0.47
154                 )],
155                 ansiorder => \@msxorder,
156         },
157         msx2 => {
158                 name => 'MSX2',
159                 list => [
160                         map { s{([0-7])}{sprintf '%02X', $1 / 7 * 255}egr } qw(
161                         000 000 161 373 117 237 511 267
162                         711 733 661 663 141 625 555 777
163                 )],
164                 ansiorder => \@msxorder,
165         },
166         arnejmp => {
167                 href => 'http://androidarts.com/palette/16pal.htm',
168                 title => "Arne's Japanese Machine Palette v3 (MSX)",
169                 name => 'A:JMP',
170                 list => [qw(
171                         000000 191028 46AF45 A1D685 453E78 7664FE 833129 9EC2E8
172                         DC534B E18D79 D6B97B E9D8A1 216C4B D365C8 AFAAB9 F5F4EB
173                 )],
174                 ansiorder => \@msxorder,
175         },
176         arnegame => {
177                 href => 'http://androidarts.com/palette/16pal.htm',
178                 title => 'Generic 16 color game palette v20 by Arne Niklas Jansson',
179                 name => 'Arne',
180                 list => [qw(
181                         000000::void     9D9D9D::ash     FFFFFF::blind   BE2633::bloodred
182                         E06F8B::pigmeat  493C2B::oldpoop A46422::newpoop EB8931::blaze
183                         F7E26B::zornskin 2F484E::shade   44891A::leaf    A3CE27::slime
184                         1B2632::night    005784::sea     31A2F2::sky     B2DCEF::cloud
185                 )],
186                 order => [ 0,5,9,12 , 3,6,10,13,1 , 4,7,8,11,14,15,2 ], # by brightness
187                 ansiorder => [ 0,3,10,6,13,12,9,1 , 5,7,11,8,14,4,15,2 ],
188         },
189
190         cpc => {
191                 name => 'Amstrad CPC',
192                 rgbmap => [
193                         3 => sub {
194                                 $_[2] + 3 * ($_[0] + 3 * $_[1]),
195                                 map { $_ && $_ * 127 + 1 } @_
196                         },
197                 ],
198         },
199         cpcboy => {
200                 name => 'Arne CPC Boy v3',
201                 href => 'http://androidarts.com/palette/16pal.htm',
202                 rgbmap => [
203                         3 => sub {
204                                 my $index = $_[2] + 3 * ($_[0] + 3 * $_[1]);
205                                 $index,
206                                 map { map { hex } /(..)/g } [qw(
207                                         000000 1B1B76 3636D8  761F28 623870 953EA7  CC3636 CE4B7A E3669A
208                                         1B761B 197F96 1986F2  8C6E1A 8E8E8E 9C9EE7  E48E2A EAA597 FE80FE
209                                         8DD836 B8D1B5 97E9D1  54BF47 37C79F 35CFE4  EDD446 EBE4A4 FFFFFF
210                                 )]->[$index]
211                         },
212                         [ # gameboy ramp
213                                 map { [ 27 + (state $index)++, map { hex } /(..)/g ] }
214                                 qw( F2EFE7 BAC375 859550 485D48 293941 )
215                         ],
216                 ],
217         },
218         ansi88 => {
219                 name => 'rxvt 88 colour extension',
220                 rgbmap => [
221                         4 => sub {
222                                 $_[2] + 4 * ($_[1] + 4 * $_[0]) + 16,
223                                 map { (0, 139, 205, 255)[$_] } @_
224                         },
225                         [ map { [80 + $_, (($_ + 2 + ($_>0)) * 255/11) x 3] } 0 .. 7 ],
226                 ],
227         },
228         ansi256 => {
229                 name => 'xterm 256 colour extension',
230                 href => 'http://web.archive.org/web/20130125000058/http://www.frexx.de/xterm-256-notes/',
231                 # \033[38;5;${FG}m
232                 rgbmap => [
233                         6 => sub {
234                                 $_[2] + 6 * ($_[1] + 6 * $_[0]) + 16,
235                                 map { $_ && $_*40 + 55 } @_
236                         },
237                         [ map { [232 + $_, ($_ * 10 + 8) x 3] } 0 .. 23 ],
238                 ],
239         },
240         512 => {
241                 name => '9-bit RGB map',
242                 # atari st, msx2, sega genesis/nomad, turbografx16
243                 rgbmap => [8],
244         },
245         '4k' => {
246                 name => '12-bit RGB map',
247                 # amiga, apple IIgs, game gear, neo geo, lynx, cpc+, nextstation
248                 rgbmap => [
249                         12 => sub {
250                                 join('', map { sprintf '%X', $_ } @_),
251                                 map { int $_ * 255 / 11 } @_
252                         },
253                 ],
254         },
255 }