Using the SVG defs Element : defs « SVG « XML






Using the SVG defs Element



Rendering Rectangles with Linear Gradients
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20001102//EN"
 "http://www.w3.org/TR/2000/CR-SVG-20001102/DTD/svg-20001102.dtd">

<svg width="100%" height="100%">
  <defs>
    <linearGradient id="gradientDefinition"
      gradientUnits="userSpaceOnUse">
      <stop stop-color="yellow" offset="0%" />
      <stop stop-color="black" offset="100%" />
    </linearGradient>
  </defs>

  <rect x="50" y="50" width="400" height="200" stroke-width="4"
    stroke="red" stroke-dasharray="2 2 2 2"
    fill="url(#gradientDefinition)" />
</svg>

 








Related examples in the same category