X-Git-Url: http://git.shiar.nl/sheet.git/blobdiff_plain/dae21a09b01baa118720670247a87c5cdc2591b8..032b7eb4897d7517e94c7fe2e1d414be8d925c9f:/termcol.plp diff --git a/termcol.plp b/termcol.plp index 359b33d..9262bf3 100644 --- a/termcol.plp +++ b/termcol.plp @@ -1,149 +1,304 @@ -<: -use utf8; -use strict; -use warnings; -use open IO => ':utf8'; -use List::Util 'min'; - -our $VERSION = 'v1.0'; - -$header{content_type} = 'text/html; charset=utf-8'; - -:> - +<(common.inc.plp)><: - -terminal colour cheat sheet - - - +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 + '], + stylesheet => [qw'light dark'], +}); - +:>

Terminal colours

- +:>
-

88-colour space

+ my $out = ''; + $out .= sprintf '', 3 * @{$_} for @colmap; + my $huerow = $colmap[0][0]; # first {$_} map { @{$_} } @colmap; + for my $h (grep { $huerow->[$_] } 0 .. $#{$huerow}) { + $out .= ''; + $out .= colcell(@$_) for map { $_->[$h] } map { @{$_} } @colmap; + } -
-

256-colour space

'; - for my $g (0 .. 5) { - print ''; - for my $b (0 .. 5) { - my $index = $r*6*6 + $g*6 + $b + 16; - print colcell($index, map { $_ && $_*40 + 55 } $r, $g, $b); - } + $offset += $dim ** 3; + $greymap{$offset++} = $_ for @{$greyramp}; + + $out .= ''; + my $col = 0; + my $colbreak = scalar map { @$_ } @colmap; # same width as hue rows + for my $num (sort { $greymap{$a} <=> $greymap{$b} } keys %greymap) { + $out .= '' unless $col++ % $colbreak; + $out .= colcell($num, ($greymap{$num}) x 3); } - print "
\n"; + $out .= "\n\n"; + + return $out; } -print "\n"; -for my $row (0, 12) { - print '
  • '; - print colcell(232+$_, ($_*10 + 8) x 3) for $row .. $row+11; - print "
    \n"; +{ + print "

    88-colour space

    \n"; + print coltable_hsv(4, + sub {(0, 139, 205, 255)[$_[0]]}, + [map { ($_ + 2 + ($_>0)) * 255/11 } 0 .. 7], + ); } -print "\n"; -:> +if ($ENV{PATH_INFO} =~ /256/) { + print "

    256-colour space

    \n"; + print coltable_hsv(6, + sub { $_[0] && $_[0]*40 + 55 }, + [ map { $_ * 10 + 8 } 0 .. 23 ], + ); +} +:>
    - - -