Web Interface For Lite Argus Control modules
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.

73 lines
2.3 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Dripping Brush</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 path;
  10. var minSize = 5;
  11. tool.maxDistance = 20;
  12. function onMouseDrag(event) {
  13. // If the user dragged more then minSize:
  14. if (event.delta.length > minSize) {
  15. // If there is no path, make one:
  16. if (!path) {
  17. path = new Path({
  18. fillColor: 'black'
  19. });
  20. path.add(event.lastPoint);
  21. }
  22. var step = event.delta / 2;
  23. step.angle = step.angle + 90;
  24. // The top point: the middle point + the step rotated by 90 degrees:
  25. // -----*
  26. // |
  27. // ------
  28. var top = event.middlePoint + step;
  29. // The bottom point: the middle point - the step rotated by 90 degrees:
  30. // ------
  31. // |
  32. // -----*
  33. var bottom = event.middlePoint - step;
  34. path.add(top);
  35. path.insert(0, bottom);
  36. path.smooth();
  37. } else {
  38. // If the user dragged too slowly:
  39. // If there is currently a path, close it
  40. if (path) {
  41. path.add(event.point);
  42. path.closed = true;
  43. path.smooth();
  44. // Set path to null (nothing) so the path check above
  45. // will force a new path next time the user drags fast enough:
  46. path = null;
  47. }
  48. }
  49. }
  50. function onMouseUp(event) {
  51. if (path) {
  52. path.add(event.point);
  53. path.closed = true;
  54. path.smooth();
  55. // Set path to null (nothing) so the path check above
  56. // will force a new path next time the user drags fast enough:
  57. path = null;
  58. }
  59. }
  60. </script>
  61. </head>
  62. <body>
  63. <canvas id="canvas" resize></canvas>
  64. </body>
  65. </html>