paper.js/examples/Scripts/lines.html

30 lines
No EOL
932 B
HTML

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Example</title>
<script type="text/javascript">var loadBase = '../../'</script>
<script type="text/javascript" src="../../src/load.js"></script>
<script type="text/paperscript" canvas="canvas">
var count = 0;
setInterval(draw, 20);
function draw() {
count++;
document.activeLayer.children = [];
var point = new Point(document.size) / 2;
var vector = new Point(100, 0);
for (var i = 0; i < 180; i++) {
var center = point + vector.rotate(i * 2).normalize(30);
var length = 30 + Math.abs(Math.sin((i + count / 20)) * 300);
var end = point + vector.rotate(i * 2).normalize(length);
var path = new Path.Line(center, end);
path.strokeColor = i % 4 ? 'black' : 'red';
}
document.redraw();
}
</script>
</head>
<body>
<canvas id='canvas' width=1024 height=768></canvas>
</body>