#!/usr/bin/perl # # xrgb2html - create html page w/rgb.txt colors # # dave.capella@cornell.edu - Sun Mar 10 23:02:48 EST 2002 # Copyright (C) 2002 dave w capella All Rights Reserved # platform: Linux portal.bscb.cornell.edu 2.4.2-2 #19 Sun Feb 24 04:54:22 EST 2002 i686 unknown # notes : ###################################################################### # location of the X11 color table # $rgbtxt="/usr/X11R6/lib/X11/rgb.txt"; # get the X version # $version = `/usr/X11R6/bin/XFree86 -version 2>&1 | /bin/grep Version`; $columns = 8; # number of columns in html table # splice on our look 'n feel # $header = $ENV{'DOCUMENT_ROOT'} . "/lib/header.html"; $footer = $ENV{'DOCUMENT_ROOT'} . "/lib/footer.html"; # print the http header # print < # # #X11 rgb.txt colors # # # #

X11 rgb.txt colors

# print `cat $header`; # remove this if not using header print <X11 rgb.txt colors

$version

This utility reads the $rgbtxt file and converts it into color tiles. Note that not all the colors will display correctly due the limitations of the web.

EOF $i = 0; # column counter $row1 = ""; # colored cell row $row2 = ""; # color names row # read each line of the file and parse. convert from # rrr ggg bbb color name # to in hex # open(FILE,$rgbtxt) or die "cannot open $rgbtxt $!"; while() { next if /^!/; # skip comment lines $i++; if($i == $columns) { # end row print $row1,"\n\n"; print $row2,"\n\n"; $i = 0; $row1 = ""; $row2 = ""; } chomp; ($r,$g,$b,@fullname) = split; # parse colors and color name $name = ""; foreach $n (@fullname) { $name .= " $n"; } # handle names with spaces $row1 .= sprintf("\n",$r,$g,$b); $row2 .= "\n"; } close(FILE); # account for leftover cells in last row # fill blank cells so they don't show up blank # for($i++;$i<$columns;$i++) { $row1 .= "\n"; $row2 .= "\n"; } # print last row # print $row1,"\n\n"; print $row2,"\n\n"; print <
 
 $name  
EOF # # #EOF print `cat $footer`; ###################################################################### # eof: xrgb2html