paper.js/examples/Tools/Wave.html
2011-02-12 17:59:39 +01:00

59 lines
No EOL
2.1 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="../../lib/Bootstrap.js"></script>
<script type="text/javascript" src="../../src/Paper.js"></script>
<script type="text/javascript" src="../../src/item/Item.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/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/document/Doc.js"></script>
<script type="text/javascript" src="../../src/item/Layer.js"></script>
<script type="text/javascript" src="../../src/item/Group.js"></script>
<script type="text/javascript" src="../../src/ToolEvent.js"></script>
<script type="text/javascript" src="../../src/ToolHandler.js"></script>
<script type="text/javascript" src="../../src/Tool.js"></script>
<script>
window.onload = function() {
var canvas = document.getElementById('canvas');
var doc = new Doc(canvas);
var values = {
curviness: 0.5,
distance: 10,
offset: 10,
mouseOffset: true
};
var path;
var mul = 1;
var tool = new Tool({
onMouseDown: function(event) {
path = new Path();
path.strokeColor = 'black';
},
onMouseDrag: function(event) {
var step = event.delta.rotate(90 * mul);
if (!values.mouseOffset)
step.length = values.offset;
var segment = new Segment(event.point.add(step));
segment.handleIn = event.delta.multiply(-values.curviness);
segment.handleOut = event.delta.multiply(values.curviness);
path.add(segment);
mul *= -1;
}
});
tool.document = doc;
tool.fixedDistance = 10;
}
</script>
</head>
<body>
<canvas id='canvas' width=1024 height=768></canvas>
</body>