XML technologies / SVG / Creating simple SVG graphics / Solutions

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

  1. The tag <circle> can only create circles, whose vertical and horizontal radii are always equal and specified by the r attribute. The <ellipse> tag lets you specify both radii separately, allowing you to draw both circles and ellipses.

  2. Create an empty text file in your editor and save it with the filename extension .svg. Then insert the following code and save the changes again.

<?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></svg>

  1. The circle’s code is:

  2. <circle cx="50" cy="50" r="10"/>
  3. To define the color, add a style attribute to the tag:

  4. <circle cx="50" cy="50" r="10" style="fill:blue;stroke:red"/>
  5. The HTML code for displaying the file should be:

<HTML>
  <HEAD>
    <TITLE>Lösungen KAP02</TITLE>
  </HEAD>
  <BODY>
    <EMBED src="KAP02.svg" type="image/svg-xml" />
  </BODY>
</HTML>

  1. The code must be:

  2. <text x="50" y="100" style="fill:green;font-size:12pt">inhalt</text>

   

 

 

 

back to top