XML technologies / SVG / Adding hyperlinks and external files / Including external files / Combining external graphics with SVG elements
(Excerpt from “Das Einsteigerseminar SVG — Webgrafiken mit XML” by Helma Spona)
You can also mix external graphics with SVG elements. This is useful when replacing an image map with such a graphic while reusing the external images elsewhere on the web page. This generally requires precise positioning of the external images. The following example shows how.
In principle, graphics included with the <image> tag are positioned just like other SVG elements. Specify the attributes x and y or use the transform attribute for positioning.
<?xml version="1.0" standalone="no"?>
...
<svg width="430" height="330">
<rect x="0" y="0" width="100%" height="100%" style="fill:#EAEAEA"/>
<image x="50" y="50" xlink:href="krawatte.png" width="70" height="74" />
<image x="122" y="126" xlink:href="halstuch.png" width="97" height="74" />
<image x="280" y="126" xlink:href="tuchgruen.png" width="97" height="74" />
<image x="50" y="202" xlink:href="tuchgrau.png" width="70" height="74" />
<image x="221" y="202" xlink:href="tuchblau.png" width="57" height="74" />
<g style="stroke:red;stroke-width:1">
<path d="M30 49 h+150" />
<path d="M6 125 h+394" />
<path d="M35 201 h+342" />
<path d="M15 277 h+380" />
<path d="M49 30 v+280" />
<path d="M121 40 v+260" />
<path d="M220 120 v+165" />
<path d="M279 110 v+185" />
<path d="M377 125 v+76" />
</g>
<g style="font-family:'Arial Unicode MS',Arial,Verdana,Helvetica;font-size:16px;font-stretch:condensed;font-weight:bolder">
<text x="123" y="47">Corporate</text>
<text x="346" y="123">Aktuelles</text>
<text x="6" y="123">Trends</text>
<text x="223" y="198">Kontakt</text>
<text x="342" y="291">Produkte</text>
</g>
</svg>
The preceding code produces this graphic, incorporating the photos as external PNG graphics into the SVG graphic.
Figure: Graphic with embedded PNG images.
Copyright © verlag moderne industrie GmbH 2001
You may print the online version for your private use.
Otherwise, this chapter from “Das Einsteigerseminar SVG — Webgrafiken mit XML” is subject to the same conditions as the bound edition. The work, including all its parts, is protected by copyright. All rights reserved, including reproduction, translation, microfilming, and storage and processing in electronic systems.
verlag moderne industrie GmbH, Justus-von-Liebig-Straße 1, D-86899 Landsberg/Lech, fon ++49 (0) 81 91 / 125 – 0, leserservice(at)mi-verlag.de
back to top