vis.js is a dynamic, browser-based visualization library
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.2 KiB

10 years ago
  1. <?php
  2. header('Content-type: text/plain');
  3. // retrieve current time
  4. $time = time();
  5. $hour = date('h', $time) * 1;
  6. $min = date('i', $time) * 1;
  7. $sec = date('s', $time) * 1;
  8. $secAngle = $sec / 60.0 * 2.0*pi();
  9. $minAngle = ($min + $sec/60.0) / 60.0 * 2.0*pi();
  10. $hourAngle = ($hour + $min / 60.0 + $sec/60.0/60.0) / 12.0 * 2.0*pi();
  11. // create labels
  12. echo '"x", "y", "z", "' . date('H:i:s', $time) . '"' . "\n";
  13. // create circle as clock
  14. for ($h = 0; $h < 12; $h += 1) {
  15. $r = $h / 12 * 2 * pi();
  16. echo
  17. round(sin($r), 2) . ', ' .
  18. round(cos($r), 2) . ', ' .
  19. 0 . ', ' .
  20. 0 . "\n";
  21. }
  22. echo "0, 0, 0, 0\n";
  23. // create hour, minute, second pointers
  24. for ($r = 0.1; $r < 0.4; $r += 0.1) {
  25. echo
  26. round($r * sin($hourAngle), 2) . ', ' .
  27. round($r * cos($hourAngle), 2) . ', ' .
  28. 0 . ', ' .
  29. 2.5 . "\n";
  30. }
  31. for ($r = 0.1; $r < 0.7; $r += 0.1) {
  32. echo
  33. round($r * sin($minAngle), 2) . ', ' .
  34. round($r * cos($minAngle), 2) . ', ' .
  35. 0 . ', ' .
  36. 1.5 . "\n";
  37. }
  38. for ($r = 0.1; $r < 0.9; $r += 0.1) {
  39. echo
  40. round($r * sin($secAngle), 2) . ', ' .
  41. round($r * cos($secAngle), 2) . ', ' .
  42. 0 . ', ' .
  43. 3 . "\n";
  44. }
  45. ?>