paper.js/examples/Scripts/star.html
2011-03-08 01:07:26 +00:00

28 lines
No EOL
893 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 root = '../../'</script>
<script type="text/javascript" src="../../src/load.js"></script>
<script type="text/paperscript" canvas="canvas">
var point = new Point(document.size) / 2;
for (var i = 0; i < 30; i++) {
var vector = new Point(1 + 10 * i, 0).rotate(i);
var l = vector.length;
var path = new Path();
path.fillColor = i % 2 ? 'red' : 'black';
path.closed = true;
for (var j = 0; j < 32; j++) {
vector = vector.rotate(45 / 4);
var newPoint = point + vector + vector.rotate(-180).normalize(l * (j % 2 ? 0.1 : -0.1));
path.add(newPoint);
}
path.smooth();
document.activeLayer.appendBottom(path);
}
</script>
</head>
<body>
<canvas id='canvas' width=1024 height=768></canvas>
</body>