Class Cam16

java.lang.Object
org.glavo.monetfx.internal.hct.Cam16

public final class Cam16 extends Object
CAM16, a color appearance model. Colors are not just defined by their hex code, but rather, a hex code and viewing conditions.

CAM16 instances also have coordinates in the CAM16-UCS space, called J*, a*, b*, or jstar, astar, bstar in code. CAM16-UCS is included in the CAM16 specification, and should be used when measuring distances between colors.

In traditional color spaces, a color can be identified solely by the observer's measurement of the color. Color appearance models such as CAM16 also use information about the environment where the color was observed, known as the viewing conditions.

For example, white under the traditional assumption of a midday sun white point is accurately measured as a slightly chromatic blue by CAM16. (roughly, hue 203, chroma 3, lightness 100)

  • Method Summary

    Modifier and Type
    Method
    Description
    double
    distance(Cam16 other)
    CAM16 instances also have coordinates in the CAM16-UCS space, called J*, a*, b*, or jstar, astar, bstar in code.
    static Cam16
    fromInt(int argb)
    Create a CAM16 color from a color, assuming the color was viewed in default viewing conditions.
    static Cam16
    fromUcs(double jstar, double astar, double bstar)
    Create a CAM16 color from CAM16-UCS coordinates.
    static Cam16
    fromUcsInViewingConditions(double jstar, double astar, double bstar, ViewingConditions viewingConditions)
    Create a CAM16 color from CAM16-UCS coordinates in defined viewing conditions.
    double
    a* coordinate in CAM16-UCS
    double
    b* coordinate in CAM16-UCS
    double
    Chroma in CAM16
    double
    Hue in CAM16
    double
    Lightness in CAM16
    double
    Lightness coordinate in CAM16-UCS
    double
    Colorfulness in CAM16.
    double
    Brightness in CAM16.
    double
    Saturation in CAM16.
    int
    ARGB representation of the color.

    Methods inherited from class java.lang.Object

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

    • distance

      public double distance(Cam16 other)
      CAM16 instances also have coordinates in the CAM16-UCS space, called J*, a*, b*, or jstar, astar, bstar in code. CAM16-UCS is included in the CAM16 specification, and is used to measure distances between colors.
    • getHue

      public double getHue()
      Hue in CAM16
    • getChroma

      public double getChroma()
      Chroma in CAM16
    • getJ

      public double getJ()
      Lightness in CAM16
    • getQ

      public double getQ()
      Brightness in CAM16.

      Prefer lightness, brightness is an absolute quantity. For example, a sheet of white paper is much brighter viewed in sunlight than in indoor light, but it is the lightest object under any lighting.

    • getM

      public double getM()
      Colorfulness in CAM16.

      Prefer chroma, colorfulness is an absolute quantity. For example, a yellow toy car is much more colorful outside than inside, but it has the same chroma in both environments.

    • getS

      public double getS()
      Saturation in CAM16.

      Colorfulness in proportion to brightness. Prefer chroma, saturation measures colorfulness relative to the color's own brightness, where chroma is colorfulness relative to white.

    • getJstar

      public double getJstar()
      Lightness coordinate in CAM16-UCS
    • getAstar

      public double getAstar()
      a* coordinate in CAM16-UCS
    • getBstar

      public double getBstar()
      b* coordinate in CAM16-UCS
    • fromInt

      public static Cam16 fromInt(int argb)
      Create a CAM16 color from a color, assuming the color was viewed in default viewing conditions.
      Parameters:
      argb - ARGB representation of a color.
    • fromUcs

      public static Cam16 fromUcs(double jstar, double astar, double bstar)
      Create a CAM16 color from CAM16-UCS coordinates.
      Parameters:
      jstar - CAM16-UCS lightness.
      astar - CAM16-UCS a dimension. Like a* in L*a*b*, it is a Cartesian coordinate on the Y axis.
      bstar - CAM16-UCS b dimension. Like a* in L*a*b*, it is a Cartesian coordinate on the X axis.
    • fromUcsInViewingConditions

      public static Cam16 fromUcsInViewingConditions(double jstar, double astar, double bstar, ViewingConditions viewingConditions)
      Create a CAM16 color from CAM16-UCS coordinates in defined viewing conditions.
      Parameters:
      jstar - CAM16-UCS lightness.
      astar - CAM16-UCS a dimension. Like a* in L*a*b*, it is a Cartesian coordinate on the Y axis.
      bstar - CAM16-UCS b dimension. Like a* in L*a*b*, it is a Cartesian coordinate on the X axis.
      viewingConditions - Information about the environment where the color was observed.
    • toInt

      public int toInt()
      ARGB representation of the color. Assumes the color was viewed in default viewing conditions, which are near-identical to the default viewing conditions for sRGB.