2011-02-21 14:31:26 +01:00
|
|
|
<!DOCTYPE html>
|
2011-02-14 22:43:14 +01:00
|
|
|
<html>
|
|
|
|
<head>
|
2013-06-02 13:41:10 -07:00
|
|
|
<meta charset="UTF-8">
|
2011-06-30 09:57:17 -04:00
|
|
|
<title>Rounded Rectangles</title>
|
2011-05-05 16:25:17 +01:00
|
|
|
<link rel="stylesheet" href="../css/style.css">
|
2014-04-06 13:44:19 +02:00
|
|
|
<script type="text/javascript" src="../../dist/paper-full.js"></script>
|
2011-03-04 12:38:38 +01:00
|
|
|
<script type="text/paperscript" canvas="canvas">
|
2011-05-16 12:51:20 +01:00
|
|
|
var mousePoint = view.center;
|
2011-03-04 12:38:38 +01:00
|
|
|
var amount = 25;
|
|
|
|
var colors = ['red', 'white', 'blue', 'white'];
|
2011-04-18 17:48:48 +02:00
|
|
|
|
2011-03-04 12:38:38 +01:00
|
|
|
for (var i = 0; i < amount; i++) {
|
|
|
|
var rect = new Rectangle([0, 0], [25, 25]);
|
|
|
|
rect.center = mousePoint;
|
2013-04-19 12:36:49 -07:00
|
|
|
var path = new Path.Rectangle(rect, 6);
|
2011-03-04 12:38:38 +01:00
|
|
|
path.fillColor = colors[i % 4];
|
|
|
|
var scale = (1 - i / amount) * 20;
|
|
|
|
path.scale(scale);
|
|
|
|
}
|
2011-04-18 17:48:48 +02:00
|
|
|
|
2011-06-21 20:10:23 +02:00
|
|
|
function onMouseMove(event) {
|
2011-03-04 12:44:02 +01:00
|
|
|
mousePoint = event.point;
|
|
|
|
}
|
2011-04-18 17:48:48 +02:00
|
|
|
|
2011-05-16 13:33:15 +01:00
|
|
|
var children = project.activeLayer.children;
|
2011-05-15 18:12:56 +01:00
|
|
|
function onFrame(event) {
|
2011-03-04 12:38:38 +01:00
|
|
|
for (var i = 0, l = children.length; i < l; i++) {
|
|
|
|
var item = children[i];
|
2011-04-18 17:48:48 +02:00
|
|
|
var delta = (mousePoint - item.position) / (i + 5);
|
2011-05-15 18:12:56 +01:00
|
|
|
item.rotate(Math.sin((event.count + i) / 10) * 7);
|
2011-03-04 12:38:38 +01:00
|
|
|
if (delta.length > 0.1)
|
2011-06-21 20:10:23 +02:00
|
|
|
item.position += delta;
|
2011-02-14 22:43:14 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
</head>
|
|
|
|
<body>
|
2013-11-06 15:32:08 +01:00
|
|
|
<canvas id="canvas" resize hidpi="off"></canvas>
|
2011-05-31 00:27:39 +02:00
|
|
|
</body>
|
2014-04-06 13:44:19 +02:00
|
|
|
</html>
|