paper.js/examples/Animated/Lines.html

51 lines
1.3 KiB
HTML
Raw Normal View History

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>
<link rel="stylesheet" href="../css/style.css">
2011-03-07 20:07:26 -05:00
<script type="text/javascript">var root = '../../'</script>
<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;
}
var position = view.center;
var mousePos = position;
var children = project.activeLayer.children;
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'>
<canvas id="canvas" resize keepalive="true"></canvas>
2011-02-07 13:28:09 -05:00
</body>