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.

41 lines
1.3 KiB

2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Rounded Rectangles</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 mousePoint = view.center;
  10. var amount = 25;
  11. var colors = ['red', 'white', 'blue', 'white'];
  12. for (var i = 0; i < amount; i++) {
  13. var rect = new Rectangle([0, 0], [25, 25]);
  14. rect.center = mousePoint;
  15. var path = new Path.Rectangle(rect, 6);
  16. path.fillColor = colors[i % 4];
  17. var scale = (1 - i / amount) * 20;
  18. path.scale(scale);
  19. }
  20. function onMouseMove(event) {
  21. mousePoint = event.point;
  22. }
  23. var children = project.activeLayer.children;
  24. function onFrame(event) {
  25. for (var i = 0, l = children.length; i < l; i++) {
  26. var item = children[i];
  27. var delta = (mousePoint - item.position) / (i + 5);
  28. item.rotate(Math.sin((event.count + i) / 10) * 7);
  29. if (delta.length > 0.1)
  30. item.position += delta;
  31. }
  32. }
  33. </script>
  34. </head>
  35. <body>
  36. <canvas id="canvas" resize hidpi="off"></canvas>
  37. </body>
  38. </html>