2007-06-20| e1 |# Was is SVG ?
SVG ist …
- eine XML-basierte Auszeichnungssprache zur Beschreibung zweidimensionaler Vektorgrafiken.
- ein offener Webstandard des W3C.
- wahlweise
- statisch
- animiert
- interaktiv
<?xml version="1.0"?> <svg xmlns="http://www.w3.org/2000/svg"> <style type="text/css"> circle:hover {fill-opacity:0.9;} </style> <g style="fill-opacity:0.7;" stroke="black" stroke-width="4"> <circle cx="250" cy="120" r="100" fill="red" /> <circle cx="320" cy="220" r="100" fill="blue" /> <circle cx="180" cy="220" r="100" fill="green" /> </g> </svg>
<?xml version="1.0"?> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="[breite]" height="[höhe]"> <title>Titeltext</title> <desc>Textuelle Bildbeschreibung (optional)</desc> <defs>Stylesheets, Definitionen, Skripte</defs> <!-- Grafische Elemente --> </svg>
svg
Wurzelelement spezifiziert.viewbox
definiert werden.
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="[breite]" height="[höhe]">
viewbox
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewbox="[xmin ymin width height]">
<?xml version="1.0"?> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="-50 -50 400 300"> <rect x="50" y="50" width="250" height="150" stroke="blue" fill="gray"/> <circle cx="100" cy="120" r="80" stroke="black" fill="lightgreen"/> <line x1="0" y1="150" x2="250" y2="0" stroke="red" stroke-width="15"/> </svg>
<line x1="[xstart]" y1="[ystart]" x2="[xend]" y2="[yend]" [presentation-attributes]/>
<circle cx="[center-x]" cy="[center-y]" r="[radius]" [presentation-attributes]/>
<ellipse cx="[center-x]" cy="[center-y]" rx="[radius-x]" ry="[radius-y]" [presentation-attributes]/>
<rect x="[upper-left-x]" y="[uper-left-y]" width="[width]" height="[height]" rx="[radius-x]" ry="[radius-y]" [presentation-attributes]/>
<polygon points="[coordinate-pairs]" [presentation-attributes]/> <polyline points="[coordinate-pairs]" [presentation-attributes]/>
<image x="[upper-left-x]" y="[upper-left-y]" width="[width]" height="[height]" xlink:href="[image-uri]" />
<text x="[base-x]" y="[base-y]" font-size="[size]" font-weight="[size]" font-style="[style]" text-decoration="[decoration]" text-anchor="[start|middle|end]" [presentation-attributes]>text content</text>
<path d="[list-of-path-commands]" [presentation-attributes]>text content</text>
Attribut | Werte | Default | Bedeutung |
stroke | [Name|\#rgb-Wert|rgb(r,b,g)|none|inherit] | none | Strichfarbe |
stroke-width | [Länge|inherit] | 1 | Linienweite |
stroke-opacity | [0.0 - 1.0] | 1 | Linienopazität |
stroke-linecap | [butt|round|square|inherit] | butt | Linenabschluss |
stroke-linejoin | [miter|round|bevel|inherit] | miter | Eckenrundung |
stroke-dasharray | [dasharray|none|inherit] | none | Liste von Längenangaben definiert als Muster abwechselnd die Länge von Strichen und Lücken (durch Kommata getrennt) |
stroke-dashoffset | [Länge|inherit] | 0 | Anfangswert (Offset) des Strichmusters |
fill | [Name|#rgb-Wert|rgb(r,b,g)|none|inherit] | black | Füllfarbe |
fill-opacity | [0.0 - 1.0] | 1 | Füllopazität |
fill-rule | [nonzero|evenodd|inherit] | nonzero | Füll-Intransparenz |
<?xml version="1.0"?> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="400" height="300" viewBox="-50 -50 400 300"> <defs> <g id="smiley"> <circle cx="0" cy="0" r="40" stroke="black" /> <circle cx="-15" cy="-15" r="10" fill="black" /> <circle cx="15" cy="-15" r="10" fill="black" /> <path d="M -30,0 A 60,60,0,0,0,30,0" stroke="black" fill="none" /> </g> </defs> <use x="50" y="50" xlink:href="#smiley" stroke-width="5" fill="yellow"/> <use x="150" y="50" xlink:href="#smiley" stroke-width="5" fill="orange"/> <use x="250" y="50" xlink:href="#smiley" stroke-width="10" fill="yellow"/> <use xlink:href="#smiley" stroke-width="5" fill="yellow" transform="translate(50,150) scale(0.5,1)"/> <use xlink:href="#smiley" stroke-width="5" fill="orange" transform="translate(150,150) rotate(30)"/> <use xlink:href="#smiley" stroke-width="10" fill="yellow" transform="translate(250,150) skewX(30)"/> </svg>