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,10 +33,9 @@
<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 = { var values = {
lines: 5, lines: 5,
@ -44,30 +44,27 @@
}; };
var paths; var paths;
var tool = new Tool({
onMouseDown: function(event) { function onMouseDown(event) {
paths = []; paths = [];
for (var i = 0; i < values.lines; i++) { for (var i = 0; i < values.lines; i++) {
var path = new Path(); var path = new Path();
path.strokeColor = '#000000'; path.strokeColor = '#000000';
paths.push(path); paths.push(path);
} }
}, }
onMouseDrag: function(event) { function onMouseDrag(event) {
var offset = event.delta; var offset = event.delta;
offset.angle = offset.angle + 90; offset.angle = offset.angle + 90;
var lineSize = values.size / values.lines; var lineSize = values.size / values.lines;
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 = paths[values.lines - 1 - i];
offset.length = lineSize * i + lineSize / 2; offset.length = lineSize * i + lineSize / 2;
path.add(event.middlePoint.add(offset)); path.add(event.middlePoint + offset);
path.smooth(); path.smooth();
} }
} }
});
tool.fixedDistance = 30;
}
</script> </script>
</head> </head>
<body> <body>