mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-01 02:38:43 -05:00
75 lines
No EOL
3.2 KiB
HTML
75 lines
No EOL
3.2 KiB
HTML
<!DOCTYPE html>
|
|
<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/Doc.js"></script>
|
|
<script type="text/javascript" src="../../src/document/Symbol.js"></script>
|
|
<script type="text/javascript" src="../../src/item/Item.js"></script>
|
|
<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>
|
|
<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>
|
|
<script type="text/javascript" src="../../src/path/CompoundPath.js"></script>
|
|
<script type="text/javascript" src="../../src/path/Path.Constructors.js"></script>
|
|
<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>
|
|
<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>
|
|
<script>
|
|
window.onload = function() {
|
|
var canvas = document.getElementById('canvas');
|
|
var doc = new Doc(canvas);
|
|
|
|
var values = {
|
|
lines: 5,
|
|
size: 40,
|
|
smooth: true
|
|
};
|
|
|
|
var paths;
|
|
var tool = new Tool({
|
|
onMouseDown: function(event) {
|
|
paths = [];
|
|
for (var i = 0; i < values.lines; i++) {
|
|
var path = new Path();
|
|
path.strokeColor = '#000000';
|
|
paths.push(path);
|
|
}
|
|
},
|
|
|
|
onMouseDrag: function(event) {
|
|
var offset = event.delta;
|
|
offset.angle = offset.angle + 90;
|
|
var lineSize = values.size / values.lines;
|
|
for (var i = 0; i < values.lines; i++) {
|
|
var path = paths[values.lines - 1 - i];
|
|
offset.length = lineSize * i + lineSize / 2;
|
|
path.add(event.middlePoint.add(offset));
|
|
path.smooth();
|
|
}
|
|
}
|
|
});
|
|
tool.fixedDistance = 30;
|
|
}
|
|
</script>
|
|
</head>
|
|
<body>
|
|
<canvas id='canvas' width=1024 height=768></canvas>
|
|
</body> |