paper.js/examples/Animated/animatedStar.html

80 lines
3.2 KiB
HTML
Raw Normal View History

2011-02-07 13:28:09 -05:00
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Example</title>
<script type="text/javascript" src="../../lib/Bootstrap.js"></script>
<script type="text/javascript" src="../../src/Paper.js"></script>
<script type="text/javascript" src="../../src/tool/ToolEvent.js"></script>
<script type="text/javascript" src="../../src/tool/ToolHandler.js"></script>
<script type="text/javascript" src="../../src/tool/Tool.js"></script>
<script type="text/javascript" src="../../src/basic/Point.js"></script>
<script type="text/javascript" src="../../src/basic/Rectangle.js"></script>
<script type="text/javascript" src="../../src/basic/Size.js"></script>
<script type="text/javascript" src="../../src/basic/Matrix.js"></script>
<script type="text/javascript" src="../../src/document/Doc.js"></script>
2011-02-20 17:28:38 -05:00
<script type="text/javascript" src="../../src/document/Symbol.js"></script>
<script type="text/javascript" src="../../src/item/Item.js"></script>
2011-02-20 17:28:38 -05:00
<script type="text/javascript" src="../../src/item/PlacedSymbol.js"></script>
<script type="text/javascript" src="../../src/item/Group.js"></script>
<script type="text/javascript" src="../../src/item/Layer.js"></script>
<script type="text/javascript" src="../../src/item/PathStyle.js"></script>
<script type="text/javascript" src="../../src/path/Segment.js"></script>
<script type="text/javascript" src="../../src/path/PathItem.js"></script>
<script type="text/javascript" src="../../src/path/Path.js"></script>
<script type="text/javascript" src="../../src/path/Path.Constructors.js"></script>
2011-02-19 11:56:15 -05:00
<script type="text/javascript" src="../../src/color/Color.js"></script>
<script type="text/javascript" src="../../src/color/RGBColor.js"></script>
<script type="text/javascript" src="../../src/color/GrayColor.js"></script>
2011-02-20 17:28:38 -05:00
<script type="text/javascript" src="../../src/color/GradientColor.js"></script>
<script type="text/javascript" src="../../src/color/Gradient.js"></script>
<script type="text/javascript" src="../../src/color/GradientStop.js"></script>
2011-02-07 13:28:09 -05:00
<script>
window.onload = function() {
2011-02-20 17:28:38 -05:00
var canvas = document.getElementById('canvas');
var doc = new Doc(canvas);
var layer = doc.activeLayer;
var values = {
count: 34,
points: 32
}
var center = new Point(doc.size).divide(2)
for (var i = 0; i < values.count; i++) {
var offset = new Point(20 + 10 * i, 0);
2011-02-07 13:28:09 -05:00
var path = new Path();
2011-02-16 16:44:05 -05:00
path.fillColor = i % 2 ? 'red' : 'black';
2011-02-07 13:28:09 -05:00
path.closed = true;
2011-02-20 17:28:38 -05:00
var l = offset.length;
for (var j = 0; j < values.points * 2; j++) {
offset.angle += 360 / values.points;
var vector = offset.clone()
vector.length = l * (j % 2 ? 0.1 : -0.1);
path.add(offset.add(vector));
2011-02-07 13:28:09 -05:00
}
path.smooth();
2011-02-20 17:28:38 -05:00
var placedSymbol = new PlacedSymbol(path);
placedSymbol.position = center;
layer.appendBottom(placedSymbol);
}
setInterval(draw, 30);
var count = 0;
function draw() {
count++;
for (var i = 0, l = layer.children.length; i < l; i++) {
var item = layer.children[i];
var angle = (values.count - i) * Math.sin(count / 128) / 10;
item.rotate(angle);
}
doc.redraw();
2011-02-07 13:28:09 -05:00
}
}
</script>
</head>
<body>
<canvas id='canvas' width=1024 height=768></canvas>
</body>