Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Re: Random Color Generator

by OfficeLinebacker (Chaplain)
on Sep 14, 2006 at 15:55 UTC ( #572946=note: print w/replies, xml ) Need Help??

in reply to Random Color Generator

Greetings, esteemed monks!

Pretty sweet. For generating just one random color, I used

my @ca=('0','3','6','9','C','E'); my @bgc=('','',''); foreach my $c (@bgc){ $r=int(rand(6)); $c=$ca[$r].$ca[$r]; } my $bgc=join("",@bgc);


I like computer programming because it's like Legos for the mind.

Replies are listed 'Best First'.
Re^2: Random Color Generator
by shibu_pu (Acolyte) on Jun 06, 2013 at 11:17 UTC
    my ($red, $green, $blue) = (int(rand(255)), int(rand(255)), int(rand(2 +55))); print qq{<div style="background-color: rgb($red, $green, $blue);"></di +v>};
      Or, if you do not want to repeat yourself:
      my ($red, $green, $blue) = map int rand 255, 1 .. 3;
      لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
        A golfer, I see.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (2)
As of 2022-05-17 19:01 GMT
Find Nodes?
    Voting Booth?
    Do you prefer to work remotely?

    Results (68 votes). Check out past polls.