XML technologies / SVG / Interactive graphics / Manipulating graphic elements / Manipulating the visible property / Creating a box
(Excerpt from “Das Einsteigerseminar SVG — Webgrafiken mit XML” by Helma Spona)
The boxes are still missing. The following shows creating and scripting one rectangular and one rounded box. Copy, rename and fill them for the remaining boxes.
Define rectangular boxes consecutively at the SVG file’s end using the <use> tag. Group the box, close button, tooltip and contents so the visibility properties can show and hide them. In the <g> tag, set position with the transform attribute and always add the style attribute with visibility:hidden so the box stays hidden after loading until shown. Scripts change both attributes, so include the transform attribute even when only scripts position the box.
Note:
For initial formatting and content tests, show the box using visibility:visible.
Give the group id K01. Other names require code changes. Choose names allowing button and tooltip names to be calculated. Give the button id I01, changing only the initial letter, and the tooltip the name TI01, adding T before the button’s name.
The following <use> tag defines the box. Adapt its size to the content with the scale instruction in the transform attribute. In the style attribute use visibility:inherit so hiding and showing the group also hides and shows the box. Then define the text, formatting the heading with class="titel" and the body with class="info".
<g id="K01" transform="translate(0,0)" style="visibility:hidden">
<use x="0" y="0" xlink:href="#smKasten" transform="scale(0.5)" style="visibility:inherit;opacity:0.8"/>
<text x="5" y="20" class="titel">Was ist SVG?</text>
<text x="5" y="50" class="info">SVG ist die Abkürzung für Scalable </text>
<text x="5" y="65" class="info">Vector Graphics und stellt ein neues </text>
<text x="5" y="80" class="info">Vektorgrafikformat dar. Es basiert </text>
<text x="5" y="95" class="info">auf XML und ist äußerst flexibel ein-</text>
<text x="5" y="110" class="info">zusetzen. SVG-Dateien zeichnen sich </text>
<text x="5" y="125" class="info">durch geringe Dateigrößen aus und </text>
<text x="5" y="140" class="info">können animiert und per Skript mani-</text>
<text x="5" y="155" class="info">puliert werden.</text>
<use id="I01" x="323" y="330" xlink:href="#smButton" transform="scale(0.5)" style="opacity:0.7" onmouseover="hovern(evt)" onmouseout="hovern(evt)" onclick="schliessen(evt)"/>
<use id="TI01" x="180" y="183" xlink:href="#smTooltipp" transform="scale(1)" style="visibility:hidden" onclick="schliessenTT(evt)"/>
</g>
Define the button and tooltip last, in the right order so the tooltip appears above the button. Both <use> tags also call scripts. The function hovern shows the tooltip on hover. The functions schliessen and schliessenTT run when the button or tooltip is clicked. The box is defined but still needs its scripts to work.
Semicircular elements for horizontal navigation are simpler: define the circle and text, but only one button at the navigation bar’s end.
Note:
Since horizontal navigation holds only a few items, name the groups according to content: Kontakt, Impressum, Ziel and Projekte. This simplifies understanding the code.
Define the groups before horizontal navigation so they appear behind it. The example places them immediately after the <defs> section. Position them precisely now: the code only shows them by changing the property opacity of the style attribute.
...
</defs>
<g id="Kontakt" transform="translate(220,0)" style="visibility:visible;opacity:0.1">
<use x="0" y="=" xlink:href="#smKastenHor" transform="scale(1,1)" style="visibility:inherit;"/>
<text x="15" y="135" class="info">Wenn Sie mit mir Kontakt aufneh-</text>
<text x="25" y="150" class="info">men möchten, können Sie mir </text>
<text x="35" y="165" class="info">eine <a class="weiss" xlink:href="mailto:helma-spona.de">Mail</a> schicken o. meine </text>
<text x="50" y="180" class="info"><a class="weiss" xlink:href="http://www.helma-spona.de">Webseite</a> besuchen.</text>
</g>
...
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