|
12 | 12 |
|
13 | 13 | <style> |
14 | 14 | canvas { |
15 | | - -moz-transform: scale(-1, 1); |
16 | | - -o-transform: scale(-1, 1); |
17 | | - -webkit-transform: scale(-1, 1); |
18 | | - filter: FlipH; |
19 | | - transform: scale(-1, 1); |
20 | | - position: absolute; |
21 | | - top: 305px; |
22 | | - left: 54px; |
| 15 | + -moz-transform: scale(-1, 1); |
| 16 | + -o-transform: scale(-1, 1); |
| 17 | + -webkit-transform: scale(-1, 1); |
| 18 | + filter: FlipH; |
| 19 | + transform: scale(-1, 1); |
| 20 | + position: absolute; |
| 21 | + top: 305px; |
| 22 | + left: 54px; |
23 | 23 | } |
24 | 24 | #iphoneContainer { |
25 | | - width: 425px; |
26 | | - height: 757px; |
27 | | - margin: 0 auto; |
28 | | - position: relative; |
29 | | - background: url(img/iphone.png); |
| 25 | + width: 425px; |
| 26 | + height: 757px; |
| 27 | + margin: 0 auto; |
| 28 | + position: relative; |
| 29 | + background: url(img/iphone.png); |
30 | 30 | } |
31 | 31 | #selected { |
32 | | - width: 30px; |
33 | | - height: 30px; |
34 | | - border: 3px solid #000; |
35 | | - border-radius: 7px; |
36 | | - position: absolute; |
37 | | - display: none; |
| 32 | + width: 30px; |
| 33 | + height: 30px; |
| 34 | + border: 3px solid #000; |
| 35 | + border-radius: 7px; |
| 36 | + position: absolute; |
| 37 | + display: none; |
38 | 38 | } |
39 | 39 | #selected.pencil { |
40 | | - bottom: 153px; |
41 | | - display: block; |
42 | | - left: 73px; |
| 40 | + bottom: 153px; |
| 41 | + display: block; |
| 42 | + left: 73px; |
43 | 43 | } |
44 | 44 | #selected.erase { |
45 | | - bottom: 153px; |
46 | | - display: block; |
47 | | - left: 128px; |
| 45 | + bottom: 153px; |
| 46 | + display: block; |
| 47 | + left: 128px; |
48 | 48 | } |
49 | 49 | </style> |
50 | 50 |
|
51 | 51 | </head> |
52 | 52 | <body> |
53 | 53 |
|
54 | 54 | <div id="iphoneContainer"> |
55 | | - <div id="selected"></div> |
| 55 | + <div id="selected"></div> |
56 | 56 | </div> |
57 | 57 |
|
58 | 58 | <script> |
59 | 59 | var videoCamera = new tracking.VideoCamera().hide().render().renderVideoCanvas('#iphoneContainer'); |
60 | 60 |
|
61 | 61 | var plotCanvas = new tracking.Canvas().render(), |
62 | | - drawSegments = [], |
63 | | - eraseFound = false, |
64 | | - pencilFound = false, |
65 | | - segment = 0, |
66 | | - selectedElement = document.getElementById('selected'); |
| 62 | + drawSegments = [], |
| 63 | + eraseFound = false, |
| 64 | + pencilFound = false, |
| 65 | + segment = 0, |
| 66 | + selectedElement = document.getElementById('selected'); |
67 | 67 |
|
68 | 68 | videoCamera.track({ |
69 | | - type: 'color', |
70 | | - color: 'magenta', |
71 | | - onFound: function(track) { |
72 | | - if (!drawSegments[segment]) { |
73 | | - drawSegments[segment]= []; |
74 | | - } |
75 | | - |
76 | | - drawSegments[segment].push(track.x, track.y); |
77 | | - |
78 | | - if (!pencilFound) { |
79 | | - selectedElement.className = 'pencil'; |
80 | | - } |
81 | | - |
82 | | - pencilFound = true; |
83 | | - }, |
84 | | - onNotFound: function() { |
85 | | - if (pencilFound) { |
86 | | - segment++; |
87 | | - pencilFound = false; |
88 | | - selectedElement.className = ''; |
89 | | - } |
90 | | - } |
| 69 | + type: 'color', |
| 70 | + color: 'magenta', |
| 71 | + onFound: function(track) { |
| 72 | + if (!drawSegments[segment]) { |
| 73 | + drawSegments[segment]= []; |
| 74 | + } |
| 75 | + |
| 76 | + drawSegments[segment].push(track.x, track.y); |
| 77 | + |
| 78 | + if (!pencilFound) { |
| 79 | + selectedElement.className = 'pencil'; |
| 80 | + } |
| 81 | + |
| 82 | + pencilFound = true; |
| 83 | + }, |
| 84 | + onNotFound: function() { |
| 85 | + if (pencilFound) { |
| 86 | + segment++; |
| 87 | + pencilFound = false; |
| 88 | + selectedElement.className = ''; |
| 89 | + } |
| 90 | + } |
91 | 91 | }); |
92 | 92 |
|
93 | 93 | videoCamera.track({ |
94 | | - type: 'color', |
95 | | - color: 'cyan', |
96 | | - onFound: function(track) { |
97 | | - segment = 0; |
98 | | - drawSegments = []; |
99 | | - |
100 | | - if (!eraseFound) { |
101 | | - selectedElement.className = 'erase'; |
102 | | - } |
103 | | - |
104 | | - eraseFound = true; |
105 | | - }, |
106 | | - onNotFound: function() { |
107 | | - if (eraseFound) { |
108 | | - eraseFound = false; |
109 | | - selectedElement.className = ''; |
110 | | - } |
111 | | - } |
| 94 | + type: 'color', |
| 95 | + color: 'cyan', |
| 96 | + onFound: function(track) { |
| 97 | + segment = 0; |
| 98 | + drawSegments = []; |
| 99 | + |
| 100 | + if (!eraseFound) { |
| 101 | + selectedElement.className = 'erase'; |
| 102 | + } |
| 103 | + |
| 104 | + eraseFound = true; |
| 105 | + }, |
| 106 | + onNotFound: function() { |
| 107 | + if (eraseFound) { |
| 108 | + eraseFound = false; |
| 109 | + selectedElement.className = ''; |
| 110 | + } |
| 111 | + } |
112 | 112 | }); |
113 | 113 |
|
114 | 114 | (function loop() { |
115 | | - for (var i = 0, len = drawSegments.length; i < len; i++) { |
116 | | - drawSpline(videoCamera.canvas.context, drawSegments[i], 0.5, false); |
117 | | - } |
118 | | - requestAnimationFrame(loop); |
| 115 | + for (var i = 0, len = drawSegments.length; i < len; i++) { |
| 116 | + drawSpline(videoCamera.canvas.context, drawSegments[i], 0.5, false); |
| 117 | + } |
| 118 | + requestAnimationFrame(loop); |
119 | 119 | }()); |
120 | 120 | </script> |
121 | 121 |
|
|
0 commit comments