class Color extends Expression
A Color Expression and a set of Color Utilities used in the Style module. You can create a Color from an RGB String
or from a CSS color name:new Color("0,255,0")
or from a hexadecimal:new Color("silver")
or from a RGB List:new Color("#00ff00")
or from a RGB Map:new Color([0,255,0])
or from a HSL Map:new Color([r: 0, g: 255, b: 0, a: 125])
new Color([h: 0, s: 1.0, l: 0.5])
Fields inherited from class | Fields |
---|---|
class Expression |
filterFactory |
Type | Name and description |
---|---|
static Map |
colorNameMap CSS Color names |
Constructor and description |
---|
Color
(java.lang.Object value) Create a new Color from a value |
Type Params | Return Type | Name and description |
---|---|---|
|
java.awt.Color |
asColor() Get a java.awt.Color for this Color |
|
Color |
brighter(int n) Create a new brighter Color |
|
Color |
contrast(Color color1, Color color2, double threshold) Create a new Color that has the largest constrast of the current Color between the dark and light Colors. |
|
Color |
darken(double percentage) Create a new Color by darkening the current Color |
|
Color |
darker(int n) Create a new darker Color |
|
Color |
desaturate(double percentage) Create a new Color by desaturating the current Color |
|
static void |
draw(java.util.List colors, java.lang.String orientation, int size) Draw a List of Colors to a JFrame |
|
static java.awt.image.BufferedImage |
drawToImage(java.util.List colors, java.lang.String orientation, int size) Draw a List of Colors to an Image |
|
java.lang.String |
getHex() Get this Color's hex value |
|
java.util.List |
getHsl() Get this Color's HSL value |
|
static java.util.List |
getPaletteColors(java.lang.String name, int count) Get a List of Colors from a Palette by name |
|
static java.util.List |
getPaletteNames(java.lang.String type) Get a List of Palette names by type (defaults to All) |
|
static Color |
getRandom() Generate a random color |
|
static Color |
getRandomPastel() Get a random pastel color |
|
java.util.List |
getRgb() Get this Color's RGB value |
|
Color |
grayscale(double percentage) Create a new Color by converting the current Color to grayscale |
|
java.util.List |
interpolate(Color color, int n) Interpolate a List of Colors between this Color and the given Color |
|
static java.util.List |
interpolate(Color start, Color end, int n) Interpolate a List Colors between the start and end Color |
|
Color |
lighten(double percentage) Create a new Color by lightening the current Color |
|
Color |
mix(Color color, double weight) Create a new Color by mixing the current Color with another Color |
|
Color |
saturate(double percentage) Create a new Color by saturating the current Color |
|
Color |
shade(double weight) Create a new Color by mixing the current Color with black |
|
Color |
spin(double amount) Create a new Color by rotating the hue angle of the current Color |
|
Color |
tint(double weight) Create a new Color by mixing the current Color with the Color white |
|
static java.lang.String |
toHex(java.lang.Object color) Convert a Color to a hex color string |
Methods inherited from class | Name |
---|---|
class Expression |
evaluate, fromCQL, getValue, toString |
CSS Color names
Create a new Color from a value
value
- The valueGet a java.awt.Color for this Color
Create a new brighter Color
n
- The number of times to brighten the Color. Defaults to 1.Create a new Color that has the largest constrast of the current Color between the dark and light Colors.
color1
- The dark Colorcolor2
- The light Colorpercentage
- The percentageCreate a new Color by darkening the current Color
percentage
- The percentage 0-1Create a new darker Color
n
- The number of times to darken the Color. Defaults to 1.Create a new Color by desaturating the current Color
percentage
- The percentageDraw a List of Colors to a JFrame
colors
- The List of Colorsorientation
- The orientation (vertical or horizontal)size
- The size of each Color swatchDraw a List of Colors to an Image
colors
- The List of Colorsorientation
- The orientation (vertical or horizontal)size
- The size of each Color swatchGet this Color's hex value
Get this Color's HSL value
Get a List of Colors from a Palette by name
name
- The Palette namecount
- The number of colorsGet a List of Palette names by type (defaults to All)
type
- The type (all, diverging, qualitative, sequential)Generate a random color
Get a random pastel color
Get this Color's RGB value
Create a new Color by converting the current Color to grayscale
percentage
- The percentageInterpolate a List of Colors between this Color and the given Color
color
- The other Colorn
- The number of ColorsInterpolate a List Colors between the start and end Color
start
- The start Colorend
- The end Colorn
- The number of ColorsCreate a new Color by lightening the current Color
percentage
- The percentage 0-1Create a new Color by mixing the current Color with another Color
color
- The other Colorweight
- The weightCreate a new Color by saturating the current Color
percentage
- The percentageCreate a new Color by mixing the current Color with black
weight
- The weightCreate a new Color by rotating the hue angle of the current Color
amount
- The amountCreate a new Color by mixing the current Color with the Color white
weight
- The weightConvert a Color to a hex color string
color
- The color valueGroovy Documentation