Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Generating a Random Color
#1
Just thought that I would share this cool little snippet with you! A random color generator!

Pastebin Version: <!-- m --><a class="postlink" href="http://pastebin.com/CbvuhpG0">http://pastebin.com/CbvuhpG0</a><!-- m -->

[code2=java]//This method is intended to return a random color by generating random
// R,G, and B values (from 0 to 255) using Math.random()
public Color getRandomColor()
{
int randomR = (int) (Math.random() * 256);
int randomG = (int) (Math.random() * 256);
int randomB = (int) (Math.random() * 256);

return new Color(randomR, randomG, randomB); //Return the color
}[/code2]
My Blog | My Setup | My Videos | Have a wonderful day.


Messages In This Thread
Generating a Random Color - by brandonio21_phpbb3_import2 - 07-09-2012, 10:49 PM
Re: Generating a Random Color - by Macatone - 09-01-2012, 10:46 AM
Re: Generating a Random Color - by Macatone - 09-01-2012, 11:46 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)