Class ColorUtils
- java.lang.Object
-
- org.pushingpixels.ephemeral.chroma.utils.ColorUtils
-
public class ColorUtils extends java.lang.ObjectColor science utilities.Utility methods for color science constants and color space conversions that aren't HCT or CAM16.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static double[][]SRGB_TO_XYZ(package private) static double[]WHITE_POINT_D65(package private) static double[][]XYZ_TO_SRGB
-
Constructor Summary
Constructors Modifier Constructor Description privateColorUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static intalphaFromArgb(int argb)Returns the alpha component of a color in ARGB format.static intargbFromLab(double l, double a, double b)Converts a color represented in Lab color space into an ARGB integer.static intargbFromLinrgb(double[] linrgb)Converts a color from linear RGB components to ARGB format.static intargbFromLstar(double lstar)Converts an L* value to an ARGB representation.static intargbFromRgb(int red, int green, int blue)Converts a color from RGB components to ARGB format.static intargbFromXyz(double x, double y, double z)Converts a color from ARGB to XYZ.static intblueFromArgb(int argb)Returns the blue component of a color in ARGB format.static intdelinearized(double rgbComponent)Delinearizes an RGB component.static intgreenFromArgb(int argb)Returns the green component of a color in ARGB format.static booleanisOpaque(int argb)Returns whether a color in ARGB format is opaque.(package private) static doublelabF(double t)static double[]labFromArgb(int argb)Converts a color from ARGB representation to L*a*b* representation.(package private) static doublelabInvf(double ft)static doublelinearized(int rgbComponent)Linearizes an RGB component.static doublelstarFromArgb(int argb)Computes the L* value of a color in ARGB representation.static doublelstarFromY(double y)Converts a Y value to an L* value.static intredFromArgb(int argb)Returns the red component of a color in ARGB format.static double[]whitePointD65()Returns the standard white point; white on a sunny day.static double[]xyzFromArgb(int argb)Converts a color from XYZ to ARGB.static doubleyFromLstar(double lstar)Converts an L* value to a Y value.
-
-
-
Method Detail
-
argbFromRgb
public static int argbFromRgb(int red, int green, int blue)Converts a color from RGB components to ARGB format.
-
argbFromLinrgb
public static int argbFromLinrgb(double[] linrgb)
Converts a color from linear RGB components to ARGB format.
-
alphaFromArgb
public static int alphaFromArgb(int argb)
Returns the alpha component of a color in ARGB format.
-
redFromArgb
public static int redFromArgb(int argb)
Returns the red component of a color in ARGB format.
-
greenFromArgb
public static int greenFromArgb(int argb)
Returns the green component of a color in ARGB format.
-
blueFromArgb
public static int blueFromArgb(int argb)
Returns the blue component of a color in ARGB format.
-
isOpaque
public static boolean isOpaque(int argb)
Returns whether a color in ARGB format is opaque.
-
argbFromXyz
public static int argbFromXyz(double x, double y, double z)Converts a color from ARGB to XYZ.
-
xyzFromArgb
public static double[] xyzFromArgb(int argb)
Converts a color from XYZ to ARGB.
-
argbFromLab
public static int argbFromLab(double l, double a, double b)Converts a color represented in Lab color space into an ARGB integer.
-
labFromArgb
public static double[] labFromArgb(int argb)
Converts a color from ARGB representation to L*a*b* representation.- Parameters:
argb- the ARGB representation of a color- Returns:
- a Lab object representing the color
-
argbFromLstar
public static int argbFromLstar(double lstar)
Converts an L* value to an ARGB representation.- Parameters:
lstar- L* in L*a*b*- Returns:
- ARGB representation of grayscale color with lightness matching L*
-
lstarFromArgb
public static double lstarFromArgb(int argb)
Computes the L* value of a color in ARGB representation.- Parameters:
argb- ARGB representation of a color- Returns:
- L*, from L*a*b*, coordinate of the color
-
yFromLstar
public static double yFromLstar(double lstar)
Converts an L* value to a Y value.L* in L*a*b* and Y in XYZ measure the same quantity, luminance.
L* measures perceptual luminance, a linear scale. Y in XYZ measures relative luminance, a logarithmic scale.
- Parameters:
lstar- L* in L*a*b*- Returns:
- Y in XYZ
-
lstarFromY
public static double lstarFromY(double y)
Converts a Y value to an L* value.L* in L*a*b* and Y in XYZ measure the same quantity, luminance.
L* measures perceptual luminance, a linear scale. Y in XYZ measures relative luminance, a logarithmic scale.
- Parameters:
y- Y in XYZ- Returns:
- L* in L*a*b*
-
linearized
public static double linearized(int rgbComponent)
Linearizes an RGB component.- Parameters:
rgbComponent- 0 <= rgb_component <= 255, represents R/G/B channel- Returns:
- 0.0 <= output <= 100.0, color channel converted to linear RGB space
-
delinearized
public static int delinearized(double rgbComponent)
Delinearizes an RGB component.- Parameters:
rgbComponent- 0.0 <= rgb_component <= 100.0, represents linear R/G/B channel- Returns:
- 0 <= output <= 255, color channel converted to regular RGB space
-
whitePointD65
public static double[] whitePointD65()
Returns the standard white point; white on a sunny day.- Returns:
- The white point
-
labF
static double labF(double t)
-
labInvf
static double labInvf(double ft)
-
-