Class ColorUtils

java.lang.Object
org.glavo.monetfx.internal.utils.ColorUtils

public class ColorUtils extends Object
Color science utilities.

Utility methods for color science constants and color space conversions that aren't HCT or CAM16.

  • Method Summary

    Modifier and Type
    Method
    Description
    static int
    alphaFromArgb(int argb)
    Returns the alpha component of a color in ARGB format.
    static int
    argbFromFx(javafx.scene.paint.Color color)
     
    static int
    argbFromLab(double l, double a, double b)
    Converts a color represented in Lab color space into an ARGB integer.
    static int
    argbFromLinrgb(double[] linrgb)
    Converts a color from linear RGB components to ARGB format.
    static int
    argbFromLstar(double lstar)
    Converts an L* value to an ARGB representation.
    static int
    argbFromRgb(int red, int green, int blue)
    Converts a color from RGB components to ARGB format.
    static int
    argbFromXyz(double x, double y, double z)
    Converts a color from ARGB to XYZ.
    static int
    blueFromArgb(int argb)
    Returns the blue component of a color in ARGB format.
    static int
    delinearized(double rgbComponent)
    Delinearizes an RGB component.
    static javafx.scene.paint.Color
    fxFromArgb(int argb)
     
    static int
    greenFromArgb(int argb)
    Returns the green component of a color in ARGB format.
    static boolean
    isOpaque(int argb)
    Returns whether a color in ARGB format is opaque.
    static double[]
    labFromArgb(int argb)
    Converts a color from ARGB representation to L*a*b* representation.
    static double
    linearized(int rgbComponent)
    Linearizes an RGB component.
    static double
    lstarFromArgb(int argb)
    Computes the L* value of a color in ARGB representation.
    static double
    lstarFromY(double y)
    Converts a Y value to an L* value.
    static int
    redFromArgb(int argb)
    Returns the red component of a color in ARGB format.
    static double[]
    Returns the standard white point; white on a sunny day.
    static double[]
    xyzFromArgb(int argb)
    Converts a color from XYZ to ARGB.
    static double
    yFromLstar(double lstar)
    Converts an L* value to a Y value.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • fxFromArgb

      public static javafx.scene.paint.Color fxFromArgb(int argb)
    • argbFromFx

      public static int argbFromFx(javafx.scene.paint.Color color)
    • 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 invalid input: '<'= rgb_component invalid input: '<'= 255, represents R/G/B channel
      Returns:
      0.0 invalid input: '<'= output invalid input: '<'= 100.0, color channel converted to linear RGB space
    • delinearized

      public static int delinearized(double rgbComponent)
      Delinearizes an RGB component.
      Parameters:
      rgbComponent - 0.0 invalid input: '<'= rgb_component invalid input: '<'= 100.0, represents linear R/G/B channel
      Returns:
      0 invalid input: '<'= output invalid input: '<'= 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