Debian Codegraph @

html/clock.svg

raw symbols SCIP
1 <?xml version="1.0" encoding="utf-8"?>
2 <!--
3 RailControl - Model Railway Control Software
4
5 Copyright (c) 2017-2025 by Teddy / Dominik Mahrer - www.railcontrol.org
6
7 RailControl is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 3, or (at your option) any
10 later version.
11
12 RailControl is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15 See the GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with RailControl; see the file LICENCE. If not see
19 <http://www.gnu.org/licenses/>.
20
21 Written based on idea of RĂ¼diger Appel. See
22 http://www.3quarks.com/en/SVGClock/index.html
23 -->
24 <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ev="http://www.w3.org/2001/xml-events" version="1.1" baseProfile="full" width="100%" height="100%" viewBox="0 0 200 200">
25 <defs>
26 <symbol id="hourStroke">
27 <rect x="96.25" y="0" width="7.5" height="25"/>
28 </symbol>
29
30 <symbol id="minuteStroke">
31 <rect x="98.5" y="0" width="3" height="7.5"/>
32 </symbol>
33
34 <symbol id="fiveMinutesStrokes">
35 <use xlink:href="#hourStroke"/>
36 <use xlink:href="#minuteStroke" transform="rotate( 6, 100, 100)"/>
37 <use xlink:href="#minuteStroke" transform="rotate(12, 100, 100)"/>
38 <use xlink:href="#minuteStroke" transform="rotate(18, 100, 100)"/>
39 <use xlink:href="#minuteStroke" transform="rotate(24, 100, 100)"/>
40 </symbol>
41
42 <symbol id="quarterStrokes">
43 <use xlink:href="#fiveMinutesStrokes"/>
44 <use xlink:href="#fiveMinutesStrokes" transform="rotate(30, 100, 100)"/>
45 <use xlink:href="#fiveMinutesStrokes" transform="rotate(60, 100, 100)"/>
46 </symbol>
47 </defs>
48
49 <g id="clock">
50 <g id="dial" style="fill:#ccc">
51 <use xlink:href="#quarterStrokes" style="stroke:none"/>
52 <use xlink:href="#quarterStrokes" style="stroke:none" transform="rotate( 90, 100, 100)"/>
53 <use xlink:href="#quarterStrokes" style="stroke:none" transform="rotate(180, 100, 100)"/>
54 <use xlink:href="#quarterStrokes" style="stroke:none" transform="rotate(270, 100, 100)"/>
55 </g>
56
57 <g id="hourHand">
58 <polygon points="95,33 105,33 106,125 94,125" style="stroke:none; fill:#eee"/>
59 </g>
60
61 <g id="minuteHand">
62 <polygon points="96,5 104,5 105,125 95,125" style="stroke:none; fill:#eee"/>
63 </g>
64
65 <g id="secondHand">
66 <polygon points="99.4,8 100.6,8 102.8,123 97.2,123" style="stroke:none; fill:#ad1a14"/>
67 </g>
68 </g>
69
70 <defs>
71 <script type="text/javascript">
72 <![CDATA[
73 var clock = new Object();
74
75 clock.rotateElement = function(id, angle)
76 {
77 let element = document.getElementById(id);
78 if (!element) return;
79 element.setAttribute('transform', 'rotate(' + angle + ', 100, 100)');
80 }
81
82 clock.draw = function()
83 {
84 let now = new Date();
85 let hours = now.getHours();
86 let minutes = now.getMinutes();
87 let seconds = now.getSeconds();
88
89 this.rotateElement('hourHand', 30 * hours + 0.5 * minutes);
90 this.rotateElement('minuteHand', 6 * minutes + 0.1 * seconds);
91 this.rotateElement('secondHand', 6 * seconds);
92 }
93
94 clock.update = function()
95 {
96 clock.draw();
97 setTimeout(function()
98 {
99 clock.update();
100 }, 250);
101 }
102
103 clock.update();
104
105 ]]>
106 </script>
107 </defs>
108 </svg>
109