XML technologies / SVG / Using complex graphic elements and formatting / Solutions

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

  1. An SVG file with a triangle at 20/20 requires this code:

<?xml version="1.0" ?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20001102//EN" "http://www.w3.org/TR/2000/CR-SVG-20001102/DTD/svg-20001102.dtd">
<svg>
  <path d="M20 20 h+20 l-10+10 z" style="stroke:black" />  
</svg>

  1. Several commands for the <path> tag can create the arc. One possible solution is:

  2. <path d="M50 50 a15 15 0 0 0 +30 0" style="stroke:black;fill:none" />
  3. To close the semicircle, add a h or z instruction at the end of the d attribute: d="M50 50 a15 15 0 0 0 +30 0 z"

  4. To fill the semicircle and set transparency to 50%, add the style attribute: style="stroke:black;fill:red;opacity:0.5".

  5. To group the two elements, use the <g> tag again.

<g>
  <path d="M20 20 h+20 l-10+10 z" style="stroke:black" />  
  <path d="M50 50 a15 15 0 0 0 +30 0 z" style="stroke:black;fill:red;opacity:0.5" />
</g>

   

 

 

 

back to top