1 | <!DOCTYPE html>
|
---|
2 | <html>
|
---|
3 | <head>
|
---|
4 | <meta charset="UTF-8">
|
---|
5 | <title>Stroke Bounds</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 paths = [];
|
---|
10 |
|
---|
11 | function makePath() {
|
---|
12 | var path = new Path();
|
---|
13 | path.moveTo(200, 50);
|
---|
14 | path.lineTo(230, 100);
|
---|
15 | path.lineTo(250, 50);
|
---|
16 | path.lineTo(280, 110);
|
---|
17 | path.arcTo([250, 20], false);
|
---|
18 | path.rotate(-5);
|
---|
19 | path.strokeWidth = 30;
|
---|
20 | path.miterLimit = 3;
|
---|
21 | paths.push(path);
|
---|
22 | return path;
|
---|
23 | }
|
---|
24 |
|
---|
25 | var path = makePath();
|
---|
26 | path.strokeColor = 'black';
|
---|
27 | path.strokeCap = 'butt';
|
---|
28 | path.strokeJoin = 'round';
|
---|
29 |
|
---|
30 | var path = makePath().translate(150, 0);
|
---|
31 | path.strokeColor = 'black';
|
---|
32 | path.strokeCap = 'butt';
|
---|
33 | path.strokeJoin = 'bevel';
|
---|
34 |
|
---|
35 | var path = makePath().translate(300, 0);
|
---|
36 | path.strokeColor = 'black';
|
---|
37 | path.strokeCap = 'butt';
|
---|
38 | path.strokeJoin = 'miter';
|
---|
39 |
|
---|
40 | var path = makePath().translate(0, 150);
|
---|
41 | path.strokeColor = 'black';
|
---|
42 | path.strokeCap = 'square';
|
---|
43 | path.strokeJoin = 'round';
|
---|
44 |
|
---|
45 | var path = makePath().translate(150, 150);
|
---|
46 | path.strokeColor = 'black';
|
---|
47 | path.strokeCap = 'square';
|
---|
48 | path.strokeJoin = 'bevel';
|
---|
49 |
|
---|
50 | var path = makePath().translate(300, 150);
|
---|
51 | path.strokeColor = 'black';
|
---|
52 | path.strokeCap = 'square';
|
---|
53 | path.strokeJoin = 'miter';
|
---|
54 |
|
---|
55 | var path = makePath().translate(0, 300);
|
---|
56 | path.strokeColor = 'black';
|
---|
57 | path.strokeCap = 'round';
|
---|
58 | path.strokeJoin = 'round';
|
---|
59 |
|
---|
60 | var path = makePath().translate(150, 300);
|
---|
61 | path.strokeColor = 'black';
|
---|
62 | path.strokeCap = 'round';
|
---|
63 | path.strokeJoin = 'bevel';
|
---|
64 |
|
---|
65 | var path = makePath().translate(300, 300);
|
---|
66 | path.strokeColor = 'black';
|
---|
67 | path.strokeCap = 'round';
|
---|
68 | path.strokeJoin = 'miter';
|
---|
69 |
|
---|
70 | for (var i = 0; i < paths.length; i++) {
|
---|
71 | var path = paths[i];
|
---|
72 | path.fullySelected = true;
|
---|
73 | path.scale(1.5, new Point(300, 0));
|
---|
74 | var rect = new Path.Rectangle(path.strokeBounds);
|
---|
75 | rect.strokeWidth = 0.25;
|
---|
76 | rect.strokeColor = 'black';
|
---|
77 | rect.fillColor = null;
|
---|
78 | var rect = new Path.Rectangle(path.bounds);
|
---|
79 | rect.strokeWidth = 0.25;
|
---|
80 | rect.strokeColor = 'red';
|
---|
81 | rect.fillColor = null;
|
---|
82 | var rect = new Path.Rectangle(path.controlBounds);
|
---|
83 | rect.strokeWidth = 0.25;
|
---|
84 | rect.strokeColor = 'green';
|
---|
85 | rect.fillColor = null;
|
---|
86 |
|
---|
87 | path.onMouseEnter = function() {
|
---|
88 | this.strokeColor = 'red';
|
---|
89 | }
|
---|
90 | path.onMouseLeave = function() {
|
---|
91 | this.strokeColor = 'black';
|
---|
92 | }
|
---|
93 | }
|
---|
94 |
|
---|
95 | project.activeLayer.position = view.center;
|
---|
96 | </script>
|
---|
97 | </head>
|
---|
98 | <body>
|
---|
99 | <canvas id="canvas" resize></canvas>
|
---|
100 | </body>
|
---|
101 | </html> |
---|