firstDaisy Diff compare report.
Click on the changed parts for a detailed description. Use the left and right arrow keys to walk through the modifications.
last 

13.3 Patterns

A pattern is used to fill or stroke an object using a pre-defined graphic object which can be replicated ("tiled") at fixed intervals in x and y to cover the areas to be painted. Patterns are defined using a 'pattern' element and then referenced by properties 'fill' and 'stroke' on a given graphics element to indicate that the given element shall be filled or stroked with the referenced pattern.

Attributes 'x', 'y', 'width', 'height' and 'patternUnits' define a reference rectangle somewhere on the infinite canvas. The reference rectangle has its top/left at (x, y) and its bottom/right at (x + width, y + height). The tiling theoretically extends a series of such rectangles to infinity in X and Y (positive and negative), with rectangles starting at (x + m*widthy + n* height) for each possible integer value for m and n.


<!ENTITY % SVG.pattern.extra.content "" >
<!ENTITY % SVG.pattern.element "INCLUDE" >
<![%SVG.pattern.element;[
<!ENTITY % SVG.pattern.content
    "( %SVG.Description.class; | %SVG.Animation.class; %SVG.Structure.class;
       %SVG.Conditional.class; %SVG.Image.class; %SVG.Style.class;
       %SVG.Shape.class; %SVG.Text.class; %SVG.Marker.class;
       %SVG.ColorProfile.class; %SVG.Gradient.class; %SVG.Pattern.class;
       %SVG.Clip.class; %SVG.Mask.class; %SVG.Filter.class; %SVG.Cursor.class;
       %SVG.Hyperlink.class; %SVG.View.class; %SVG.Script.class;
       %SVG.Font.class; %SVG.pattern.extra.content; )*"
>
<!ELEMENT %SVG.pattern.qname; %SVG.pattern.content; >
<!-- end of SVG.pattern.element -->]]>
<!ENTITY % SVG.pattern.attlist "INCLUDE" >
<![%SVG.pattern.attlist;[
<!ATTLIST %SVG.pattern.qname;
    %SVG.Core.attrib;
    %SVG.Conditional.attrib;
    %SVG.Style.attrib;
    %SVG.Presentation.attrib;
    %SVG.XLink.attrib;
    %SVG.External.attrib;
    x %Coordinate.datatype; #IMPLIED
    y %Coordinate.datatype; #IMPLIED
    width %Length.datatype; #IMPLIED
    height %Length.datatype; #IMPLIED
    patternUnits ( userSpaceOnUse | objectBoundingBox ) #IMPLIED
    patternContentUnits ( userSpaceOnUse | objectBoundingBox ) #IMPLIED
    patternTransform %TransformList.datatype; #IMPLIED
    viewBox %ViewBoxSpec.datatype; #IMPLIED
    preserveAspectRatio %PreserveAspectRatioSpec.datatype; 'xMidYMid meet'
>

'pattern'
Categories:
None
Content model:
Any number of the following elements, in any order:
Attributes:
DOM Interfaces:

Attribute definitions:

patternUnits = "userSpaceOnUse | objectBoundingBox"
Defines the coordinate system for attributes 'x', 'y', 'width, ' and 'height'.
If patternUnits="userSpaceOnUse", 'x', 'y', 'width, ' and 'height' represent values in the coordinate system that results from taking the current user coordinate system in place at the time when the 'pattern' element is referenced (i.e., the user coordinate system for the element referencing the 'pattern' element via a 'fill' or 'stroke' property) and then applying the transform specified by attribute 'patternTransform'.
If patternUnits="objectBoundingBox", the user coordinate system for attributes 'x', 'y', 'width, ' and 'height' is established using the bounding box of the element to which the pattern is applied (see Object bounding box units) and then applying the transform specified by attribute 'patternTransform'.
If attribute 'patternUnits' is not specified, then the effect is as if a value of 'objectBoundingBox' were specified.
Animatable: yes.
patternContentUnits = "userSpaceOnUse | objectBoundingBox"
Defines the coordinate system for the contents of the 'pattern'. Note that this attribute has no effect if attribute 'viewBox' is specified.
If patternContentUnits="userSpaceOnUse", the user coordinate system for the contents of the 'pattern' element is the coordinate system that results from taking the current user coordinate system in place at the time when the 'pattern' element is referenced (i.e., the user coordinate system for the element referencing the 'pattern' element via a 'fill' or 'stroke' property) and then applying the transform specified by attribute 'patternTransform'.
If patternContentUnits="objectBoundingBox", the user coordinate system for the contents of the 'pattern' element is established using the bounding box of the element to which the pattern is applied (see Object bounding box units) and then applying the transform specified by attribute 'patternTransform'.
If attribute 'patternContentUnits' is not specified, then the effect is as if a value of 'userSpaceOnUse' were specified.
Animatable: yes.
patternTransform = "<transform-list>"
Contains the definition of an optional additional transformation from the pattern coordinate system onto the target coordinate system (i.e., 'userSpaceOnUse' or 'objectBoundingBox'). This allows for things such as skewing the pattern tiles. This additional transformation matrix is post-multiplied to (i.e., inserted to the right of) any previously defined transformations, including the implicit transformation necessary to convert from object bounding box units to user space.
If attribute 'patternTransform' is not specified, then the effect is as if an identity transform were specified.
Animatable: yes.
x = "<coordinate>"
'x', 'y', 'width, ' and 'height' indicate how the pattern tiles are placed and spaced. These attributes represent coordinates and values in the coordinate space specified by the combination of attributes 'patternUnits' and 'patternTransform'.
If the attribute is not specified, the effect is as if a value of zero were specified.
Animatable: yes.
y = "<coordinate>"
See 'x'.
If the attribute is not specified, the effect is as if a value of zero were specified.
Animatable: yes.
width = "<length>"
See 'x'.
A negative value is an error (see Error processing). A value of zero disables rendering of the element (i.e., no paint is applied).
If the attribute is not specified, the effect is as if a value of zero were specified.
Animatable: yes.
height = "<length>"
See 'x'.
A negative value is an error (see Error processing). A value of zero disables rendering of the element (i.e., no paint is applied).
If the attribute is not specified, the effect is as if a value of zero were specified.
Animatable: yes.
xlink:href = "<uri>"
A URI reference to a different 'pattern' element within the current SVG document fragment. Any attributes which are defined on the referenced element which are not defined on this element are inherited by this element. If this element has no children, and the referenced element does (possibly due to its own 'xlink:href' attribute), then this element inherits the children from the referenced element. Inheritance can be indirect to an arbitrary level; thus, if the referenced element inherits attributes or children due to its own 'xlink:href' attribute, then the current element can inherit those attributes or children.
Animatable: yes.

SVG's user agent style sheet sets the 'overflow' property for 'pattern' elements to hidden, which causes a rectangular clipping path to be created at the bounds of the pattern tile. Unless the 'overflow' property is overridden, any graphics within the pattern which goes outside of the pattern rectangle will be clipped. Example pattern01 below shows the effect of clipping to the pattern tile.

The contents of the 'pattern' are relative to a new coordinate system. If there is a 'viewBox' attribute, then the new coordinate system is fitted into the region defined by the 'x', 'y', 'width', 'height' and 'patternUnits' attributes on the 'pattern' element using the standard rules for 'viewBox' and 'preserveAspectRatio'. If there is no 'viewBox' attribute, then the new coordinate system has its origin at (x, y), where x is established by the 'x' attribute on the 'pattern' element, and y is established by the 'y' attribute on the 'pattern' element. Thus, in the following example:

<pattern x="10" y="10" width="20" height="20">
   <rect x="5" y="5" width="10" height="10"/>
</pattern>

the rectangle has its top/left located 5 units to the right and 5 units down from the origin of the pattern tile.

The 'viewBox' attribute introduces a supplemental transformation which is applied on top of any transformations necessary to create a new pattern coordinate system due to attributes 'x', 'y', 'width', 'height' and 'patternUnits'.

Properties inherit into the 'pattern' element from its ancestors; properties do not inherit from the element referencing the 'pattern' element.

'pattern' elements are never rendered directly; their only usage is as something that can be referenced using the 'fill' and 'stroke' properties. The 'display' property does not apply to the 'pattern' element; thus, 'pattern' elements are not directly rendered even if the 'display' property is set to a value other than none, and 'pattern' elements are available for referencing even when the 'display' property on the 'pattern' element or any of its ancestors is set to none.

Event attributes and event listeners attached to the contents of a 'pattern' element are not processed; only the rendering aspects of 'pattern' elements are processed.

Example pattern01 shows how to fill a rectangle by referencing a pattern paint server. Note how the blue stroke of each triangle has been clipped at the top and the left. This is due to SVG's user agent style sheet setting the 'overflow' property for 'pattern' elements to hidden, which causes the pattern to be clipped to the bounds of the pattern tile.

<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" 
  "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="8cm" height="4cm" viewBox="0 0 800 400" version="1.1"
     xmlns="http://www.w3.org/2000/svg"
version="1.1"
>
  <defs>
    <pattern id="TrianglePattern" patternUnits="userSpaceOnUse"
             x="0" y="0" width="100" height="100"
             viewBox="0 0 10 10" >
      <path d="M 0 0 L 7 0 L 3.5 7 z" fill="red" stroke="blue" />
    </pattern> 
  </defs>

  <!-- Outline the drawing area in blue -->
  <rect fill="none" stroke="blue" 
        x="1" y="1" width="798" height="398"/>

  <!-- The ellipse is filled using a triangle pattern paint server
       and stroked with black -->
  <ellipse fill="url(#TrianglePattern)" stroke="black" stroke-width="5"  
           cx="400" cy="200" rx="350" ry="150" />
</svg>
Example pattern01
Example pattern01 — fill a rectangle by referencing a pattern paint server

View this example as SVG (SVG-enabled browsers only)  

13.4 Gradient Module
ElementsAttributesContent Model
linearGradientCore.attrib, XLink.attrib, Paint.attrib, Gradient.attrib, Style.attrib, External.attrib, gradientUnits, gradientTransform, x1, y1, x2, y2, spreadMethod(Description.class | Animation.class | stop)*
radialGradientCore.attrib, XLink.attrib, Paint.attrib, Gradient.attrib, Style.attrib, External.attrib, gradientUnits, gradientTransform, cx, cy, r, fx, fy, spreadMethod(Description.class | Animation.class | stop)*
stopCore.attrib, Style.attrib, Paint.attrib, Gradient.attrib, offset(Description.class | Animation.class)*
13.4.1 Gradient Content Set

The Gradient Module defines the Gradient.class content set.

Content Set NameElements in Content Set
Gradient.classlinearGradient, radialGradient
13.4.2 Gradient Attribute Set

The Gradient Module defines the Gradient.attrib attribute set.

Collection NameAttributes in Collection
Gradient.attribstop-color, stop-opacity
13.5 Pattern Module
ElementsAttributesContent Model
patternCore.attrib,, XLink.attrib, Conditional.attrib, External.attrib, Style.attrib, Presentation.attrib, viewBox, preserveAspectRatio, patternUnits, patternTransform, x, y, width, height(Description.class | Structure.class | Shape.class | Text.class | Image.class | Hyperlink.class | Script.class | Style.class | Clip.class | Mask.class | Gradient.class | Pattern.class | Filter.class | Cursor.class | Font.class | ColorProfile.class | Animation.class)*
13.5.1 Pattern Content Set

The Pattern Module defines the Pattern.class content set.

Content Set NameElements in Content Set
Pattern.classpattern

 

13.6 DOM interfaces

The following interfaces are defined below: SVGGradientElement, SVGLinearGradientElement, SVGRadialGradientElement, SVGStopElement, SVGPatternElement.

13.4 DOM interfaces

13.4.1 Interface SVGGradientElement

The SVGGradientElement interface is a base interface used by SVGLinearGradientElement and SVGRadialGradientElement. IDL Definition
interface SVGGradientElement : SVGElement,
                
SVGElement,
               
SVGURIReference,
                               SVGExternalResourcesRequired,
                               SVGStylable,
                               SVGUnitTypes {

  // Spread Method Types
  
const
unsigned short SVG_SPREADMETHOD_UNKNOWN = 0;
  
const
unsigned short SVG_SPREADMETHOD_PAD 
= 1;
  
const
unsigned short SVG_SPREADMETHOD_REFLECT = 2;
  
const
unsigned short SVG_SPREADMETHOD_REPEAT 
= 3;

  readonly attribute SVGAnimatedEnumeration 
gradientUnits;
  readonly attribute SVGAnimatedTransformList gradientTransform;
  readonly attribute SVGAnimatedEnumeration 
spreadMethod;
};
Definition
Constants in group
Spread Method Types
Defined constants
“Spread Method Types”:
SVG_SPREADMETHOD_UNKNOWN(unsigned short)
The 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_SPREADMETHOD_PAD(unsigned short)
Corresponds to value 'pad'.
SVG_SPREADMETHOD_REFLECT(unsigned short)
Corresponds to value 'reflect'.
SVG_SPREADMETHOD_REPEAT(unsigned short)
Corresponds to value 'repeat'.
Attributes:
gradientUnits (readonly SVGAnimatedEnumeration
gradientUnits
)
Corresponds to attribute 'gradientUnits' on the given element. Takes one of the constants defined in SVGUnitTypes.
gradientTransform (readonly SVGAnimatedTransformList
gradientTransform
)
Corresponds to attribute 'gradientTransform' on the given element.
spreadMethod (readonly SVGAnimatedEnumeration
spreadMethod
)
Corresponds to attribute 'spreadMethod' on the given element. One of the Spread Method Types defined on this interface.

13.4.2 Interface SVGLinearGradientElement

The SVGLinearGradientElement interface corresponds to the 'linearGradient' element. IDL Definition
interface SVGLinearGradientElement : SVGGradientElement {
  
readonly attribute SVGAnimatedLength x1;
  readonly attribute SVGAnimatedLength y1;
  readonly attribute SVGAnimatedLength x2;
  readonly attribute SVGAnimatedLength y2;
};
Attributes:
x1 (readonly SVGAnimatedLength
x1
)
Corresponds to attribute 'x1' on the given 'linearGradient' element.
y1 (readonly SVGAnimatedLength
y1
)
Corresponds to attribute 'y1' on the given 'linearGradient' element.
x2 (readonly SVGAnimatedLength
x2
)
Corresponds to attribute 'x2' on the given 'linearGradient' element.
y2 (readonly SVGAnimatedLength
y2
)
Corresponds to attribute 'y2' on the given 'linearGradient' element.

13.4.3 Interface SVGRadialGradientElement

The SVGRadialGradientElement interface corresponds to the 'radialGradient' element. IDL Definition
interface SVGRadialGradientElement : SVGGradientElement {
  
readonly attribute SVGAnimatedLength cx;
  readonly attribute SVGAnimatedLength cy;
  readonly attribute SVGAnimatedLength r;
  readonly attribute SVGAnimatedLength fx;
  readonly attribute SVGAnimatedLength fy;
};
Attributes:
cx (readonly SVGAnimatedLength
cx
)
Corresponds to attribute 'cx' on the given 'radialGradient' element.
cy (readonly SVGAnimatedLength
cy
)
Corresponds to attribute 'cy' on the given 'radialGradient' element.
r (readonly SVGAnimatedLength
r
)
Corresponds to attribute 'r' on the given 'radialGradient' element.
fx (readonly SVGAnimatedLength
fx
)
Corresponds to attribute 'fx' on the given 'radialGradient' element.
fy (readonly SVGAnimatedLength
fy
)
Corresponds to attribute 'fy' on the given 'radialGradient' element.

13.4.4 Interface SVGStopElement

The SVGStopElement interface corresponds to the 'stop' element. IDL Definition
interface SVGStopElement : SVGElement,
                
SVGElement,
           
SVGStylable {
  
readonly attribute SVGAnimatedNumber offset;
};
Attributes:
offset (readonly SVGAnimatedNumber
offset
)
Corresponds to attribute 'offset' on the given 'stop' element.

13.4.5 Interface SVGPatternElement

The SVGPatternElement interface corresponds to the 'pattern' element. IDL Definition
interface SVGPatternElement : SVGElement,
                
SVGElement,
              SVGURIReference,
  
SVGURIReference,
                            SVGTests,
                              SVGLangSpace,
                              SVGExternalResourcesRequired,
                              SVGStylable,
                
SVGFitToViewBox,
              SVGFitToViewBox,
  
SVGUnitTypes
 
{
    
readonly
 
attribute
 
SVGAnimatedEnumeration
   
patternUnits;
   
readonly
 
attribute
 
SVGAnimatedEnumeration
   
patternContentUnits;
   
readonly
 
attribute
 
SVGAnimatedTransformList
 
patternTransform;
   
readonly
 
attribute
SVGUnitTypes 
SVGAnimatedLength
{
  readonly attribute SVGAnimatedEnumeration 
x
patternUnits;
  readonly attribute 
SVGAnimatedLength
SVGAnimatedEnumeration patternContentUnits;
  readonly attribute SVGAnimatedTransformList 
y
patternTransform;
  readonly attribute SVGAnimatedLength x;
  readonly attribute SVGAnimatedLength 
width
y;
  readonly attribute SVGAnimatedLength width;
  readonly attribute SVGAnimatedLength 
height;
};
Attributes:
patternUnits (readonly SVGAnimatedEnumeration
patternUnits
)
Corresponds to attribute 'patternUnits' on the given 'pattern' element. Takes one of the constants defined in SVGUnitTypes.
patternContentUnits (readonly SVGAnimatedEnumeration
patternContentUnits
)
Corresponds to attribute 'patternContentUnits' on the given 'pattern' element. Takes one of the constants defined in SVGUnitTypes.
patternTransform (readonly SVGAnimatedTransformList
patternTransform
)
Corresponds to attribute 'patternTransform' on the given 'pattern' element.
x (readonly SVGAnimatedLength
x
)
Corresponds to attribute 'x' on the given 'pattern' element.
y (readonly SVGAnimatedLength
y
)
Corresponds to attribute 'y' on the given 'pattern' element.
width (readonly SVGAnimatedLength
width
)
Corresponds to attribute 'width' on the given 'pattern' element.
height (readonly SVGAnimatedLength
height
)
Corresponds to attribute 'height' on the given 'pattern' element.
SVG 1.1 (Second Edition) – 16 May 2009