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.

79 lines
1.7 KiB

10 years ago
  1. <?php
  2. header('Content-type: text/plain');
  3. // initialize flushing without buffer
  4. @apache_setenv('no-gzip', 1);
  5. @ini_set('zlib.output_compression', 0);
  6. @ini_set('implicit_flush', 1);
  7. for ($i = 0; $i < ob_get_level(); $i++) { ob_end_flush(); }
  8. ob_implicit_flush(1);
  9. ob_start();
  10. // create labels once?
  11. //echo '"id", "x", "y", "z", "Color"' . "\n";
  12. while (true) {
  13. // retrieve current time
  14. $time = time();
  15. $hour = date('h', $time) * 1;
  16. $min = date('i', $time) * 1;
  17. $sec = date('s', $time) * 1;
  18. $secAngle = $sec / 60.0 * 2.0*pi();
  19. $minAngle = ($min + $sec/60.0) / 60.0 * 2.0*pi();
  20. $hourAngle = ($hour + $min / 60.0 + $sec/60.0/60.0) / 12.0 * 2.0*pi();
  21. $id = 0;
  22. // create circle as clock
  23. for ($h = 0; $h < 12; $h += 1) {
  24. $r = $h / 12 * 2 * pi();
  25. echo
  26. $id . ', ' .
  27. round(sin($r), 2) . ', ' .
  28. round(cos($r), 2) . ', ' .
  29. 0 . ', ' .
  30. 0 . "\n";
  31. $id++;
  32. }
  33. echo "$id, 0, 0, 0, 0\n";
  34. $id++;
  35. // create hour, minute, second pointers
  36. for ($r = 0.1; $r < 0.4; $r += 0.1) {
  37. echo
  38. $id . ', ' .
  39. round($r * sin($hourAngle), 2) . ', ' .
  40. round($r * cos($hourAngle), 2) . ', ' .
  41. 0 . ', ' .
  42. 2.5 . "\n";
  43. $id++;
  44. }
  45. for ($r = 0.1; $r < 0.7; $r += 0.1) {
  46. echo
  47. $id . ', ' .
  48. round($r * sin($minAngle), 2) . ', ' .
  49. round($r * cos($minAngle), 2) . ', ' .
  50. 0 . ', ' .
  51. 1.5 . "\n";
  52. $id++;
  53. }
  54. for ($r = 0.1; $r < 0.9; $r += 0.1) {
  55. echo
  56. $id . ', ' .
  57. round($r * sin($secAngle), 2) . ', ' .
  58. round($r * cos($secAngle), 2) . ', ' .
  59. 0 . ', ' .
  60. 3 . "\n";
  61. $id++;
  62. }
  63. // flush, send the new output to the client now
  64. ob_flush();
  65. flush();
  66. sleep(1);
  67. }
  68. ?>