2011-02-21 08:31:26 -05:00
|
|
|
<!DOCTYPE html>
|
2011-02-07 13:28:09 -05:00
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|
|
|
<title>Example</title>
|
2011-05-05 11:25:17 -04:00
|
|
|
<link rel="stylesheet" href="../css/style.css">
|
2011-03-07 20:07:26 -05:00
|
|
|
<script type="text/javascript">var root = '../../'</script>
|
2011-03-07 18:11:41 -05:00
|
|
|
<script type="text/javascript" src="../../src/load.js"></script>
|
2011-03-04 06:38:38 -05:00
|
|
|
<script type="text/paperscript" canvas="canvas">
|
2011-03-12 09:17:08 -05:00
|
|
|
var amount = 180;
|
2011-05-03 03:54:13 -04:00
|
|
|
for (var i = 0; i < amount; i++) {
|
2011-03-12 09:17:08 -05:00
|
|
|
var path = new Path();
|
|
|
|
path.fillColor = new HSBColor(1, 1, Math.random());
|
|
|
|
path.strokeCap = 'round';
|
|
|
|
path.closed = true;
|
|
|
|
}
|
|
|
|
|
2011-05-16 07:51:20 -04:00
|
|
|
var position = view.center;
|
2011-05-15 06:36:10 -04:00
|
|
|
var mousePos = position;
|
2011-05-16 08:33:15 -04:00
|
|
|
var children = project.activeLayer.children;
|
2011-05-15 06:36:10 -04:00
|
|
|
var count = 0;
|
2011-02-07 13:28:09 -05:00
|
|
|
|
2011-03-12 09:17:08 -05:00
|
|
|
function iterate() {
|
2011-02-07 13:28:09 -05:00
|
|
|
count++;
|
2011-03-12 09:17:08 -05:00
|
|
|
var delta = (mousePos - position);
|
|
|
|
position += delta / 10;
|
|
|
|
for (var i = 1; i < amount; i++) {
|
2011-03-12 09:28:01 -05:00
|
|
|
var path = children[i];
|
2011-03-12 09:17:08 -05:00
|
|
|
var length = Math.abs(Math.sin(i + count / 20) * 300);
|
2011-03-12 09:28:01 -05:00
|
|
|
path.segments = [
|
2011-03-12 09:17:08 -05:00
|
|
|
position + delta / 1.5,
|
|
|
|
position + { angle: i * 2, length: length },
|
|
|
|
position + { angle: (i + 1) * 2, length: length }
|
|
|
|
];
|
2011-03-12 09:28:01 -05:00
|
|
|
path.fillColor.hue = count - length;
|
2011-02-07 13:28:09 -05:00
|
|
|
}
|
2011-03-12 09:17:08 -05:00
|
|
|
}
|
|
|
|
|
2011-04-26 09:51:56 -04:00
|
|
|
function onFrame() {
|
2011-03-12 09:17:08 -05:00
|
|
|
iterate();
|
|
|
|
}
|
|
|
|
|
|
|
|
function onMouseMove(event) {
|
|
|
|
iterate();
|
|
|
|
mousePos = event.point;
|
2011-02-07 13:28:09 -05:00
|
|
|
}
|
|
|
|
</script>
|
|
|
|
</head>
|
2011-03-12 09:17:08 -05:00
|
|
|
<body style='background-color:black'>
|
2011-05-14 06:04:02 -04:00
|
|
|
<canvas id="canvas" resize keepalive="true"></canvas>
|
2011-02-07 13:28:09 -05:00
|
|
|
</body>
|