SVG – Learning by Coding
1: <?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
2: <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN"
3: "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd" [
4: <!ATTLIST svg xmlns:xlink CDATA #FIXED "http://www.w3.org/1999/xlink">
5: ]>
6:
7: <!-- SVG - Learning by Coding - http://www.datenverdrahten.de/svglbc/ -->
8: <!-- Author: Dr. Thomas Meinike 01/04 - thomas@handmadecode.de -->
9:
10: <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
11: onload="Init(evt)">
12:
13: <title>SVG - Learning by Coding</title>
14: <desc>SVG-Spezifikation in Beispielen</desc>
15:
16: <defs>
17:
18: <script type="text/javascript">
19: <![CDATA[
20:
21: var svgdoc,start=0,ende=360,drehpunkt_x,drehpunkt_y,txtobj,aniobj,krobj;
22:
23:
24: function Init(load_evt)
25: {
26: svgdoc=load_evt.target.ownerDocument;
27:
28: txtobj=svgdoc.getElementById("iptext");
29: aniobj=svgdoc.getElementById("animat");
30: krobj=svgdoc.getElementById("kreis");
31:
32: getIP();
33: }
34:
35:
36: function getIP()
37: {
38: // IP-Adresse wird mit PHP-Skript ermittelt: print $_SERVER["REMOTE_ADDR"];
39: // und via DOM dem bereits vorhandenen Textknoten zugewiesen
40: getURL("getip.php",setIP);
41: }
42:
43:
44: function setIP(urlRequestStatus)
45: {
46: if(urlRequestStatus.success && urlRequestStatus.content.indexOf("php")==-1)
47: txtobj.firstChild.nodeValue=urlRequestStatus.content;
48: else txtobj.firstChild.nodeValue="127.0.0.1";
49:
50: drehpunkt_x=txtobj.getComputedTextLength()/2;
51: drehpunkt_y=drehpunkt_x;
52:
53: txtobj.setAttribute("x","0");
54: txtobj.setAttribute("y",drehpunkt_y+5);
55:
56: aniobj.setAttribute("from",start+","+drehpunkt_x+","+drehpunkt_y);
57: aniobj.setAttribute("to",ende+","+drehpunkt_x+","+drehpunkt_y);
58:
59: krobj.setAttribute("cx",drehpunkt_x);
60: krobj.setAttribute("cy",drehpunkt_y);
61: krobj.setAttribute("r",drehpunkt_x);
62: }
63:
64: ]]>
65: </script>
66:
67: </defs>
68:
69: <text x="20" y="30" style="fill: #000; font-size: 24px">Ihre aktuelle IP ...</text>
70:
71: <g transform="translate(50,50)">
72:
73: <!--
74: der mehrfach verwendete Basiswert 38 (Pixel) entspricht der Breite der
75: Zeichenkette 127.0.0.1 bei der Verwendung serifenloser 18px Schrift im ASV
76: -->
77:
78: <circle id="kreis" cx="38" cy="38" r="38" style="fill: #FFE; stroke: #F00"/>
79:
80: <text id="iptext" x="0" y="43" style="fill: #00C; font-family: sans-serif;
81: font-size: 18px">127.0.0.1
82:
83: <animateTransform id="animat" attributeName="transform" attributeType="XML"
84: type="rotate" from="0,38,38" to="360,38,38" begin="0s" dur="10s"
85: repeatCount="indefinite"/>
86:
87: </text>
88:
89: </g>
90:
91: </svg>
[zum Anfang]