java.lang.Object | |
↳ | lineageos.util.ColorUtils |
Helper class for colorspace conversions, and color-related algorithms which may be generally useful.
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Calculate the colour difference value between two colours in lab space.
| |||||||||||
Converts an RGB packed int into L*a*b space, which is well-suited for finding
perceptual differences in color
| |||||||||||
Drop the alpha component from an RGBA packed int and return
a non sign-extended RGB int.
| |||||||||||
Finds the "perceptually nearest" color from a list of colors to
the given RGB value.
| |||||||||||
Convenience method to find the nearest "solid" color (having RGB components
of either 0 or 255) to the given color.
| |||||||||||
Takes a drawable and uses Palette to generate a suitable "alert"
color which can be used for an external notification mechanism
such as an RGB LED.
| |||||||||||
Given a Palette, pick out the dominant swatch based on population
| |||||||||||
Convert a color temperature value (in Kelvin) to a RGB units as floats.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
Calculate the colour difference value between two colours in lab space. This code is from OpenIMAJ under BSD License
Parameters | |
---|---|
L1 |
double : first colour's L component |
a1 |
double : first colour's a component |
b1 |
double : first colour's b component |
L2 |
double : second colour's L component |
a2 |
double : second colour's a component |
b2 |
double : second colour's b component |
Returns | |
---|---|
double |
the CIE 2000 colour difference |
Converts an RGB packed int into L*a*b space, which is well-suited for finding perceptual differences in color
Parameters | |
---|---|
rgb |
int : A 32-bit value of packed RGB ints |
Returns | |
---|---|
float[] |
array of Lab values of size 3 |
Drop the alpha component from an RGBA packed int and return a non sign-extended RGB int.
Returns | |
---|---|
int |
rgb |
Finds the "perceptually nearest" color from a list of colors to the given RGB value. This is done by converting to L*a*b colorspace and using the CIE2000 deltaE algorithm.
Parameters | |
---|---|
rgb |
int : The original color to start with |
colors |
int : An array of colors to test |
Returns | |
---|---|
int |
RGB packed int of nearest color in the list |
Convenience method to find the nearest "solid" color (having RGB components of either 0 or 255) to the given color. This is useful for cases such as LED notification lights which may not be able to display the full range of colors due to hardware limitations.
Returns | |
---|---|
int |
the perceptually nearest color in RGB |
Takes a drawable and uses Palette to generate a suitable "alert" color which can be used for an external notification mechanism such as an RGB LED. This will always pick a solid color having RGB components of 255 or 0.
Parameters | |
---|---|
drawable |
Drawable : The drawable to generate a color for |
Returns | |
---|---|
int |
a suitable solid color which corresponds to the image |
Given a Palette, pick out the dominant swatch based on population
Returns | |
---|---|
Palette.Swatch |
the dominant Swatch |
Convert a color temperature value (in Kelvin) to a RGB units as floats. This can be used in a transform matrix or hardware gamma control.
Returns | |
---|---|
float[] |
array of floats representing rgb values 0->1 |