Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re: CGI Colour Palette

by dws (Chancellor)
on Aug 08, 2002 at 20:59 UTC ( [id://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/', 'action=colour&colour='.$hex_colour.'">'."What goes here?".'</a>'; + + print $q->th({-BGCOLOR=>"#$hex_colour", + -width=>"1"},$string_to_send),"\n"; + } }}

Log In?

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (1)
As of 2024-05-24 20:12 GMT
Find Nodes?
    Voting Booth?

    No recent polls found