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.

86 lines
2.5 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. // Create a symbol, which we will use to place instances of later:
  12. var path = new Path.Circle({
  13. center: new Point(0, 0),
  14. radius: 5,
  15. fillColor: 'white',
  16. strokeColor: 'black'
  17. });
  18. var symbol = new SymbolDefinition(path);
  19. // Place the instances of the symbol:
  20. for (var i = 0; i < count; i++) {
  21. // The center position is a random point in the view:
  22. var center = Point.random() * view.size;
  23. var placed = symbol.place(center);
  24. var scale = (i + 1) / count;
  25. placed.scale(scale);
  26. placed.data.vector = new Point({
  27. angle: Math.random() * 360,
  28. length : scale * Math.random() / 5
  29. });
  30. }
  31. var vector = new Point({
  32. angle: 45,
  33. length: 0
  34. });
  35. var mouseVector = vector.clone();
  36. function onMouseMove(event) {
  37. mouseVector = view.center - event.point;
  38. }
  39. // The onFrame function is called up to 60 times a second:
  40. function onFrame(event) {
  41. vector = vector + (mouseVector - vector) / 30;
  42. // Run through the active layer's children list and change
  43. // the position of the placed symbols:
  44. for (var i = 0; i < count; i++) {
  45. var item = project.activeLayer.children[i];
  46. var size = item.bounds.size;
  47. var length = vector.length / 10 * size.width / 10;
  48. item.position += vector.normalize(length) + item.data.vector;
  49. keepInView(item);
  50. }
  51. }
  52. function keepInView(item) {
  53. var position = item.position;
  54. var itemBounds = item.bounds;
  55. var bounds = view.bounds;
  56. if (itemBounds.left > bounds.width) {
  57. position.x = -item.bounds.width;
  58. }
  59. if (position.x < -itemBounds.width) {
  60. position.x = bounds.width + itemBounds.width;
  61. }
  62. if (itemBounds.top > view.size.height) {
  63. position.y = -itemBounds.height;
  64. }
  65. if (position.y < -itemBounds.height) {
  66. position.y = bounds.height + itemBounds.height / 2;
  67. }
  68. }
  69. </script>
  70. </head>
  71. <body>
  72. <canvas id="canvas" resize hidpi="off" style="background:black"></canvas>
  73. </body>
  74. </html>