What is the best way to make a 5 color random color generator?
random color generatorsWhat is the best way to make a 5 color random color generator?
Page 1 of 1
2 Replies - 3101 Views - Last Post: 16 April 2010 - 05:07 PM
Replies To: random color generators
#2
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
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
#3
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]
And then store it in a Color array Color[] cols = new Color[5]
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote





|