X-Git-Url: http://git.shiar.nl/sheet.git/blobdiff_plain/c32011016e046e39ac53f81303c9f3b95b0e9c89..a6bdc11ce27566679da505185e519ddd0bc9a5ca:/termcol.plp diff --git a/termcol.plp b/termcol.plp index 3dd1d1b..e544bf7 100644 --- a/termcol.plp +++ b/termcol.plp @@ -1,61 +1,170 @@ -<: -use utf8; -use strict; -use warnings; -use open IO => ':utf8'; - -our $VERSION = 'v1.0'; +<(common.inc.plp)><: -$header{content_type} = 'text/html; charset=utf-8'; +Html({ + title => 'terminal colour cheat sheet', + version => '1.0', + description => [ + "Index of all terminal/console colour codes,", + "with an example result of various environments.", + ], + keywords => [qw' + color code terminal console escape table xterm rxvt + '], + data => ['termcol.inc.pl'], + stylesheet => [qw'light dark'], +}); -:> - +my @termlist; +push @termlist, split /\W+/, $ENV{PATH_INFO} || 'default'; -
-# | xterm |
---|---|
%d | %s%s | ⪠',
- 'background:#'.$col{$_}[0].'; color:#'.$col{$_}[$num + 2],
- } qw/linux xterm tango/ ),
+
+<:
+use Shiar_Sheet::Colour '1.03';
+use List::Util qw( min max );
+
+my $palettes = do 'termcol.inc.pl';
+die "Cannot open palette data: $_\n" for $@ || $! || ();
+
+sub colcell {
+ my $name = shift // return " \n";
+ my $col = Shiar_Sheet::Colour->new(@_);
+ my $minhex = $col->rgb24;
+ my $css = '#' . $col->rgb48;
+ my $inverse = '#' . sprintf('%X', $col->luminance/255 < .3 ? 12 : 0) x 3;
+
+ my $sample = [ qw(#000 #FFF) ];
+ ($name, $sample) = @$name if ref $name eq 'ARRAY';
+
+ my $out = sprintf(' | %s',
+ join(',', map { int } @$col),
+ "background:$css; color:$inverse",
+ $name,
);
+ $out .= sprintf ' | %s', "background:$_; color:$css", $minhex
+ for @$sample;
+ return "$out\n";
}
-:> | |