1 | <!DOCTYPE html>
|
---|
2 | <html>
|
---|
3 | <head>
|
---|
4 | <meta charset="UTF-8">
|
---|
5 | <title>Rotated Primitives</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 | // This "arbitrary" shape triggered rectangles in the original code,
|
---|
10 | // since point2 is as far from point0 as point3 is from point1.
|
---|
11 | var path = new Path({
|
---|
12 | closed: true,
|
---|
13 | strokeColor: 'black'
|
---|
14 | });
|
---|
15 | path.moveTo(0, 0);
|
---|
16 | path.lineTo(50, 50);
|
---|
17 | path.lineTo(100, 100);
|
---|
18 | path.lineTo(-50, 150);
|
---|
19 | path.position += 100;
|
---|
20 |
|
---|
21 | var rect = new Path.Rectangle({
|
---|
22 | point: [200, 100],
|
---|
23 | size: [200, 300],
|
---|
24 | fillColor: 'red'
|
---|
25 | });
|
---|
26 | rect.rotate(40);
|
---|
27 |
|
---|
28 | var circle = new Path.Circle({
|
---|
29 | center: [200, 300],
|
---|
30 | radius: 100,
|
---|
31 | fillColor: 'green'
|
---|
32 | });
|
---|
33 | circle.scale(0.5, 1);
|
---|
34 | circle.rotate(40);
|
---|
35 |
|
---|
36 | var ellipse = new Path.Ellipse({
|
---|
37 | point: [300, 300],
|
---|
38 | size: [100, 200],
|
---|
39 | fillColor: 'blue'
|
---|
40 | });
|
---|
41 | ellipse.rotate(-40);
|
---|
42 |
|
---|
43 | var rect = new Path.Rectangle({
|
---|
44 | point: [250, 20],
|
---|
45 | size: [200, 300],
|
---|
46 | radius: [40, 20],
|
---|
47 | fillColor: 'yellow'
|
---|
48 | });
|
---|
49 | rect.rotate(-20);
|
---|
50 | rect.data = {
|
---|
51 | string: '----',
|
---|
52 | number: 1234,
|
---|
53 | array: ['a ray', 'some rays'],
|
---|
54 | bool: true,
|
---|
55 | nil: null,
|
---|
56 | point: new Point(12, 34),
|
---|
57 | size: new Size(12, 34),
|
---|
58 | rectangle: new Rectangle([12, 34], [56, 78]),
|
---|
59 | deep: {
|
---|
60 | deeper: {
|
---|
61 | deepest: true
|
---|
62 | }
|
---|
63 | }
|
---|
64 | };
|
---|
65 |
|
---|
66 | var parallelogram = new Path({
|
---|
67 | closed: true,
|
---|
68 | segments: [[50, 0], [50, 100], [90, 120], [90, 20]],
|
---|
69 | fillColor: '#99c'
|
---|
70 | });
|
---|
71 |
|
---|
72 | document.getElementById('svg').appendChild(project.exportSVG({ matchShapes: true }));
|
---|
73 | </script>
|
---|
74 | </head>
|
---|
75 | <body>
|
---|
76 | <canvas id="canvas" width="500" height="500"></canvas>
|
---|
77 | <svg id="svg" width="500" height="500"></svg>
|
---|
78 | </body>
|
---|
79 | </html> |
---|