X-Git-Url: http://git.shiar.nl/sheet.git/blobdiff_plain/0934eb163565512a7e1622f931a2f6a60b7c0872..HEAD:/termcol.plp diff --git a/termcol.plp b/termcol.plp index c7c74bf..f76e293 100644 --- a/termcol.plp +++ b/termcol.plp @@ -1,132 +1,289 @@ -<: -use utf8; -use strict; -use warnings; -use open IO => ':utf8'; -use List::Util 'min'; +<(common.inc.plp)><: -our $VERSION = 'v1.0'; +if (my ($name) = $Request =~ /(.+)\.gpl\z/) { + my $palettes = Data('termcol'); + my $palette = $palettes->{$name} + or Abort("Palette '$name' not found", 404); + ref $palette ne 'ARRAY' + or Abort("Group contains multiple palettes: ".join(', ', @{$palette})); -$header{content_type} = 'text/html; charset=utf-8'; + $header{content_type} = 'text/x-gimp-gpl'; + say 'GIMP Palette'; + say 'Name: ', $palette->{name} // $name; + say 'Columns: 8'; + say '#'; + for (@{ $palette->{list} }) { + my ($rgb, $name) = split /:/, $_, 3; + say join ' ', unpack('C*', pack 'H6', $rgb), $name; + } + exit; +} -:> - +Html({ + title => ($Request ? 'terminal colour' : 'colour palettes') . ' cheat sheet', + version => '1.4', + description => [!$Request ? "Comparison of various colour palettes." : ( + "Index of all terminal/console colour codes,", + "with an example result of various environments.", + )], + keywords => [qw' + color colour code terminal console escape table xterm rxvt + ansi vt100 8bit 4bit cga ega vga rgb hsv game emulator display + '], + data => ['termcol.inc.pl'], + stylesheet => [qw'light dark'], +}); - -terminal colour cheat sheet - - - +my @draw = map { [$_, s/\W+\z//] } grep { $_ } split m(/), + $get{img} // exists $get{img} && 'compile.png'; - -

Terminal colours

+my @termlist; +push @termlist, split /\W+/, $Request || 'default'; - -
-

88-colour space

+sub colorder { + my ($palette, $reorder) = @_; + return [ map { $palette->[$_] =~ s/:(?![^:])|$/:$_/r } @{$reorder} ] + if $reorder; + return $palette; +} -
-

256-colour space

+coltable($_) for @termlist; +:> +