public class Colors extends Object
| Modifier and Type | Method and Description |
|---|---|
static Color |
computeContrastingColor(int argb)
Compute a color (either black or white) that as a large contrast
to the given ARGB color.
|
static double |
computeContrastRatio(int argb0,
int argb1)
Compute the contrast ratio between the given colors, as defined by
https://www.w3.org/TR/UNDERSTANDING-WCAG20/
visual-audio-contrast-contrast.html
|
static double |
computeLuminance(int argb)
Returns the luminance of the given ARGB color
|
static int[] |
createArgbs(List<? extends Color> colors)
Creates an array containing the ARGB values of the given colors
|
static Color |
createClamped(double r,
double g,
double b)
Create a new color, clamping the given values to be in [0, 1]
|
static Color |
createClamped(double r,
double g,
double b,
double a)
Create a new color, clamping the given values to be in [0, 1].
|
static Color |
createClamped(int r,
int g,
int b)
Create a new color, clamping the given values to be in [0, 255]
|
static Color |
createClamped(int r,
int g,
int b,
int a)
Create a new color, clamping the given values to be in [0, 255].
|
static Color[] |
createColors(int... argbs)
Creates an array containing the colors for the given ARGB values
|
static int |
getAlpha(int argb)
Returns the alpha component of the given ARGB color
|
static int |
getARGB(int a,
int r,
int g,
int b)
Returns the ARGB color that is composed from the given values
|
static int |
getBlue(int argb)
Returns the blue component of the given ARGB color
|
static int |
getGreen(int argb)
Returns the green component of the given ARGB color
|
static int |
getRed(int argb)
Returns the red component of the given ARGB color
|
static int |
interpolate(int argb0,
int argb1,
double v)
Linearly interpolate between the given ARGB colors.
|
static Color |
interpolateClamping(Color c0,
Color c1,
double v)
Linearly interpolate between the given colors, clamping each
component to be in [0,255)
|
static int |
interpolateClamping(int argb0,
int argb1,
double v)
Linearly interpolate between the given ARGB colors, clamping each
component to be in [0,255)
|
public static Color createClamped(int r, int g, int b)
r - The red componentg - The green componentb - The blue componentpublic static Color createClamped(int r, int g, int b, int a)
r - The red componentg - The green componentb - The blue componenta - The alpha componentpublic static Color createClamped(double r, double g, double b)
r - The red componentg - The green componentb - The blue componentpublic static Color createClamped(double r, double g, double b, double a)
r - The red componentg - The green componentb - The blue componenta - The alpha componentpublic static int getAlpha(int argb)
argb - The ARGB colorpublic static int getRed(int argb)
argb - The ARGB colorpublic static int getGreen(int argb)
argb - The ARGB colorpublic static int getBlue(int argb)
argb - The ARGB colorpublic static int getARGB(int a,
int r,
int g,
int b)
a - The alpha valuer - The red valueg - The green valueb - The blue valuepublic static int[] createArgbs(List<? extends Color> colors)
colors - The colorspublic static Color[] createColors(int... argbs)
argbs - The ARGB valuespublic static int interpolate(int argb0,
int argb1,
double v)
argb0 - The first colorargb1 - The second colorv - The interpolation valuepublic static int interpolateClamping(int argb0,
int argb1,
double v)
argb0 - The first colorargb1 - The second colorv - The interpolation valuepublic static Color interpolateClamping(Color c0, Color c1, double v)
c0 - The first colorc1 - The second colorv - The interpolation valuepublic static Color computeContrastingColor(int argb)
argb - The ARGB colorpublic static double computeContrastRatio(int argb0,
int argb1)
https://www.w3.org/TR/UNDERSTANDING-WCAG20/ visual-audio-contrast-contrast.html
argb0 - The first ARGB colorargb1 - The second ARGB colorpublic static double computeLuminance(int argb)
argb - The ARGB colorCopyright © 2018. All rights reserved.