2011-02-21 08:31:26 -05:00
|
|
|
<!DOCTYPE html>
|
2011-02-07 13:28:09 -05:00
|
|
|
<html>
|
|
|
|
<head>
|
2013-06-02 16:41:10 -04:00
|
|
|
<meta charset="UTF-8">
|
2011-06-30 09:57:17 -04:00
|
|
|
<title>Animated Star</title>
|
2011-05-05 11:25:17 -04:00
|
|
|
<link rel="stylesheet" href="../css/style.css">
|
2014-04-06 07:44:19 -04:00
|
|
|
<script type="text/javascript" src="../../dist/paper-full.js"></script>
|
2011-03-04 06:38:38 -05:00
|
|
|
<script type="text/paperscript" canvas="canvas">
|
2011-05-16 08:33:15 -04:00
|
|
|
var layer = project.activeLayer;
|
2011-05-16 07:51:20 -04:00
|
|
|
|
2011-03-04 06:38:38 -05:00
|
|
|
var values = {
|
|
|
|
count: 34,
|
|
|
|
points: 32
|
2011-05-05 13:40:10 -04:00
|
|
|
};
|
2011-05-16 08:42:23 -04:00
|
|
|
|
2011-03-04 06:38:38 -05:00
|
|
|
for (var i = 0; i < values.count; i++) {
|
2013-03-02 10:02:29 -05:00
|
|
|
var path = new Path({
|
|
|
|
fillColor: i % 2 ? 'red' : 'black',
|
|
|
|
closed: true
|
|
|
|
});
|
2011-05-16 08:42:23 -04:00
|
|
|
|
2013-03-02 10:02:29 -05:00
|
|
|
var offset = new Point(20 + 10 * i, 0);
|
2011-03-04 06:38:38 -05:00
|
|
|
var l = offset.length;
|
|
|
|
for (var j = 0; j < values.points * 2; j++) {
|
|
|
|
offset.angle += 360 / values.points;
|
2011-05-05 19:19:24 -04:00
|
|
|
var vector = offset.normalize(l * (j % 2 ? 0.1 : -0.1));
|
2011-03-04 06:38:38 -05:00
|
|
|
path.add(offset + vector);
|
2011-02-20 17:28:38 -05:00
|
|
|
}
|
2011-03-04 06:38:38 -05:00
|
|
|
path.smooth();
|
2013-11-04 05:43:27 -05:00
|
|
|
layer.insertChild(0, new Group({
|
|
|
|
children: [path],
|
2014-03-02 10:04:17 -05:00
|
|
|
applyMatrix: false
|
2013-11-04 05:43:27 -05:00
|
|
|
}));
|
2011-03-04 06:38:38 -05:00
|
|
|
}
|
2011-07-07 10:09:02 -04:00
|
|
|
|
2011-05-15 13:12:56 -04:00
|
|
|
function onFrame(event) {
|
2013-03-02 10:02:29 -05:00
|
|
|
for (var i = 0; i < values.count; i++) {
|
2011-03-04 06:38:38 -05:00
|
|
|
var item = layer.children[i];
|
2011-05-15 13:12:56 -04:00
|
|
|
var angle = (values.count - i) * Math.sin(event.count / 128) / 10;
|
2011-03-04 06:38:38 -05:00
|
|
|
item.rotate(angle);
|
2011-02-07 13:28:09 -05:00
|
|
|
}
|
|
|
|
}
|
2011-05-16 08:42:23 -04:00
|
|
|
|
2011-05-05 13:40:10 -04:00
|
|
|
// Reposition the paths whenever the window is resized:
|
2011-05-15 20:30:09 -04:00
|
|
|
function onResize(event) {
|
2011-05-18 16:32:34 -04:00
|
|
|
layer.position = view.center;
|
2011-05-15 20:30:09 -04:00
|
|
|
}
|
2011-02-07 13:28:09 -05:00
|
|
|
</script>
|
|
|
|
</head>
|
|
|
|
<body>
|
2013-11-06 09:32:08 -05:00
|
|
|
<canvas id="canvas" resize stats hidpi="off"></canvas>
|
2011-05-30 18:27:39 -04:00
|
|
|
</body>
|
2014-04-06 07:44:19 -04:00
|
|
|
</html>
|