XML technologies / SVG / Filters, transformations and gradients / Defining and assigning gradients / Assigning a gradient to an element

(Excerpt from “Das Einsteigerseminar SVG — Webgrafiken mit XML” by Helma Spona)

An object to receive the gradient is still needed. For a round button, a circle is suitable; create it with the <circle> tag. Assign the gradient by setting the circle’s style attribute’s fill property using fill:url(#runderVerlauf). Here, runderVerlauf is the gradient name specified in its id attribute.

<?xml version="1.0" standalone="no"?>
<svg>
  ...
  <radialGradient id="runderVerlauf" cx="40%" cy="75%" r="50%">
  ...
  </radialGradient>
  <circle cx="200" cy="200" r="25" style="stroke-width:1;stroke-opacity:0.8;stroke:rgb(222,0,0);fill-opacity:1;opacity:1;fill:url(#runderVerlauf)"/>
</svg>

Source code result in the browser

Figure: Source code result in the browser.

   

 

 

 

back to top