paper.js/examples/Animated/RoundedRectangles.html

77 lines
3.2 KiB
HTML
Raw Normal View History

<!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>
<script>
window.onload = function() {
var canvas = document.getElementById('canvas');
2011-02-20 17:28:38 -05:00
var doc = new Doc(canvas);
var mousePoint = new Point(doc.size.divide(2));
var amount = 25;
var colors = ['red', 'white', 'blue', 'white'];
2011-02-17 10:00:03 -05:00
for (var i = 0; i < amount; i++) {
var rect = new Rectangle([0, 0], [25, 25]);
rect.center = mousePoint;
var path = new Path.RoundRectangle(rect, 6);
path.fillColor = colors[i % 4];
var scale = (1 - i / amount) * 20;
2011-02-20 17:28:38 -05:00
path.scale(scale);
new PlacedSymbol(path);
}
setInterval(draw, 30);
var tool = new Tool({
onMouseDrag: function(event) {
mousePoint = event.point;
}
2011-02-20 17:28:38 -05:00
});
var children = Paper.document.activeLayer.children;
var count = 0;
function draw() {
count++;
for (var i = 0, l = children.length; i < l; i++) {
var item = children[i];
var delta = mousePoint.subtract(item.position).divide(i + 1);
item.rotate(Math.sin((count + i) / 10) * 7);
2011-02-20 21:32:39 -05:00
if (delta.length > 0.1)
2011-02-20 17:28:38 -05:00
item.translate(delta);
}
doc.redraw();
}
}
</script>
</head>
<body>
<canvas id='canvas' width=1024 height=768></canvas>
</body>