[Removed defunct rgbtable subproject Dino Morelli **20140324182613 Ignore-this: 8416d5a77c4704e5fb82ec3a07395d97 The rgb.txt file has been deprecated from X11 packages. ] hunk ./rgbtable/README 1 -Locations of the rgb.txt file - -Debian GNU/Linux: /usr/lib/X11/rgb.txt -SDF BSD: /usr/pkg/X11R6/lib/X11/rgb.txt - rmfile ./rgbtable/README hunk ./rgbtable/rgbtable.pl 1 -#! /usr/bin/perl -w - -#-------------------------------------------------------------------------- -# Script to turn an rgb.txt file (from *nix) into an html table showing -# The color names, values and swatches. -#-------------------------------------------------------------------------- - -use HTML::Template; - - -main(); - -#-------------------------------------------------------------------------- -# Take the decimal RGB values and color name and construct a table row. -sub constructTableRow($$$$) -{ - my %rowData; # Get a fresh hash for the row data - - # These three assingments perform a dec to hex conversion. - $r = sprintf("%02x", $_[0]); - $g = sprintf("%02x", $_[1]); - $b = sprintf("%02x", $_[2]); - $colorDec = "$_[0] $_[1] $_[2]"; - $colorHex = "#${r}${g}${b}"; - - $rowData{colorName} = $_[3]; - $rowData{colorHex} = $colorHex; - $rowData{colorDec} = $colorDec; - - # Return a reference to the hash. - return { %rowData }; -} # sub constructTableRow - -#-------------------------------------------------------------------------- -sub main -{ - my $pathIn = shift @ARGV; - - # open the html template - my $template = HTML::Template->new(filename => 'rgbtable.tmpl'); - - $template->param(fileOrig => $pathIn); - $template->param(platform => qx/uname -a/); - $template->param(dateTime => scalar localtime()); - - open(fileRgb, $pathIn) - || die("Could not open file: $pathIn\n"); - - # initialize an array to hold your loop - my @loopData = (); - - # Skip the first line, it's always a comment. - $line = ; - - # Walk the remaining lines and extract the info we want. - while($line = ) - { - $line =~ m/[ \t]*([0-9]{1,3})[ \t]*([0-9]{1,3})[ \t]*([0-9]{1,3})[ \t]*(.*)/; - - # Push a reference to this row into the loop - push(@loopData, constructTableRow($1, $2, $3, $4)); - } - - close(fileRgb); - - $template->param(colors => \@loopData); - - # Output the result document. - print $template->output; -} # sub main - rmfile ./rgbtable/rgbtable.pl hunk ./rgbtable/rgbtable.tmpl 1 - - - - rgb.txt listing - - - -

Constructed from -
Running on -
Constructed on - -

- - - - - - - - - - - - - - - - - -
color nameswatch#rrggbb (hex)R G B (dec)
-  
- - rmfile ./rgbtable/rgbtable.tmpl rmdir ./rgbtable