annotate www/tests/svgclock.svg @ 101:52e44ee1c791 tip master

enabled all scores in autostart script
author Rob Canning <rc@kiben.net>
date Tue, 21 Apr 2015 16:20:57 +0100
parents 49c94f63b8b0
children
rev   line source
rc-web@42 1 <svg xmlns="http://www.w3.org/2000/svg"
rc-web@42 2 xmlns:xlink="http://www.w3.org/1999/xlink"
rc-web@42 3 width="270px" height="270px" viewBox="0 0 270 270"
rc-web@42 4 onload="setClock()">
rc-web@42 5
rc-web@42 6 <!--This is a modified version from Charles McCathieNevile's code
rc-web@42 7 1. Javascript added to set the time as current
rc-web@42 8 2. Removed animation code
rc-web@42 9 3. Other minor changes -->
rc-web@42 10
rc-web@42 11 <script>
rc-web@42 12
rc-web@42 13 <![CDATA[
rc-web@42 14
rc-web@42 15 var xmlns="http://www.w3.org/2000/svg"
rc-web@42 16
rc-web@42 17 function setClock()
rc-web@42 18 {
rc-web@42 19 var date = new Date()
rc-web@42 20 var h = parseInt(date.getHours())
rc-web@42 21 h = h > 12 ? h-12: h
rc-web@42 22 var m = parseInt(date.getMinutes())
rc-web@42 23 var s = parseInt(date.getSeconds())
rc-web@42 24
rc-web@42 25 var second = 6*s
rc-web@42 26 var minute =(m+s/60)*6
rc-web@42 27 var hour = (h+m/60+s/3600)*30
rc-web@42 28
rc-web@42 29
rc-web@42 30 var hourHand = document.getElementById("hour")
rc-web@42 31 var minuteHand = document.getElementById("minute")
rc-web@42 32 var secondHand = document.getElementById("second")
rc-web@42 33
rc-web@42 34 hourHand.setAttribute("transform","rotate("+ hour.toString() +")")
rc-web@42 35 minuteHand.setAttribute("transform","rotate("+ minute.toString() +")")
rc-web@42 36 secondHand.setAttribute("transform","rotate("+ second.toString() +")")
rc-web@42 37 }
rc-web@42 38
rc-web@42 39 ]]>
rc-web@42 40
rc-web@42 41 </script>
rc-web@42 42
rc-web@42 43
rc-web@42 44 <g transform="translate(150,150)">
rc-web@42 45
rc-web@42 46 <!-- tick -->
rc-web@42 47 <g>
rc-web@42 48 <circle r="108" fill="none" stroke-width="4" stroke="gray" />
rc-web@42 49 <circle r="97" fill="none" stroke-width="11" stroke="black"
rc-web@42 50 stroke-dasharray="4,46.789082" transform="rotate(-1.5)" />
rc-web@42 51 <circle r="100" fill="none" stroke-width="5" stroke="black"
rc-web@42 52 stroke-dasharray="2,8.471976" transform="rotate(-.873)" />
rc-web@42 53 </g>
rc-web@42 54
rc-web@42 55 <!-- hands -->
rc-web@42 56 <g id="hands" transform="rotate(180)">
rc-web@42 57 <g id="hour">
rc-web@42 58 <line stroke-width="5" y2="75" stroke-linecap="round" stroke="blue" opacity=".5" />
rc-web@42 59 <animateTransform attributeName="transform" type="rotate"
rc-web@42 60 repeatCount="indefinite" dur="12h" by="360" />
rc-web@42 61 <circle r="7" />
rc-web@42 62 </g>
rc-web@42 63 <g id="minute">
rc-web@42 64 <line stroke-width="4" y2="93" stroke-linecap="round" stroke="green" opacity=".9" />
rc-web@42 65 <animateTransform attributeName="transform" type="rotate"
rc-web@42 66 repeatCount="indefinite" dur="60min" by="360" />
rc-web@42 67 <circle r="6" fill="red"/>
rc-web@42 68 </g>
rc-web@42 69 <g id="second">
rc-web@42 70 <line stroke-width="2" y1="-20" y2="102" stroke-linecap="round" stroke="red" />
rc-web@42 71 <animateTransform attributeName="transform" type="rotate"
rc-web@42 72 repeatCount="indefinite" dur="60s" by="360" />
rc-web@42 73 <circle r="4" fill="blue"/>
rc-web@42 74 </g>
rc-web@42 75 </g>
rc-web@42 76
rc-web@42 77 </g>
rc-web@42 78
rc-web@42 79 </svg>