mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-01 02:38:43 -05:00
45 lines
No EOL
1.6 KiB
HTML
45 lines
No EOL
1.6 KiB
HTML
<!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="../src/Bootstrap.js"></script>
|
|
<script type="text/javascript" src="../src/Item.js"></script>
|
|
<script type="text/javascript" src="../src/PathItem.js"></script>
|
|
<script type="text/javascript" src="../src/Point.js"></script>
|
|
<script type="text/javascript" src="../src/Rectangle.js"></script>
|
|
<script type="text/javascript" src="../src/Size.js"></script>
|
|
<script type="text/javascript" src="../src/Segment.js"></script>
|
|
<script type="text/javascript" src="../src/PathItem.js"></script>
|
|
<script type="text/javascript" src="../src/Path.js"></script>
|
|
<script type="text/javascript" src="../src/Doc.js"></script>
|
|
<script>
|
|
window.onload = function() {
|
|
var canvas = document.getElementById('canvas');
|
|
var doc = new Doc(canvas);
|
|
|
|
var point = new Point(1024, 768).divide(2);
|
|
for(var i = 0; i < 30; i++) {
|
|
var vector = new Point(1 + 10 * i, 0).rotate(i);
|
|
var l = vector.getLength();
|
|
var path = new Path();
|
|
// path.strokeColor = '#000000';
|
|
path.fillColor = i % 2 ? 'red' : 'black';
|
|
path.closed = true;
|
|
for(var j = 0; j < 32; j++) {
|
|
vector = vector.rotate(45 / 4);
|
|
var newPoint = point.add(vector).add(vector.rotate(-180).normalize(l * (j % 2 ? 0.1 : -0.1)));
|
|
path.add(newPoint);
|
|
}
|
|
path.smooth();
|
|
doc.children.push(path);
|
|
}
|
|
doc.children.reverse();
|
|
doc.draw();
|
|
}
|
|
</script>
|
|
</head>
|
|
<body>
|
|
<canvas id='canvas' width=1024 height=768></canvas>
|
|
</body> |