paper.js/examples/Tools/MultipleTools.html
Jürg Lehni e0a0cd58d5 PaperScript: Improve tool detection code.
And implement Multiple Tools example.
2016-04-13 15:21:35 -07:00

44 lines
1.2 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Mulitple Tools</title>
<link rel="stylesheet" href="../css/style.css">
<script type="text/javascript" src="../../dist/paper-full.js"></script>
<script type="text/paperscript" canvas="canvas">
// Create two drawing tools.
// tool1 will draw straight lines, tool2 will draw clouds.
// Both share the mouseDown event:
var path;
function onMouseDown(event) {
path = new Path();
path.strokeColor = 'black';
path.add(event.point);
}
window.app = {
tool1: new Tool({
onMouseDown: onMouseDown,
onMouseDrag: function(event) {
path.add(event.point);
}
}),
tool2: new Tool({
minDistance: 20,
onMouseDown: onMouseDown,
onMouseDrag: function(event) {
// Use the arcTo command to draw cloudy lines
path.arcTo(event.point);
}
})
};
</script>
</head>
<body>
<a href="#" onclick="app.tool1.activate(); return false;">Lines</a>
<a href="#" onclick="app.tool2.activate(); return false;">Clouds</a>
<canvas id="canvas" resize></canvas>
</body>
</html>