Last change
on this file since 28914 was 28914, checked in by ak19, 10 years ago |
Supporting javascript libraries and bespoke code written by Steffan to support the von-sparql user interface
|
File size:
1.7 KB
|
Line | |
---|
1 | <!DOCTYPE html>
|
---|
2 | <html>
|
---|
3 | <head>
|
---|
4 | <meta charset="UTF-8">
|
---|
5 | <title>Dripping Brush</title>
|
---|
6 | <link rel="stylesheet" href="../css/style.css">
|
---|
7 | <script type="text/javascript" src="../../dist/paper.js"></script>
|
---|
8 | <script type="text/paperscript" canvas="canvas">
|
---|
9 | var path;
|
---|
10 | var minSize = 5;
|
---|
11 | tool.maxDistance = 20;
|
---|
12 | function onMouseDrag(event) {
|
---|
13 | // If the user dragged more then minSize:
|
---|
14 | if (event.delta.length > minSize) {
|
---|
15 | // If there is no path, make one:
|
---|
16 | if (!path) {
|
---|
17 | path = new Path({
|
---|
18 | fillColor: 'black'
|
---|
19 | });
|
---|
20 | path.add(event.lastPoint);
|
---|
21 | }
|
---|
22 |
|
---|
23 | var step = event.delta / 2;
|
---|
24 | step.angle = step.angle + 90;
|
---|
25 |
|
---|
26 | // The top point: the middle point + the step rotated by 90 degrees:
|
---|
27 | // -----*
|
---|
28 | // |
|
---|
29 | // ------
|
---|
30 | var top = event.middlePoint + step;
|
---|
31 |
|
---|
32 | // The bottom point: the middle point - the step rotated by 90 degrees:
|
---|
33 | // ------
|
---|
34 | // |
|
---|
35 | // -----*
|
---|
36 | var bottom = event.middlePoint - step;
|
---|
37 |
|
---|
38 | path.add(top);
|
---|
39 | path.insert(0, bottom);
|
---|
40 | path.smooth();
|
---|
41 | } else {
|
---|
42 | // If the user dragged too slowly:
|
---|
43 |
|
---|
44 | // If there is currently a path, close it
|
---|
45 | if (path) {
|
---|
46 | path.add(event.point);
|
---|
47 | path.closed = true;
|
---|
48 | path.smooth();
|
---|
49 |
|
---|
50 | // Set path to null (nothing) so the path check above
|
---|
51 | // will force a new path next time the user drags fast enough:
|
---|
52 | path = null;
|
---|
53 | }
|
---|
54 | }
|
---|
55 | }
|
---|
56 |
|
---|
57 | function onMouseUp(event) {
|
---|
58 | if (path) {
|
---|
59 | path.add(event.point);
|
---|
60 | path.closed = true;
|
---|
61 | path.smooth();
|
---|
62 |
|
---|
63 | // Set path to null (nothing) so the path check above
|
---|
64 | // will force a new path next time the user drags fast enough:
|
---|
65 | path = null;
|
---|
66 | }
|
---|
67 | }
|
---|
68 | </script>
|
---|
69 | </head>
|
---|
70 | <body>
|
---|
71 | <canvas id="canvas" resize></canvas>
|
---|
72 | </body>
|
---|
73 | </html> |
---|
Note:
See
TracBrowser
for help on using the repository browser.