#!/usr/bin/perl # # Copyright 2002 Brown University # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #------------------------------------------------------------------------ # colorcomb # # Generate a table of text-on-background-color combinations # using only web-safe colors. This is a perl CGI script. # # Author: John Bazik # jsb@cs.brown.edu # http://www.cs.brown.edu/~jsb/ # # History: # 30jun99 jsb - original # 26sep02 jsb - fixed some typos that broke mozilla # use CGI; # # Hue-sorted list of web-safe colors. # my @webcols=( '330000', '663333', '660000', '996666', '993333', '990000', 'cc9999', 'cc6666', 'cc3333', 'cc0000', 'ffcccc', 'ff9999', 'ff6666', 'ff3333', 'ff0000', 'ff3300', 'cc3300', 'ff6633', 'ff9966', '993300', 'cc6633', 'ff6600', 'cc9966', 'ff9933', '663300', '996633', 'cc6600', 'ffcc99', 'ff9900', 'cc9933', '996600', 'ffcc66', 'cc9900', 'ffcc33', 'ffcc00', '333300', '666633', '666600', '999966', '999933', '999900', 'cccc99', 'cccc66', 'cccc33', 'cccc00', 'ffffcc', 'ffff99', 'ffff66', 'ffff33', 'ffff00', 'ccff00', '99cc00', 'ccff33', '669900', '99cc33', 'ccff66', '99ff00', '336600', '669933', '99cc66', '66cc00', 'ccff99', '99ff33', '66ff00', '339900', '66cc33', '99ff66', '33cc00', '66ff33', '33ff00', '003300', '336633', '006600', '669966', '339933', '009900', '99cc99', '66cc66', '33cc33', '00cc00', 'ccffcc', '99ff99', '66ff66', '33ff33', '00ff00', '00ff33', '00cc33', '33ff66', '66ff99', '009933', '33cc66', '00ff66', '006633', '339966', '66cc99', '00cc66', '99ffcc', '33ff99', '00ff99', '009966', '33cc99', '66ffcc', '00cc99', '33ffcc', '00ffcc', '003333', '336666', '006666', '669999', '339999', '009999', '99cccc', '66cccc', '33cccc', '00cccc', 'ccffff', '99ffff', '66ffff', '33ffff', '00ffff', '00ccff', '0099cc', '33ccff', '006699', '66ccff', '3399cc', '0099ff', '003366', '336699', '6699cc', '0066cc', '99ccff', '3399ff', '0066ff', '003399', '3366cc', '6699ff', '0033cc', '3366ff', '0033ff', '000033', '333366', '000066', '666699', '333399', '000099', '9999cc', '6666cc', '3333cc', '0000cc', 'ccccff', '9999ff', '6666ff', '3333ff', '0000ff', '3300ff', '3300cc', '6633ff', '330099', '6633cc', '9966ff', '6600ff', '330066', '663399', '9966cc', '6600cc', 'cc99ff', '9933ff', '9900ff', '9933cc', '660099', 'cc66ff', '9900cc', 'cc33ff', 'cc00ff', '330033', '663366', '660066', '996699', '993399', '990099', 'cc99cc', 'cc66cc', 'cc33cc', 'cc00cc', 'ffccff', 'ff99ff', 'ff66ff', 'ff33ff', 'ff00ff', 'ff00cc', 'cc0099', 'ff33cc', '990066', 'cc3399', 'ff66cc', 'ff0099', '660033', '993366', 'cc6699', 'cc0066', 'ff99cc', 'ff3399', 'ff0066', '990033', 'cc3366', 'ff6699', 'cc0033', 'ff3366', 'ff0033', '000000', '333333', '666666', '999999', 'cccccc', 'ffffff'); # # Colors that are too dark for black text. # my @toodark=( 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0); my $pagebg = '999999'; my $borderfg = '666666'; my $q = new CGI; my $href = $q->url(-absolute=>1); my $bg = $q->param('keywords') ? $q->param('keywords') : $q->param('bg'); my $fg = $q->param('fg'); my $choose = $q->param('choose'); my $title; my $section; if (defined $bg) { $bg = check_color($bg); if (defined $fg) { $fg = check_color($fg); textpage($bg, $fg); exit 0; } $title = "Web Safe Color Combinations: Background #$bg"; } elsif (defined $fg) { $fg = check_color($fg); $title = "Web Safe Color Combinations: Foreground #$fg"; } elsif (defined $choose) { if ($choose eq 'fg') { $title = "Web Safe Color Combinations: Choose Foreground (Text) Color"; $section = 'Foreground'; } elsif ($choose eq 'bg') { $title = "Web Safe Color Combinations: Choose Background Color"; $section = 'Background'; } else { error(''); } } else { $title = "Explore Web Safe Color Combinations"; $section = 'Home'; $choose = 'bg'; } # # Build the page. # print $q->header, $q->start_html(-title=>"$title", -bgcolor=>"#$pagebg"), $q->h1("$title"); if ($section eq 'Home') { preamble(); print qq(
Choose a background color:
\n); } prtable($bg, $fg, $choose); print $q->p; navbar($section); print $q->address($q->a({-href=>"/people/jsb/"}, "John Bazik")); print $q->end_html; # # Done # sub preamble { print qq(
\n); print qq(There are 216 "web safe" colors. These are the colors that look the same on a wide variety of platforms. Restricting your web page design to these colors ensures that all visitors to your site get the same experience.); print $q->p; print qq(It's easy to browse 216 colors. But web designers must choose color combinations. There are 2162 = 46656 two-color, web-safe color combinations. This page lets you explore those combinations as text (foreground) on background, rendered by your browser exactly as it would be in your web page.); print qq(\n); } sub prtable { my $bg = shift; my $fg = shift; my $choose = shift; my ($i); print qq(