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.

44 lines
1.2 KiB

2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Multi Lines</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. tool.fixedDistance = 30;
  10. var values = {
  11. lines: 5,
  12. size: 40,
  13. smooth: true
  14. };
  15. var paths;
  16. function onMouseDown(event) {
  17. paths = [];
  18. for (var i = 0; i < values.lines; i++) {
  19. var path = new Path();
  20. path.strokeColor = '#000000';
  21. paths.push(path);
  22. }
  23. }
  24. function onMouseDrag(event) {
  25. var offset = event.delta;
  26. offset.angle = offset.angle + 90;
  27. var lineSize = values.size / values.lines;
  28. for (var i = 0; i < values.lines; i++) {
  29. var path = paths[values.lines - 1 - i];
  30. offset.length = lineSize * i + lineSize / 2;
  31. path.add(event.middlePoint + offset);
  32. path.smooth();
  33. }
  34. }
  35. </script>
  36. </head>
  37. <body>
  38. <canvas id="canvas" resize></canvas>
  39. </body>
  40. </html>