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.
#2
Thanks! Very helpful. Is it okay if I post versions of this for C# and Visual Basic .NET?
#3
Of course! Just post them in the proper forums!
My Blog | My Setup | My Videos | Have a wonderful day.
#4
Okay, thanks!


Forum Jump:


Users browsing this thread: 1 Guest(s)