paper.js/examples/Tools/Grid.html
2011-02-17 15:56:07 +01:00

59 lines
No EOL
2.2 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/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>
<script type="text/javascript" src="../../src/item/Item.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>
<script>
window.onload = function() {
var values = { size: 10 };
var point, path;
function getPos(pt) {
return (pt.divide(values.size)).round().multiply(values.size);
}
var canvas = document.getElementById('canvas');
var doc = new Doc(canvas);
var point, path;
var tool = new Tool({
onMouseDown: function(event) {
point = getPos(event.point);
path = new Path();
path.strokeColor = 'black';
path.add(point);
},
onMouseDrag: function(event) {
var p = getPos(event.point);
if (!point.equals(p)) {
path.add(p);
point = p;
}
}
});
}
</script>
</head>
<body>
<canvas id='canvas' width=1024 height=768></canvas>
</body>