paper.js/examples/Tools/Grid.html

69 lines
3 KiB
HTML
Raw Normal View History

2011-02-21 08:31:26 -05:00
<!DOCTYPE html>
2011-02-08 19:10:55 -05:00
<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/DocumentView.js"></script>
<script type="text/javascript" src="../../src/document/Document.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>
2011-03-02 20:25:45 -05:00
<script type="text/javascript" src="../../src/item/Raster.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>
2011-03-02 20:25:45 -05:00
<script type="text/javascript" src="../../src/path/CompoundPath.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>
2011-02-08 19:10:55 -05:00
<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 Document(canvas);
2011-02-08 19:10:55 -05:00
var point, path;
var tool = new Tool({
onMouseDown: function(event) {
point = getPos(event.point);
2011-02-08 19:10:55 -05:00
path = new Path();
path.strokeColor = 'black';
path.add(point);
},
onMouseDrag: function(event) {
var p = getPos(event.point);
2011-02-08 19:10:55 -05:00
if (!point.equals(p)) {
path.add(p);
point = p;
}
}
});
}
</script>
</head>
<body>
<canvas id='canvas' width=1024 height=768></canvas>
</body>