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