paper.js/examples/Scripts/lines.html

30 lines
928 B
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>
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-02-07 13:28:09 -05:00
var count = 0;
2011-03-04 06:38:38 -05:00
setInterval(draw, 20);
2011-02-07 13:28:09 -05:00
function draw() {
count++;
2011-03-04 06:38:38 -05:00
document.activeLayer.children = [];
var point = new Point(document.size) / 2;
2011-02-07 13:28:09 -05:00
var vector = new Point(100, 0);
for (var i = 0; i < 180; i++) {
2011-03-04 06:38:38 -05:00
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);
2011-02-07 13:28:09 -05:00
path.strokeColor = i % 4 ? 'black' : 'red';
}
2011-03-04 06:38:38 -05:00
document.redraw();
2011-02-07 13:28:09 -05:00
}
</script>
</head>
<body>
<canvas id='canvas' width=1024 height=768></canvas>
</body>