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