Interface CSSColorValue

All Superinterfaces:
Cloneable, CSSPrimitiveValue, CSSTypedValue, CSSValue
All Known Subinterfaces:
CSSColorMixFunction, HSLColorValue, HWBColorValue, LABColorValue, LCHColorValue
All Known Implementing Classes:
ColorValue, HSLColorValue, HWBColorValue, LABColorValue, LCHColorValue, RGBColorValue

public interface CSSColorValue extends CSSTypedValue
Represents a color value (not including color identifiers).

When the value is a COLOR, cast it to this interface, obtain the color with getColor() and cast it to the appropriate sub-interface (like RGBAColor or LABColor) according to the color model given by getColorModel().

For any color model, you can access the color components also through the base CSSColor interface, without the need to cast it to any sub-interface (and there is no sub-interface for PROFILE colors, so in that case you must use the base interface).

  • Method Details

    • getColor

      CSSColor getColor()
      Get the color represented by this value.
      the color.
    • getColorModel

      default CSSColorValue.ColorModel getColorModel()
      Get the color model with which this value was set.
      the color model.
    • deltaE2000

      float deltaE2000(CSSColorValue color)
      Compute the difference to the given color, according to CIE Delta E 2000.
      color - the color to compute the delta from.
      the CIE Delta E 2000.
    • toLABColorValue

      LABColorValue toLABColorValue() throws DOMException
      Convert this value to a LABColorValue, if possible.
      the converted LABColorValue.
      DOMException - INVALID_STATE_ERR if the components cannot be converted.
    • toLCHColorValue

      LCHColorValue toLCHColorValue() throws DOMException
      Convert this value to a LCHColorValue, if possible.
      the converted LCHColorValue.
      DOMException - INVALID_STATE_ERR if the components cannot be converted.
    • toRGBColor

      default RGBAColor toRGBColor(boolean clamp) throws DOMException
      Get the RGB(A) color representation of this value.

      The returned value is implicitly in the sRGB color space, unless stated otherwise.

      clamp - true if the converted value has to be clamped when it does not fall into the sRGB color gamut.
      the RGBA color value.
      DOMException - INVALID_ACCESS_ERR: if this value can't return a RGB color value (either is not a COLOR, not a typed value, or clamp is false and the color does not map into the -implicit- sRGB color space).
      NOT_SUPPORTED_ERR: if the conversion needs device color space information to be performed accurately.
    • clone

      CSSColorValue clone()
      Creates and returns a copy of this value.
      Specified by:
      clone in interface CSSValue
      a clone of this value.