X-Git-Url: http://git.shiar.nl/sheet.git/blobdiff_plain/8b8c77dbf30f70a1e8ade679a62f08e130f959a2..f7dc0c4618952f5a64b0bf3097b115d0c799684e:/termcol.plp diff --git a/termcol.plp b/termcol.plp index 446b9c5..74bcbc4 100644 --- a/termcol.plp +++ b/termcol.plp @@ -1,111 +1,305 @@ -<: -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

+ +:> +<: if ($ENV{PATH_INFO} =~ /256/) { :> +
+ +
+

256-colour space

+<: +my @colmap; # saturation => value => hue => colcell +for my $r (0 .. 5) { + for my $g (0 .. 5) { + for my $b (0 .. 5) { + my $index = $r*6*6 + $g*6 + $b + 16; + my @rgb = map { $_ && $_*40 + 55 } $r, $g, $b; + + my $h = Shiar_Sheet::Colour->new(@rgb)->hue * 35; + my $v = int(max(@rgb) / 255 * 5); + my $s = abs(min(@rgb) - max(@rgb)) / 255 * 7; + my $grey = !$s; + + $h-- for grep {$h >= $_} 4, 6, 16, 19, 28, 31; + $v = 5 - $v; + $s = 7 - $s - $v; + $s-- if $s; + + if ($grey) { + $h = 30; # greyscale hue + $s -= 2; # lowest saturation for other hues + $v = $s = 0 if $s < 0; # black at full saturation + } + + $colmap[$s][$v][$h] = [$index, @rgb]; + } + } +} + +{ + print ''; + printf '', 3 * @{$_} for @colmap; + for my $h (0 .. 30) { + print ''; + print colcell(@$_) for map { $_->[$h] } map { @{$_} } @colmap; + } + print "
\n"; +} +print "\n"; + + print ''; +for my $row (0, 12) { + print ''; + print colcell(232+$_, ($_*10 + 8) x 3) for $row .. $row+11; +} + print "
\n"; +print "\n"; + +:>
+<: } :> +