previous next contents properties index

# 12 Color

### Contents

## 12.1 Introduction

All SVG colors are specified in the sRGB color space (see [SRGB]). At a minimum, SVG user agents shall conform to the color behavior requirements specified in the Colors chapter of the CSS2 specification (see [CSS2]).

Additionally, SVG content can specify an alternate color specification using an ICC profiles (see [ICC32]). If ICC-based colors are provided and the SVG user agent support ICC color, then the ICC-based color takes precedence over the sRGB color specification. Note that color interpolation occurs in an RGB color space even if an ICC-based color specification is provided (see 'color-interpolation').

For more on specifying color properties, refer to the descriptions of the 'fill' property and the 'stroke' property.

The 'color' property is used to provide a potential indirect value (currentColor) for the 'fill' and 'stroke' properties.

'color'

  Value: | <color> | inherit
  Initial: | depends on user agent
  Applies to: | 'fill' and 'stroke' properties
  Inherited: | see Inheritance of Painting Properties
  Percentages: | N/A
  Media: | visual
  Animatable: | yes

For a description of the parameters, refer to [CSS2].

## 12.2 Color profile descriptions and @color-profile

The International Color Consortium has established a standard, the ICC Profile [ICC32], for documenting the color characteristics of input and output devices. Using these profiles, it is possible to build a transform and correct visual data for viewing on different devices.

A color profile description provides the bridge between an ICC profile and references to that ICC profile within SVG content. The color profile description is added to the user agent's list of known color profiles and then used to select the relevant profile. The color profile description contains descriptors for the location of the color profile on the Web, a name to reference the profile and information about rendering intent.

Color profile descriptions in CSS style sheets are specified via an @color-profile rule. The general form is:

    @color-profile { <color-profile-description> }

where the <color-profile-description> has the form:

    descriptor: value;
    [...]
    descriptor: value;

Each @color-profile rule specifies a value for every color profile descriptor, either implicitly or explicitly. Those not given explicit values in the rule take the initial value listed with each descriptor in this specification. These descriptors apply solely within the context of the @color-profile rule in which they are defined, and do not apply to document language elements. Thus, there is no notion of which elements the descriptors apply to, or whether the values are inherited by child elements.

The following are the descriptors for a <color-profile-description>:

'src' (Descriptor)

  Values: | sRGB | <uri> | inherit
  Initial: | auto
  Media: | visual

sRGB
  The source profile is assumed to be sRGB [SRGB]. This differs from auto in that it overrides an embedded profile inside an image.
<uri>
  The name or location of a standard ICC profile resource. Due to the size of profiles, the <uri> may specify a special name representing a standard profile. The name sRGB, being the standard WWW color space, is defined separately because of its significance, although the rules regarding application of any special profile shall be identical.

'name' (Descriptor)

  Values: | <name>
  Initial: | undefined
  Media: | visual

<name>
  The name which is used as the first parameter for icc-color specifications within 'fill', 'stroke' and 'stop-color' property values to identify the color profile to use for the ICC color specification. Note that if <name> is not provided, it will be impossible to reference the given @color-profile definition.

'rendering-intent' (Descriptor)

  Values: | auto | perceptual | relative-colorimetric | saturation | absolute-colorimetric | inherit
  Initial: | auto
  Media: | visual
  Animatable: | no

This property permits the specification of a color profile rendering intent other than the default. The behavior of values other than auto and inherent are defined by the International Color Consortium standard.

auto
  This is the default behavior. The user-agent determines the best intent based on the content type. For image content containing an embedded profile, it shall be assumed that the intent specified within the profile is the desired intent. Otherwise, the user agent shall use the current profile (based on the color-profile style) and force the intent, overriding any intent that might be stored in the profile itself.

## 12.3 DOM interfaces

The following interfaces are defined below: SVGICCColor, SVGColor.

### Interface SVGICCColor

The SVGICCColor expresses an ICC-based color specification and is a base class for interface SVGColor

IDL Definition

      interface SVGICCColor {
                 attribute DOMString colorProfile;
        readonly attribute SVGList   colors;
      };

Attributes
  DOMString colorProfile

    The name of the color profile, which is the first parameter of an ICC color specification.

  readonly SVGList colors

    The list of color values that define this ICC color. Each color value is an arbitrary floating point number.

    The various methods from SVGList, which are defined to accept parameters and return values of type Object, must receive parameters of type float and return values of type float.

### Interface SVGColor

The SVGColor corresponds to color value definition for the 'stop-color' property and is a base class for interface SVGPaint. It incorporates SVG's extended notion of color, which incorporates ICC-based color specifications.

Interface SVGColor does not correspond to the <color> basic data type. For the <color> basic data type, the applicable DOM interfaces are defined in [DOM2-CSS]; in particular, see the [DOM2-CSS-RGBCOLOR].

IDL Definition

      interface SVGColor {
        // Color Types
        constant unsigned short SVG_COLORTYPE_UNKNOWN           = 0;
        constant unsigned short SVG_COLORTYPE_RGBCOLOR          = 1;
        constant unsigned short SVG_COLORTYPE_RGBCOLOR_ICCCOLOR = 2;

        readonly attribute unsigned short colorType;
        readonly attribute RGBColor       rgbColor;
        readonly attribute SVGICCColor    iccColor;
        readonly attribute unsigned short animatedColorType;
        readonly attribute RGBColor       animatedRGBColor;
        readonly attribute SVGICCColor    animatedICCColor;

        void        setRGBColor ( in RGBColor rgbColor )
                        raises( SVGException );
        void        setRGBColorICCColor ( in RGBColor rgbColor, in SVGICCColor iccColor )
                        raises( SVGException );
        RGBColor    createRGBColor (  );
        SVGICCColor createSVGICCColor (  );
      };

Definition group Color Types
  Defined constants

    SVG_COLORTYPE_UNKNOWN |  | The color type is not one of predefined types. It is invalid to attempt to define a new value of this type or to attempt to switch an existing value to this type.
    SVG_COLORTYPE_RGBCOLOR |  | An sRGB color has been specified without an alternative ICC color specification.
    SVG_COLORTYPE_RGBCOLOR_ICCCOLOR |  | An sRGB color has been specified along with an alternative ICC color specification.

Attributes
  readonly unsigned short colorType
    The type of the value as specified by one of the constants specified above.
  readonly RGBColor rgbColor
    The color specified in the sRGB color space.
  readonly SVGICCColor iccColor
    The alternate ICC color specification.
  readonly unsigned short animatedColorType
    If the given attribute or property is being animated, contains the current animated value of colorType. If the given attribute or property is not currently being animated, contains the same value as colorType.
  readonly RGBColor animatedRGBColor
    If the given attribute or property is being animated, contains the current animated value of rgbColor. If the given attribute or property is not currently being animated, contains the same value as rgbColor.
  readonly SVGICCColor animatedICCColor
    If the given attribute or property is being animated, contains the current animated value of iccColor. If the given attribute or property is not currently being animated, contains the same value as iccColor.
Methods
  setRGBColor
    Modifies the color value to be the specified sRGB color without an alternate ICC color specification.
    Parameters

      in RGBColor rgbColor |  | The new sRGB color specification.

    No Return Value
    Exceptions

      SVGException |  | SVG_WRONG_TYPE_ERR: Raised if a parameter is of the wrong type.

  setRGBColorICCColor
    Modifies the color value to be the specified sRGB color with an alternate ICC color specification.
    Parameters

      in RGBColor rgbColor |  | The new sRGB color specification.
      in SVGICCColor iccColor |  | The alternate ICC color specification.

    No Return Value
    Exceptions

      SVGException |  | SVG_WRONG_TYPE_ERR: Raised if a parameter is of the wrong type.

  createRGBColor
    Returns an RGBColor object which is initialized to red=green=blue=0.
    No Parameters
    Return value

      RGBColor |  | The returned RGBColor object.

    No Exceptions
  createSVGICCColor
    Returns an SVGICCColor object which is initialized to an empty list of colors and a null for the colorProfile string.
    No Parameters
    Return value

      SVGICCColor |  | The returned SVGICCColor object.

    No Exceptions

previous next contents properties index