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

Re: CGI Colour Palette

by dws (Chancellor)
on Aug 08, 2002 at 20:59 UTC ( #188738=note: print w/replies, xml ) Need Help??


in reply to CGI Colour Palette

Does anyone out there know of a cgi script that will return the RBG colour that a user clicks on?

There are basically two approaches to this. They differ by where the mapping is done:

You can use an image map, and handle the coordinate-to-RGB translation on the server side. This approach gives you a lot of flexibility with our graphics, at the expense of making the coordinate mapping more difficult the fancier you get.

Alternatively, you do the "translation" on the client side, by doing something like filling a table with colors, and adding a link to each cell that embeds the RGB code in the URL. Such a table is easy to generate from Perl.

Replies are listed 'Best First'.
Re: Re: CGI Colour Palette
by sabkat (Acolyte) on Aug 08, 2002 at 23:24 UTC
    Thanks for the help! I figured that I would have to do somthing like the second option above. The only drwaback here is that the table will size each cell by the text the cell, and will only link on the text and not the cell itself. argh!
    my @hex_numbers_row = ("ff","cc","99","66","33","00"); foreach $block (@hex_numbers_row) { + foreach $col (@hex_numbers_row) { + foreach $row (@hex_numbers_row) { + my $hex_colour = $block.$row.$col; + my $string_to_send = '<a', 'href="/ckoster-cgi/test_colour.pl?', 'action=colour&colour='.$hex_colour.'">'."What goes here?".'</a>'; + + print $q->th({-BGCOLOR=>"#$hex_colour", + -width=>"1"},$string_to_send),"\n"; + } }} +
    ;

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (6)
As of 2019-05-20 15:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you enjoy 3D movies?



    Results (128 votes). Check out past polls.

    Notices?