Web UI for ARGUS server
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
2.3 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Space</title>
  6. <link rel="stylesheet" href="../css/style.css">
  7. <script type="text/javascript" src="../../dist/paper-full.js"></script>
  8. <script type="text/paperscript" canvas="canvas">
  9. // The amount of symbol we want to place;
  10. var count = 150;
  11. project.currentStyle = {
  12. fillColor: 'white'
  13. };
  14. // Place the instances of the symbol:
  15. for (var i = 0; i < count; i++) {
  16. // The center position is a random point in the view:
  17. var center = Point.random() * view.size;
  18. var scale = (i + 1) / count;
  19. var path = new Shape.Circle(center, 5 * scale);
  20. path.data.vector = new Point({
  21. angle: Math.random() * 360,
  22. length : scale * Math.random() / 5
  23. });
  24. }
  25. var vector = new Point({
  26. angle: 45,
  27. length: 0
  28. });
  29. var mouseVector = vector.clone();
  30. function onMouseMove(event) {
  31. mouseVector = view.center - event.point;
  32. }
  33. // The onFrame function is called up to 60 times a second:
  34. function onFrame(event) {
  35. vector = vector + (mouseVector - vector) / 30;
  36. // Run through the active layer's children list and change
  37. // the position of the placed symbols:
  38. for (var i = 0; i < count; i++) {
  39. var item = project.activeLayer.children[i];
  40. var size = item.bounds.size;
  41. var length = vector.length / 10 * size.width / 10;
  42. item.position += vector.normalize(length) + item.data.vector;
  43. keepInView(item);
  44. }
  45. }
  46. function keepInView(item) {
  47. var position = item.position;
  48. var itemBounds = item.bounds;
  49. var bounds = view.bounds;
  50. if (itemBounds.left > bounds.width) {
  51. position.x = -item.bounds.width;
  52. }
  53. if (position.x < -itemBounds.width) {
  54. position.x = bounds.width + itemBounds.width;
  55. }
  56. if (itemBounds.top > view.size.height) {
  57. position.y = -itemBounds.height;
  58. }
  59. if (position.y < -itemBounds.height) {
  60. position.y = bounds.height + itemBounds.height / 2;
  61. }
  62. }
  63. </script>
  64. </head>
  65. <body>
  66. <canvas id="canvas" resize hidpi="off" style="background:black"></canvas>
  67. </body>
  68. </html>