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.

70 lines
2.2 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Smoothing</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. var width, height, center;
  10. var points = 10;
  11. var smooth = true;
  12. var path = new Path({
  13. fillColor: 'black'
  14. });
  15. var mousePos = view.center / 2;
  16. var pathHeight = mousePos.y;
  17. initializePath();
  18. function initializePath() {
  19. center = view.center;
  20. width = view.size.width;
  21. height = view.size.height / 2;
  22. path.segments = [];
  23. path.add(view.bounds.bottomLeft);
  24. for (var i = 1; i < points; i++) {
  25. var point = new Point(width / points * i, center.y);
  26. path.add(point);
  27. }
  28. path.add(view.bounds.bottomRight);
  29. path.fullySelected = true;
  30. }
  31. function onFrame(event) {
  32. pathHeight += (center.y - mousePos.y - pathHeight) / 10;
  33. for (var i = 1; i < points; i++) {
  34. var sinSeed = event.count + (i + i % 10) * 100;
  35. var sinHeight = Math.sin(sinSeed / 200) * pathHeight;
  36. var yPos = Math.sin(sinSeed / 100) * sinHeight + height;
  37. path.segments[i].point.y = yPos;
  38. }
  39. if (smooth)
  40. path.smooth({ type: 'continuous' });
  41. }
  42. function onMouseMove(event) {
  43. mousePos = event.point;
  44. }
  45. function onMouseDown(event) {
  46. smooth = !smooth;
  47. if (!smooth) {
  48. // If smooth has been turned off, we need to reset
  49. // the handles of the path:
  50. for (var i = 0, l = path.segments.length; i < l; i++) {
  51. var segment = path.segments[i];
  52. segment.handleIn = segment.handleOut = null;
  53. }
  54. }
  55. }
  56. // Reposition the path whenever the window is resized:
  57. function onResize(event) {
  58. initializePath();
  59. }
  60. </script>
  61. </head>
  62. <body>
  63. <canvas id="canvas" resize></canvas>
  64. </body>
  65. </html>