public class ColorPalette extends Object
Modifier and Type | Field and Description |
---|---|
static Color[] |
blueHues
An array of blue hues, all the blue web colors plus the greenish blues Teal, MediumAquamarine...
|
static Color[] |
defaultPalette |
static Color[] |
defaultPalette2 |
static Color[] |
defaultPalette3 |
static Color[] |
RAINBOW |
Constructor and Description |
---|
ColorPalette() |
Modifier and Type | Method and Description |
---|---|
static Color[] |
createColorPaletteByHue(int nbcolors,
float h,
float hrange,
float b,
float brange)
Generate a color palette with colors in a restricted range of Hue and Brightness.
|
static Color[] |
createColorPaletteByRange(int nbcolors) |
static Color[] |
createColorPaletteByRange(int nbcolors,
float saturation,
float brightness)
Create a palette of color by varying the hue for nbcolors steps
|
static String |
getColorCode(Color color)
Convert a 8-bit Color into a CSS-like string (without the #).
Exemple : Color(255,127,0) -> "FF7F00" |
static Color |
getColorFromCode(String code)
get a Color corresponding to a given color code.
|
static Color |
getConstrastedForegroundColor(Color backgroundColor)
Return black or white to contrast with the given background
|
static boolean |
isColorPercievedBright(Color col)
Indicates if the given color is perceived bright
|
static int |
percievedBrightness(int r,
int g,
int b)
Return the perceived brightness of the given color
|
public static final Color[] RAINBOW
public static final Color[] defaultPalette
public static final Color[] defaultPalette3
public static final Color[] defaultPalette2
public static final Color[] blueHues
public static Color[] createColorPaletteByRange(int nbcolors, float saturation, float brightness)
nbcolors
- saturation
- brightness
- public static Color[] createColorPaletteByHue(int nbcolors, float h, float hrange, float b, float brange)
nbcolors
- h
- hrange
- b
- brange
- public static Color[] createColorPaletteByRange(int nbcolors)
public static Color getConstrastedForegroundColor(Color backgroundColor)
backgroundColor
- the color of the backgroundpublic static boolean isColorPercievedBright(Color col)
col
- public static int percievedBrightness(int r, int g, int b)
r
- red value from 0-255g
- green value from 0-255b
- blue value from 0-255public static String getColorCode(Color color)
color
- the color to convert.public static Color getColorFromCode(String code) throws NumberFormatException
code
- the hexadecimal color codeNumberFormatException
Copyright © 2005–2020. All rights reserved.