Advertisement
Guest User

analog clock

a guest
Apr 19th, 2014
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 2.30 KB | None | 0 0
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <title>Analog Clock</title>
  5. <script>
  6. function updateTime() {
  7. var now = new Date();
  8. var min = now.getMinutes();
  9. var hour = (now.getHours() % 12) + min/60;
  10. var minangle = min*6;
  11. var hourangle = hour*30;
  12. var minhand = document.getElementById("minutehand");
  13. var hourhand = document.getElementById("hourhand");
  14. minhand.setAttribute("transform", "rotate(" + minangle + ",50,50)");
  15. hourhand.setAttribute("transform", "rotate(" + hourangle + ",50,50)");
  16. setTimeout(updateTime, 60000);
  17. }
  18. </script>
  19. <style>
  20. #clock {
  21. stroke: black;
  22. stroke-linecap: round;
  23. fill: #eef;
  24. }
  25. #face { stroke-width: 3px;}
  26. #ticks { stroke-width: 2; }
  27. #hourhand {stroke-width: 5px;}
  28. #minutehand {stroke-width: 3px;}
  29. #numbers {
  30. font-family: sans-serif; font-size: 7pt; font-weight: bold;
  31. text-anchor: middle; stroke: none; fill: black;
  32. }
  33. </style>
  34. </head>
  35. <body onload="updateTime()">
  36. <svg id="clock" viewBox="0 0 100 100" width="500" height="500">
  37. <defs> <!-- Einen Filter fu ̈r Schlagschatten definieren. -->
  38. <filter id="shadow" x="-50%" y="-50%" width="200%" height="200%">
  39. <feGaussianBlur in="SourceAlpha" stdDeviation="1" result="blur" />
  40. <feOffset in="blur" dx="1" dy="1" result="shadow" />
  41. <feMerge>
  42. <feMergeNode in="SourceGraphic"/><feMergeNode in="shadow"/>
  43.  
  44. </feMerge>
  45. </filter>
  46. </defs>
  47. <circle id="face" cx="50" cy="50" r="45"/>
  48. <g id="ticks">
  49. <line x1='50' y1='5.000' x2='50.00' y2='10.00'/>
  50. <line x1='72.50' y1='11.03' x2='70.00' y2='15.36'/>
  51. <line x1='88.97' y1='27.50' x2='84.64' y2='30.00'/>
  52. <line x1='95.00' y1='50.00' x2='90.00' y2='50.00'/>
  53. <line x1='88.97' y1='72.50' x2='84.64' y2='70.00'/>
  54. <line x1='72.50' y1='88.97' x2='70.00' y2='84.64'/>
  55. <line x1='50.00' y1='95.00' x2='50.00' y2='90.00'/>
  56. <line x1='27.50' y1='88.97' x2='30.00' y2='84.64'/>
  57. <line x1='11.03' y1='72.50' x2='15.36' y2='70.00'/>
  58. <line x1='5.000' y1='50.00' x2='10.00' y2='50.00'/>
  59. <line x1='11.03' y1='27.50' x2='15.36' y2='30.00'/>
  60. <line x1='27.50' y1='11.03' x2='30.00' y2='15.36'/>
  61. </g>
  62. <g id="numbers">
  63. <text x="50" y="18">12</text><text x="85" y="53">3</text>
  64. <text x="50" y="88">6</text><text x="15" y="53">9</text>
  65. </g>
  66. <g id="hands" filter="url(#shadow)">
  67. <line id="hourhand" x1="50" y1="50" x2="50" y2="24"/>
  68. <line id="minutehand" x1="50" y1="50" x2="50" y2="20"/>
  69. </g>
  70. </svg>
  71. </body>
  72. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement