O'Reilly logo

Designing SVG Web Graphics by Andrew H. Watt

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The <radialGradient> Element

The second type of gradient provided in SVG is the radial gradient. It is defined within a <radialGradient> element nested within the <defs> element of an SVG document:

<radialGradient id="MyRadialGradient" 
gradientUnits="userSpaceOnUse" 
cx="100" cy="100" r="50" fx="100" fy="100"> 
<stop offset="20%" style="stop-color:#990066"/> 
<stop offset="70%" style="stop-color:pink"/> 
</radialGradient> 

and is referenced by another SVG element occurring later in the document. The <radialGradient> element must have an id attribute to allow it to be referenced by any graphical element elsewhere in the SVG (see Figure 06.14).

Figure 06.14. A simple radial gradient with two stops.

Listing 6.14. (RadialGradientTwoStops.svg)

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required