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 profile (see [ICC32]). If ICC-based colors are provided and the SVG user agent supports 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').

12.2 The 'color' property

The 'color' property is used to provide a potential indirect value (currentColor) for the 'fill', 'stroke', 'stop-color', 'flood-color', 'lighting-color' 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

Except for any additional information provided in this specification, the normative definition of the property is in [CSS2].


12.3 Color profile descriptions


12.3.1 Overview of color profile descriptions

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.


12.3.2 Alternative ways for defining a color profile description

Color profile descriptions can be specified in either of the following ways:


12.3.3 The 'color-profile' element

<!ELEMENT color-profile (%descTitleMetadata;,color-profile-src) >
<!ATTLIST color-profile 
  %stdAttrs;
  name CDATA #REQUIRED
  rendering-intent (auto | perceptual | relative-colorimetric | saturation | absolute-colorimetric) "auto" >

Attribute definitions:

name = "<name>"
The name which is used as the first parameter for icc-color specifications within 'fill', 'stroke', 'stop-color', 'flood-color' and 'lighting-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 description.
Animatable: no.
rendering-intent = "auto | perceptual | relative-colorimetric | saturation | absolute-colorimetric"

'rendering-intent' permits the specification of a color profile rendering intent other than the default. 'rendering-intent' is applicable primarily to color profiles corresponding to CMYK color spaces. The different options cause different methods to be used for translating colors to the color gamut of the target rendering device:

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 and force the intent, overriding any intent that might be stored in the profile itself.
perceptual
This method, often the preferred choice for images, preserves the relationship between colors. It attempts to maintain relative color values among the pixels as they are mapped to the target device gamut. Sometimes pixel values that were originally within the target device gamut are changed in order to avoid hue shifts and discontinuities and to preserve as much as possible the overall appearance of the scene.
saturation
Preserves the relative saturation (chroma) values of the original pixels. Out of gamut colors are converted to colors that have the same saturation but fall just inside the gamut.
relative colorimetric
Leaves colors that fall inside the gamut unchanged. This method usually converts out of gamut colors to colors that have the same lightness but fall just inside the gamut.
absolute colorimetric
Disables white point matching when converting colors. This option is generally not recommended.

Animatable: no.
Attributes defined elsewhere:
%stdAttrs;.

12.3.4 The 'color-profile-src' element

<!ELEMENT color-profile-src EMPTY >
<!ATTLIST color-profile-src 
  %stdAttrs;
  %xlinkRefAttrs;
  xlink:href %URI; #REQUIRED >

Attribute definitions:

xlink:href = "<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.
Animatable: no.
Attributes defined elsewhere:
%stdAttrs;, %xlinkRefAttrs;.

12.3.5 @color-profile' when using CSS styling

When the document is styled using CSS, the @color-profile rule can be used to specify a color profile description. 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>
See the description for the name attribute on the 'color-profile' element. 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
Initial: auto
Media: visual
Animatable:   no

See the description for the rendering-intent attribute on the 'color-profile' element.


12.4 DOM interfaces

The following interfaces are defined below: SVGColorProfileElement, SVGColorProfileSrcElement, SVGColorProfileRule.


Interface SVGColorProfileElement

The SVGColorProfileElement interface corresponds to the 'color-profile' element.


IDL Definition
interface SVGColorProfileElement : 
                SVGElement,
                SVGRenderingIntent { 

           attribute DOMString      name;
                       // raises DOMException on setting
           attribute unsigned short renderingIntent;
                       // raises DOMException on setting
};

Attributes
DOMString name
Corresponds to property name within an @color-profile rule.
Exceptions on setting
DOMException
NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.
unsigned short renderingIntent
The type of rendering intent, identified by one of the SVGRenderingIntent constants.
Exceptions on setting
DOMException
NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.

Interface SVGColorProfileSrcElement

The SVGColorProfileSrcElement interface corresponds to the 'color-profile-src' element.


IDL Definition
interface SVGColorProfileSrcElement : 
                SVGElement,
                SVGURIReference {};


Interface SVGColorProfileRule

The SVGColorProfileRule interface represents an @color-profile rule in a CSS style sheet. An @color-profile rule identifies a ICC profile which can be referenced within a given document.

Support for the SVGColorProfileRule interface is only required in user agents that support styling with CSS.


IDL Definition
interface SVGColorProfileRule : 
                SVGCSSRule,
                SVGRenderingIntent { 

           attribute DOMString      src;
                       // raises DOMException on setting
           attribute DOMString      name;
                       // raises DOMException on setting
           attribute unsigned short renderingIntent;
                       // raises DOMException on setting
};

Attributes
DOMString src
Corresponds to property src within an @color-profile rule.
Exceptions on setting
DOMException
NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.
DOMString name
Corresponds to property name within an @color-profile rule.
Exceptions on setting
DOMException
NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.
unsigned short renderingIntent
The type of rendering intent, identified by one of the SVGRenderingIntent constants.
Exceptions on setting
DOMException
NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.