paper.js/examples/Animated/Lines.html

54 lines
1.6 KiB
HTML
Raw Permalink Normal View History

2011-02-21 08:31:26 -05:00
<!DOCTYPE html>
2011-02-07 13:28:09 -05:00
<html>
<head>
2014-08-16 13:24:54 -04:00
<meta charset="UTF-8">
<title>Lines</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 amount = 45;
for (var i = 0; i < amount; i++) {
var path = new Path({
fillColor: {
hue: 1,
saturation: 1,
brightness: Math.random()
},
closed: true
});
}
2011-03-12 09:17:08 -05:00
2014-08-16 13:24:54 -04:00
var position = view.center;
var mousePos = view.center;
var children = project.activeLayer.children;
2011-05-16 08:42:23 -04:00
2014-08-16 13:24:54 -04:00
function iterate(count) {
var delta = mousePos - position;
position += delta / 10;
for (var i = 1; i < amount; i++) {
var path = children[i];
var length = Math.abs(Math.sin(i + count / 40) * 300);
path.segments = [
position + delta / 1.5,
position + { angle: i / amount * 360, length: length },
position + { angle: (i + 1) / amount * 360, length: length }
];
path.fillColor.hue = count - length;
}
}
2011-05-16 08:42:23 -04:00
2014-08-16 13:24:54 -04:00
function onFrame(event) {
iterate(event.count);
}
2011-05-16 08:42:23 -04:00
2014-08-16 13:24:54 -04:00
function onMouseMove(event) {
iterate();
mousePos = event.point;
}
</script>
2011-02-07 13:28:09 -05:00
</head>
<body style="background:black">
2014-08-16 13:24:54 -04:00
<canvas id="canvas" resize></canvas>
2011-05-30 18:27:39 -04:00
</body>
</html>