public final class RandomColor extends Object
The algorithm used here is described in How to Generate Random Colors Programmatically by Martin Ankerl.
Modifier and Type | Field and Description |
---|---|
static RandomColor |
INSTANCE
A ready-to-use random color generator.
|
Constructor and Description |
---|
RandomColor()
Constructs a random color generator using the current time as a seed.
|
RandomColor(long seed)
Constructs a random color generator using specified seed.
|
Modifier and Type | Method and Description |
---|---|
static Color |
getRandomBackground()
Returns a random color which is suitable as the background of
a Component.
|
Color |
nextColor(float saturation,
float brightness)
Returns a random color.
|
public static final RandomColor INSTANCE
public RandomColor()
public RandomColor(long seed)
public Color nextColor(float saturation, float brightness)
saturation
- the saturation of the color (range 0.0-1.0)brightness
- the brightness of the color (range 0.0-1.0)public static Color getRandomBackground()
INSTANCE.nextColor(0.075F, 0.99F)
when the LAF has a light theme.
This method is thread-safe.
INSTANCE