random color generators

What is the best way to make a 5 color random color generator?

Page 1 of 1

2 Replies - 3665 Views - Last Post: 16 April 2010 - 05:07 PM Rate Topic: -----

#1 Emily Rose  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 16-April 10

random color generators

Posted 16 April 2010 - 03:28 PM

What is the best way to make a 5 color random color generator?
Is This A Good Question/Topic? 0
  • +

Replies To: random color generators

#2 erik.price  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 485
  • View blog
  • Posts: 2,690
  • Joined: 18-December 08

Re: random color generators

Posted 16 April 2010 - 03:45 PM

I assume you're referring to generating 5 random java.awt.Colors?

Color has a constructor which takes 3 ints, representing red, green, and blue, respectively. To generate a random number between 0-255 (which is what you need), you could do this: (int)(Math.random() * 255), or alternatively, use a Random Object
Was This Post Helpful? 0
  • +
  • -

#3 zim1985  Icon User is offline

  • Grand Inquisitor
  • member icon

Reputation: 74
  • View blog
  • Posts: 568
  • Joined: 19-February 10

Re: random color generators

Posted 16 April 2010 - 05:07 PM

So what I would do would make an method that returns a random color in the way erik.price suggested. public Color ranCol()

And then store it in a Color array Color[] cols = new Color[5]
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1