Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

"R/G/B-ish" colors lists

by AltBlue (Chaplain)
on Apr 24, 2005 at 14:28 UTC ( [id://450974]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Browser safe colors :)
in thread HTML RGB hex color

Here is some example on how to generate the "R/G/B-ish" lists:

#!/usr/bin/perl -Twl use strict; my @SAFE = qw(0 51 102 153 204 255); my @RGB = ([RED => 0], [GREEN => 1], [BLUE => 2]); sub get_set {grep { $_ >= $_[0] && $_ < $_[1] } @SAFE} sub dec_hex {map {sprintf "%02x", $_} @_} sub permute { my $last = pop @_; return map [$_], @$last if(!@_); return map { my $left = $_; map [@$left, $_], @$last } permute(@_); } foreach my $R (@RGB) { print $/, $R->[0], 'ish:'; foreach my $t (get_set(51, 256)) { my @clrs = get_set(0, $t); foreach (permute(\@clrs, \@clrs)) { my @tuple = @$_; splice(@tuple, $R->[1], 0, $t); print '#', dec_hex(@tuple); } } } print $/, 'GRAYish:'; print '#', dec_hex(($_)x3) for @SAFE;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://450974]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2024-04-25 05:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found