ColorUtils

public final class ColorUtils


A set of color-related utility methods, building upon those available in Color.

Summary

Public constructors

Public methods

static @ColorInt int
HSLToColor(float[] hsl)

Convert HSL (hue-saturation-lightness) components to a RGB color.

static @ColorInt int
LABToColor(
    @FloatRange(from = 0.0, to = 100) double l,
    @FloatRange(from = "-128", to = 127) double a,
    @FloatRange(from = "-128", to = 127) double b
)

Converts a color from CIE Lab to its RGB representation.

static void
LABToXYZ(
    @FloatRange(from = 0.0, to = 100) double l,
    @FloatRange(from = "-128", to = 127) double a,
    @FloatRange(from = "-128", to = 127) double b,
    double[] outXyz
)

Converts a color from CIE Lab to CIE XYZ representation.

static void
RGBToHSL(
    @IntRange(from = 0, to = 255) int r,
    @IntRange(from = 0, to = 255) int g,
    @IntRange(from = 0, to = 255) int b,
    float[] outHsl
)

Convert RGB components to HSL (hue-saturation-lightness).

static void
RGBToLAB(
    @IntRange(from = 0, to = 255) int r,
    @IntRange(from = 0, to = 255) int g,
    @IntRange(from = 0, to = 255) int b,
    double[] outLab
)

Convert RGB components to its CIE Lab representative components.

static void
RGBToXYZ(
    @IntRange(from = 0, to = 255) int r,
    @IntRange(from = 0, to = 255) int g,
    @IntRange(from = 0, to = 255) int b,
    double[] outXyz
)

Convert RGB components to its CIE XYZ representative components.

static @ColorInt int
XYZToColor(
    @FloatRange(from = 0.0, to = "") double x,
    @FloatRange(from = 0.0, to = "") double y,
    @FloatRange(from = 0.0, to = "") double z
)

Converts a color from CIE XYZ to its RGB representation.

static void
XYZToLAB(
    @FloatRange(from = 0.0, to = "") double x,
    @FloatRange(from = 0.0, to = "") double y,
    @FloatRange(from = 0.0, to = "") double z,
    double[] outLab
)

Converts a color from CIE XYZ to CIE Lab representation.

static @ColorInt int
blendARGB(
    @ColorInt int color1,
    @ColorInt int color2,
    @FloatRange(from = 0.0, to = 1.0) float ratio
)

Blend between two ARGB colors using the given ratio.

static void