Convert MultiLines examples to PaperScript.

This commit is contained in:
Jürg Lehni 2011-03-04 01:05:41 +00:00
parent be0d260cb4
commit 7bc56d4c39

View file

@ -4,6 +4,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Example</title> <title>Example</title>
<script type="text/javascript" src="../../lib/bootstrap.js"></script> <script type="text/javascript" src="../../lib/bootstrap.js"></script>
<script type="text/javascript" src="../../lib/parse-js.js"></script>
<script type="text/javascript" src="../../src/Paper.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/ToolEvent.js"></script>
<script type="text/javascript" src="../../src/tool/ToolHandler.js"></script> <script type="text/javascript" src="../../src/tool/ToolHandler.js"></script>
@ -32,41 +33,37 @@
<script type="text/javascript" src="../../src/color/GradientColor.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/Gradient.js"></script>
<script type="text/javascript" src="../../src/color/GradientStop.js"></script> <script type="text/javascript" src="../../src/color/GradientStop.js"></script>
<script> <script type="text/javascript" src="../../src/util/PaperScript.js"></script>
window.onload = function() { <script type="text/paperscript" canvas="canvas">
var canvas = document.getElementById('canvas'); tool.fixedDistance = 30;
var doc = new Document(canvas);
var values = {
lines: 5,
size: 40,
smooth: true
};
var paths; var values = {
var tool = new Tool({ lines: 5,
onMouseDown: function(event) { size: 40,
paths = []; smooth: true
for (var i = 0; i < values.lines; i++) { };
var path = new Path();
path.strokeColor = '#000000';
paths.push(path);
}
},
onMouseDrag: function(event) { var paths;
var offset = event.delta;
offset.angle = offset.angle + 90; function onMouseDown(event) {
var lineSize = values.size / values.lines; paths = [];
for (var i = 0; i < values.lines; i++) { for (var i = 0; i < values.lines; i++) {
var path = paths[values.lines - 1 - i]; var path = new Path();
offset.length = lineSize * i + lineSize / 2; path.strokeColor = '#000000';
path.add(event.middlePoint.add(offset)); paths.push(path);
path.smooth(); }
} }
}
}); function onMouseDrag(event) {
tool.fixedDistance = 30; 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 + offset);
path.smooth();
}
} }
</script> </script>
</head> </head>