Movatterモバイル変換


[0]ホーム

URL:


Wayback Machine
586 captures
06 Jun 2002 - 12 Feb 2026
AugSEPOct
21
200820092010
success
fail
COLLECTED BY
Organization:Alexa Crawls
Starting in 1996,Alexa Internet has been donating their crawl data to the Internet Archive. Flowing in every day, these data are added to theWayback Machine after an embargo period.
Collection:alexa_web_2009
this data is currently not publicly accessible.
TIMESTAMPS
loading
The Wayback Machine - https://web.archive.org/web/20090921131039/http://www.w3.org:80/TR/SVG11/pservers.html

previous  next  contents  elements  attributes  properties  index  


14 January 2003

13 Gradients and Patterns


Contents


 

13.1 Introduction

With SVG, you can fill (i.e., paint the interior) or stroke (i.e., paint the outline) of shapes and text using one of the following:

SVG uses the general notion of apaint server. Gradients and patterns are just specific types of built-in paint servers. The'solidColor' element is another built-in paint server, described inColor.

Paint servers are referenced using aURI reference on a'fill' or'stroke' property.

13.2 Gradients

13.2.1 Introduction

Gradients consist of continuously smooth color transitions along a vector from one color to another, possibly followed by additional transitions along the same vector to other colors. SVG provides for two types of gradients,linear gradients andradial gradients.

Once defined, gradients are then referenced using'fill' or'stroke' properties on a givengraphics element to indicate that the given element shall be filled or stroked with the referenced gradient.

13.2.2 Linear gradients

Linear gradients are defined by a'linearGradient' element.
 

<!ENTITY % SVG.linearGradient.extra.content "" ><!ENTITY % SVG.linearGradient.element "INCLUDE" ><![%SVG.linearGradient.element;[<!ENTITY % SVG.linearGradient.content    "(( %SVG.Description.class; )*, ( %SVG.stop.qname; | %SVG.animate.qname;      | %SVG.set.qname; | %SVG.animateTransform.qname;        %SVG.linearGradient.extra.content; )*)"><!ELEMENT %SVG.linearGradient.qname; %SVG.linearG\radient.content; ><!-- end of SVG.linearGradient.element -->]]><!ENTITY % SVG.linearGradient.attlist "INCLUDE" ><![%SVG.linearGradient.attlist;[<!ATTLIST %SVG.linearGradient.qname;    %SVG.Core.attrib;    %SVG.Style.attrib;    %SVG.Color.attrib;    %SVG.Gradient.attrib;    %SVG.XLink.attrib;    %SVG.External.attrib;    x1 %Coordinate.datatype; #IMPLIED    y1 %Coordinate.datatype; #IMPLIED    x2 %Coordinate.datatype; #IMPLIED    y2 %Coordinate.datatype; #IMPLIED    gradientUnits ( userSpaceOnUse | objectBoundingBox ) #IMPLIED    gradientTransform %TransformList.datatype; #IMPLIED    spreadMethod ( pad | reflect | repeat ) #IMPLIED>

Attribute definitions:

gradientUnits = "userSpaceOnUse |objectBoundingBox"
Defines the coordinate system for attributesx1, y1, x2, y2.
IfgradientUnits="userSpaceOnUse",x1, y1, x2, y2 represent values in the coordinate system that results from taking the current user coordinate system in place at the time when the gradient element is referenced (i.e., the user coordinate system for the element referencing the gradient element via a'fill' or'stroke' property) and then applying the transform specified by attributegradientTransform.
IfgradientUnits="objectBoundingBox", the user coordinate system for attributesx1, y1, x2, y2 is established using the bounding box of the element to which the gradient is applied (seeObject bounding box units) and then applying the transform specified by attributegradientTransform.
WhengradientUnits="objectBoundingBox" andgradientTransform is the identity matrix, the stripes of the linear gradient are perpendicular to the gradient vector in object bounding box space (i.e., the abstract coordinate system where (0,0) is at the top/left of the object bounding box and (1,1) is at the bottom/right of the object bounding box). When the object's bounding box is not square, the stripes that are conceptually perpendicular to the gradient vector within object bounding box space will render non-perpendicular relative to the gradient vector in user space due to application of the non-uniform scaling transformation from bounding box space to user space.
If attributegradientUnits is not specified, then the effect is as if a value ofobjectBoundingBox were specified.
Animatable: yes.
gradientTransform = "<transform-list>"
Contains the definition of an optional additional transformation from the gradient coordinate system onto the target coordinate system (i.e., userSpaceOnUse or objectBoundingBox). This allows for things such as skewing the gradient. 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 fromobject bounding box units to user space.
If attributegradientTransform is not specified, then the effect is as if an identity transform were specified.
Animatable: yes.
x1 = "<coordinate>"
x1, y1, x2, y2 define agradient vector for the linear gradient. Thisgradient vector provides starting and ending points onto which thegradient stops are mapped. The values ofx1, y1, x2, y2 can be either numbers or percentages.
If the attribute is not specified, the effect is as if a value of "0%" were specified.
Animatable: yes.
y1 = "<coordinate>"
Seex1.
If the attribute is not specified, the effect is as if a value of "0%" were specified.
Animatable: yes.
x2 = "<coordinate>"
Seex1.
If the attribute is not specified, the effect is as if a value of "100%" were specified.
Animatable: yes.
y2 = "<coordinate>"
Seex1.
If the attribute is not specified, the effect is as if a value of "0%" were specified.
Animatable: yes.
spreadMethod = "pad | reflect | repeat"
Indicates what happens if the gradient starts or ends inside the bounds of thetarget rectangle. Possible values are:pad, which says to use the terminal colors of the gradient to fill the remainder of the target region,reflect, which says to reflect the gradient pattern start-to-end, end-to-start, start-to-end, etc. continuously until thetarget rectangle is filled, andrepeat, which says to repeat the gradient pattern start-to-end, start-to-end, start-to-end, etc. continuously until the target region is filled.
If the attribute is not specified, the effect is as if a value of "pad" were specified.
Animatable: yes.
xlink:href = "<uri>"
AURI reference to a different'linearGradient' or'radialGradient' element within the current SVG document fragment. Any'linearGradient' 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 defined gradient stops, and the referenced element does (possibly due to its ownhref attribute), then this element inherits the gradient stop from the referenced element. Inheritance can be indirect to an arbitrary level; thus, if the referenced element inherits attribute or gradient stops due to its ownhref attribute, then the current element can inherit those attributes or gradient stops.
Animatable: yes.

Percentages are allowed forx1, y1, x2, y2. For gradientUnits="userSpaceOnUse", percentages represent values relative to the current viewport. For gradientUnits="objectBoundingBox", percentages represent values relative to the bounding box for the object.

Ifx1 =x2 andy1 =y2, then the area to be painted will be painted as a single color using the color and opacity of the lastgradient stop.

Properties inherit into the'linearGradient' element from its ancestors; properties donot inherit from the element referencing the'linearGradient' element.

'linearGradient' 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'linearGradient' element; thus,'linearGradient' elements are not directly rendered even if the'display' property is set to a value other thannone, and'linearGradient' elements are available for referencing even when the'display' property on the'linearGradient' element or any of its ancestors is set tonone.

Example lingrad01 shows how to fill a rectangle by referencing a linear gradient paint server.

<?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"     xmlns="http://www.w3.org/2000/svg" version="1.1">  <desc>Example lingrad01 - fill a rectangle using a            linear gradient paint server</desc>  <g>    <defs>      <linearGradient>        <stop offset="5%" stop-color="#F60" />        <stop offset="95%" stop-color="#FF6" />      </linearGradient>    </defs>    <!-- Outline the drawing area in blue -->    <rect fill="none" stroke="blue"           x="1" y="1" width="798" height="398"/>    <!-- The rectangle is filled using a linear gradient paint server -->    <rect fill="url(#MyGradient)" stroke="black" stroke-width="5"            x="100" y="100" width="600" height="200"/>  </g></svg>
Example lingrad01
Example lingrad01 - fill a rectangle by referencing a linear gradient paint server

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

13.2.3 Radial gradients

Radial gradients are defined by a'radialGradient' element.
 

<!ENTITY % SVG.radialGradient.extra.content "" ><!ENTITY % SVG.radialGradient.element "INCLUDE" ><![%SVG.radialGradient.element;[<!ENTITY % SVG.radialGradient.content    "(( %SVG.Description.class; )*, ( %SVG.stop.qname; | %SVG.animate.qname;      | %SVG.set.qname; | %SVG.animateTransform.qname;        %SVG.radialGradient.extra.content; )*)"><!ELEMENT %SVG.radialGradient.qname; %SVG.radialG\radient.content; ><!-- end of SVG.radialGradient.element -->]]><!ENTITY % SVG.radialGradient.attlist "INCLUDE" ><![%SVG.radialGradient.attlist;[<!ATTLIST %SVG.radialGradient.qname;    %SVG.Core.attrib;    %SVG.Style.attrib;    %SVG.Color.attrib;    %SVG.Gradient.attrib;    %SVG.XLink.attrib;    %SVG.External.attrib;    cx %Coordinate.datatype; #IMPLIED    cy %Coordinate.datatype; #IMPLIED    r %Length.datatype; #IMPLIED    fx %Coordinate.datatype; #IMPLIED    fy %Coordinate.datatype; #IMPLIED    gradientUnits ( userSpaceOnUse | objectBoundingBox ) #IMPLIED    gradientTransform %TransformList.datatype; #IMPLIED    spreadMethod ( pad | reflect | repeat ) #IMPLIED>

Attribute definitions:

gradientUnits = "userSpaceOnUse |objectBoundingBox"
Defines the coordinate system for attributescx, cy, r, fx, fy.
IfgradientUnits="userSpaceOnUse",cx, cy, r, fx, fy represent values in the coordinate system that results from taking the current user coordinate system in place at the time when the gradient element is referenced (i.e., the user coordinate system for the element referencing the gradient element via a'fill' or'stroke' property) and then applying the transform specified by attributegradientTransform.
IfgradientUnits="objectBoundingBox", the user coordinate system for attributescx, cy, r, fx, fy is established using the bounding box of the element to which the gradient is applied (seeObject bounding box units) and then applying the transform specified by attributegradientTransform.
WhengradientUnits="objectBoundingBox" andgradientTransform is the identity matrix, then the rings of the radial gradient are circular with respect to the object bounding box space (i.e., the abstract coordinate system where (0,0) is at the top/left of the object bounding box and (1,1) is at the bottom/right of the object bounding box). When the object's bounding box is not square, the rings that are conceptually circular within object bounding box space will render as elliptical due to application of the non-uniform scaling transformation from bounding box space to user space.
If attributegradientUnits is not specified, then the effect is as if a value ofobjectBoundingBox were specified.
Animatable: yes.
gradientTransform = "<transform-list>"
Contains the definitions of an optional additional transformation from the gradient coordinate system onto the target coordinate system (i.e., userSpaceOnUse or objectBoundingBox). This allows for things such as skewing the gradient. 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 fromobject bounding box units to user space.
If attributegradientTransform is not specified, then the effect is as if an identity transform were specified.
Animatable: yes.
cx = "<coordinate>"
cx, cy, r define the largest (i.e., outermost) circle for the radial gradient. The gradient will be drawn such that the 100%gradient stop is mapped to the perimeter of this largest (i.e., outermost) circle.
If the attribute is not specified, the effect is as if a value of "50%" were specified.
Animatable: yes.
cy = "<coordinate>"
Seecx.
If the attribute is not specified, the effect is as if a value of "50%" were specified.
Animatable: yes.
r = "<length>"
Seecx.
A negative value is an error (seeError processing). A value of zero will cause the area to be painted as a single color using the color and opacity of the lastgradient stop.
If the attribute is not specified, the effect is as if a value of "50%" were specified.
Animatable: yes.
fx = "<coordinate>"
fx, fy define the focal point for the radial gradient. The gradient will be drawn such that the 0%gradient stop is mapped to (fx, fy).
If attributefx is not specified,fx will coincide withcx.
Animatable: yes.
fy = "<coordinate>"
Seefx.
If attributefy is not specified,fy will coincide withcy.
Animatable: yes.
spreadMethod = "pad | reflect | repeat"
Indicates what happens if the gradient starts or ends inside the bounds of the object(s) being painted by the gradient. Has the same values and meanings as thespreadMethod attribute on'linearGradient' element.
Animatable: yes.
xlink:href = "<uri>"
AURI reference to a different'linearGradient' or'radialGradient' element within the current SVG document fragment. Any'radialGradient' 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 defined gradient stops, and the referenced element does (possibly due to its ownhref attribute), then this element inherits the gradient stop from the referenced element. Inheritance can be indirect to an arbitrary level; thus, if the referenced element inherits attribute or gradient stops due to its ownhref attribute, then the current element can inherit those attributes or gradient stops.
Animatable: yes.

Percentages are allowed for attributescx,cy,r,fx andfy. ForgradientUnits="userSpaceOnUse", percentages represent values relative to the current viewport. ForgradientUnits="objectBoundingBox", percentages represent values relative to the bounding box for the object.

If the point defined byfx andfy lies outside the circle defined bycx,cy andr, then the user agent shall set the focal point to the intersection of the line from (cx,cy) to (fx,fy) with the circle defined bycx,cy andr.

Properties inherit into the'radialGradient' element from its ancestors; properties donot inherit from the element referencing the'radialGradient' element.

'radialGradient' 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'radialGradient' element; thus,'radialGradient' elements are not directly rendered even if the'display' property is set to a value other thannone, and'radialGradient' elements are available for referencing even when the'display' property on the'radialGradient' element or any of its ancestors is set tonone.

Example radgrad01 shows how to fill a rectangle by referencing a radial gradient paint server.

<?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"     xmlns="http://www.w3.org/2000/svg" version="1.1">  <desc>Example radgrad01 - fill a rectangle by referencing a            radial gradient paint server</desc>  <g>    <defs>      <radialGradient gradientUnits="userSpaceOnUse"                      cx="400" cy="200" r="300" fx="400" fy="200">        <stop offset="0%" stop-color="red" />        <stop offset="50%" stop-color="blue" />        <stop offset="100%" stop-color="red" />      </radialGradient>    </defs>    <!-- Outline the drawing area in blue -->    <rect fill="none" stroke="blue"           x="1" y="1" width="798" height="398"/>    <!-- The rectangle is filled using a radial gradient paint server -->    <rect fill="url(#MyGradient)" stroke="black" stroke-width="5"            x="100" y="100" width="600" height="200"/>  </g></svg>
Example radgrad01
Example radgrad01 - fill a rectangle by referencing a radial gradient paint server

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

13.2.4 Gradient stops

The ramp of colors to use on a gradient is defined by the'stop' elements that are child elements to either the'linearGradient' element or the'radialGradient' element.

<!ENTITY % SVG.stop.extra.content "" ><!ENTITY % SVG.stop.element "INCLUDE" ><![%SVG.stop.element;[<!ENTITY % SVG.stop.content    "( %SVG.animate.qname; | %SVG.set.qname; | %SVG.animateColor.qname;       %SVG.stop.extra.content; )*"><!ELEMENT %SVG.stop.qname; %SVG.stop.content; ><!-- end of SVG.stop.element -->]]><!ENTITY % SVG.stop.attlist "INCLUDE" ><![%SVG.stop.attlist;[<!ATTLIST %SVG.stop.qname;    %SVG.Core.attrib;    %SVG.Style.attrib;    %SVG.Color.attrib;    %SVG.Gradient.attrib;    offset %NumberOrPercentage.datatype; #REQUIRED>

Attribute definitions:

offset = "<number> |<percentage>"
Theoffset attribute is either a<number> (usually ranging from 0 to 1) or a<percentage> (usually ranging from 0% to 100%) which indicates where the gradient stop is placed. For linear gradients, theoffset attribute represents a location along thegradient vector. For radial gradients, it represents a percentage distance from (fx,fy) to the edge of the outermost/largest circle.
Animatable: yes.

The'stop-color' property indicates what color to use at that gradient stop. The keywordcurrentColor and ICC colors can be specified in the same manner as within a<paint> specification for the'fill' and'stroke' properties.

'stop-color'
Value:  currentColor |
<color> [icc-color(<name>[,<icccolorvalue>]*)] |
inherit
Initial:  black
Applies to:  'stop' elements
Inherited:  no
Percentages:  N/A
Media:  visual
Animatable:  yes

The'stop-opacity' property defines the opacity of a given gradient stop.

'stop-opacity'
Value:  <opacity-value> |inherit
Initial:  1
Applies to:  'stop' elements
Inherited:  no
Percentages:  N/A
Media:  visual
Animatable:  yes

Some notes on gradients:

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 inx andy to cover the areas to be painted. Patterns are defined using a'pattern' element and then referenced by properties'fill' and'stroke' on a givengraphics element to indicate that the given element shall be filled or stroked with the referenced pattern.

Attributesx,y,width,height andpatternUnits 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 form andn.

<!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'>

Attribute definitions:

patternUnits = "userSpaceOnUse |objectBoundingBox"
Defines the coordinate system for attributesx, y, width, height.
IfpatternUnits="userSpaceOnUse",x, y, width, 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 attributepatternTransform.
IfpatternUnits="objectBoundingBox", the user coordinate system for attributesx, y, width, height is established using the bounding box of the element to which the pattern is applied (seeObject bounding box units) and then applying the transform specified by attributepatternTransform.
If attributepatternUnits is not specified, then the effect is as if a value ofobjectBoundingBox 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 attributeviewBox is specified.
IfpatternContentUnits="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 attributepatternTransform.
IfpatternContentUnits="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 (seeObject bounding box units) and then applying the transform specified by attributepatternTransform.
If attributepatternContentUnits is not specified, then the effect is as if a value ofuserSpaceOnUse 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 fromobject bounding box units to user space.
If attributepatternTransform is not specified, then the effect is as if an identity transform were specified.
Animatable: yes.
x = "<coordinate>"
x, y, width, 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 attributespatternUnits andpatternTransform.
If the attribute is not specified, the effect is as if a value of zero were specified.
Animatable: yes.
y = "<coordinate>"
Seex.
If the attribute is not specified, the effect is as if a value of zero were specified.
Animatable: yes.
width = "<length>"
Seex.
A negative value is an error (seeError 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>"
Seex.
A negative value is an error (seeError 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>"
AURI 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 ownhref 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 ownhref attribute, then the current element can inherit those attributes or children.
Animatable: yes.

SVG'suser agent style sheet sets the'overflow' property for'pattern' elements tohidden, 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 aviewBox attribute, then the new coordinate system is fitted into the region defined by thex,y,width,height andpatternUnits attributes on the'pattern' element using the standard rules forviewBox andpreserveAspectRatio. If there is noviewBox attribute, then the new coordinate system has its origin at (x,y), where x is established by thex attribute on the'pattern' element, and y is established by they 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.

TheviewBox attribute introduces a supplemental transformation which is applied on top of any transformations necessary to create a new pattern coordinate system due to attributesx,y,width,height andpatternUnits.

Properties inherit into the'pattern' element from its ancestors; properties donot 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 thannone, and'pattern' elements are available for referencing even when the'display' property on the'pattern' element or any of its ancestors is set tonone.

Event attributes andevent 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'suser agent style sheet setting the'overflow' property for'pattern' elements tohidden, 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"     xmlns="http://www.w3.org/2000/svg" version="1.1">  <defs>    <pattern 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 radial gradient 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.


InterfaceSVGGradientElement

TheSVGGradientElement interface is a base interface used bySVGLinearGradientElement andSVGRadialGradientElement.


IDL Definition
interface SVGGradientElement :                 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 group Spread Method Types
Defined constants
SVG_SPREADMETHOD_UNKNOWNThe 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_PADCorresponds to valuepad.
SVG_SPREADMETHOD_REFLECTCorresponds to valuereflect.
SVG_SPREADMETHOD_REPEATCorresponds to valuerepeat.
Attributes
readonlySVGAnimatedEnumerationgradientUnits
Corresponds to attributegradientUnits on the given element. Takes one of the constants defined inSVGUnitTypes.
readonlySVGAnimatedTransformListgradientTransform
Corresponds to attributegradientTransform on the given element.
readonlySVGAnimatedEnumerationspreadMethod
Corresponds to attributespreadMethod on the given element. One of the Spread Method Types.

InterfaceSVGLinearGradientElement

TheSVGLinearGradientElement 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
readonlySVGAnimatedLengthx1
Corresponds to attributex1 on the given'linearGradient' element.
readonlySVGAnimatedLengthy1
Corresponds to attributey1 on the given'linearGradient' element.
readonlySVGAnimatedLengthx2
Corresponds to attributex2 on the given'linearGradient' element.
readonlySVGAnimatedLengthy2
Corresponds to attributey2 on the given'linearGradient' element.

InterfaceSVGRadialGradientElement

TheSVGRadialGradientElement 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
readonlySVGAnimatedLengthcx
Corresponds to attributecx on the given'radialGradient' element.
readonlySVGAnimatedLengthcy
Corresponds to attributecy on the given'radialGradient' element.
readonlySVGAnimatedLengthr
Corresponds to attributer on the given'radialGradient' element.
readonlySVGAnimatedLengthfx
Corresponds to attributefx on the given'radialGradient' element.
readonlySVGAnimatedLengthfy
Corresponds to attributefy on the given'radialGradient' element.

InterfaceSVGStopElement

TheSVGStopElement interface corresponds to the'stop' element.


IDL Definition
interface SVGStopElement :                 SVGElement,                SVGStylable {   readonly attribute SVGAnimatedNumber offset;};

Attributes
readonlySVGAnimatedNumberoffset
Corresponds to attributeoffset on the given'stop' element.

InterfaceSVGPatternElement

TheSVGPatternElement interface corresponds to the'pattern' element.


IDL Definition
interface SVGPatternElement :                 SVGElement,                SVGURIReference,                SVGTests,                SVGLangSpace,                SVGExternalResourcesRequired,                SVGStylable,                SVGFitToViewBox,                SVGUnitTypes {   readonly attribute SVGAnimatedEnumeration   patternUnits;  readonly attribute SVGAnimatedEnumeration   patternContentUnits;  readonly attribute SVGAnimatedTransformList patternTransform;  readonly attribute SVGAnimatedLength        x;  readonly attribute SVGAnimatedLength        y;  readonly attribute SVGAnimatedLength        width;  readonly attribute SVGAnimatedLength        height;};

Attributes
readonlySVGAnimatedEnumerationpatternUnits
Corresponds to attributepatternUnits on the given'pattern' element. Takes one of the constants defined inSVGUnitTypes.
readonlySVGAnimatedEnumerationpatternContentUnits
Corresponds to attributepatternContentUnits on the given'pattern' element. Takes one of the constants defined inSVGUnitTypes.
readonlySVGAnimatedTransformListpatternTransform
Corresponds to attributepatternTransform on the given'pattern' element.
readonlySVGAnimatedLengthx
Corresponds to attributex on the given'pattern' element.
readonlySVGAnimatedLengthy
Corresponds to attributey on the given'pattern' element.
readonlySVGAnimatedLengthwidth
Corresponds to attributewidth on the given'pattern' element.
readonlySVGAnimatedLengthheight
Corresponds to attributeheight on the given'pattern' element.

previous  next  contents  elements  attributes  properties  index  


[8]ページ先頭

©2009-2026 Movatter.jp