Using an SVG pattern Element : pattern « SVG « XML






Using an SVG pattern Element

<?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>
    <pattern id="gridPattern" width="40" height="40"
      patternUnits="userSpaceOnUse">

      <rect x="0" y="0" width="40" height="40" fill="#CCCCCC"
        style="stroke:white;stroke-width:3;" />
    </pattern>
  </defs>

  <g transform="translate(20,20)">
    <rect fill="url(#gridPattern)" stroke="red" stroke-width="4"
      stroke-dasharray="2 2 2 2" x="0" y="0" width="400" height="280" />
  </g>
</svg>

 








Related examples in the same category

1.Generating a Checkerboard Grid
2.Generating a Gradient Checkerboard