1 <!DOCTYPE html> |
|
2 <html> |
|
3 <head><title>TUIO Client plugin test</title> |
|
4 <style type="text/css"> |
|
5 canvas { border: 1px solid black; } |
|
6 </style> |
|
7 <script type="text/javascript"> |
|
8 |
|
9 var canvas; |
|
10 var ctx; |
|
11 var w = 300; |
|
12 var h = 300; |
|
13 |
|
14 function tuio_object_add(sid, fid, x, y, a) { |
|
15 } |
|
16 |
|
17 function tuio_object_update(sid, fid, x, y, a) { |
|
18 } |
|
19 |
|
20 function tuio_object_remove(sid, fid, x, y, a) { |
|
21 } |
|
22 |
|
23 function tuio_cursor_add(sid, fid, x, y) { |
|
24 } |
|
25 |
|
26 function tuio_cursor_update(sid, fid, x, y) { |
|
27 var px = x * w; |
|
28 var py = y * h; |
|
29 |
|
30 ctx.beginPath(); |
|
31 ctx.fillStyle = "rgba(0, 0, 200, 0.2)"; |
|
32 ctx.arc(px, py, 5, 0, 2*Math.PI, true); |
|
33 ctx.fill(); |
|
34 } |
|
35 |
|
36 function tuio_cursor_remove(sid, fid, x, y) { |
|
37 } |
|
38 |
|
39 function tuio_callback(type, sid, fid, x, y, a) { |
|
40 if (type == 0) { |
|
41 tuio_object_add(sid, fid, x, y, a); |
|
42 } |
|
43 else if (type == 1) { |
|
44 tuio_object_update(sid, fid, x, y, a); |
|
45 } |
|
46 else if (type == 2) { |
|
47 tuio_object_remove(sid, fid, x, y, a); |
|
48 } |
|
49 else if (type == 3) { |
|
50 tuio_cursor_add(sid, fid, x, y); |
|
51 } |
|
52 else if (type == 4) { |
|
53 tuio_cursor_update(sid, fid, x, y); |
|
54 } |
|
55 else if (type == 5) { |
|
56 tuio_cursor_remove(sid, fid, x, y); |
|
57 } |
|
58 } |
|
59 |
|
60 function ol() { |
|
61 canvas = document.getElementById('c'); |
|
62 ctx = canvas.getContext('2d'); |
|
63 } |
|
64 |
|
65 </script> |
|
66 </head> |
|
67 <body onload="ol()"> |
|
68 |
|
69 <canvas id="c" width="300" height="300" style="top:0px; left:0px; width: 300px; height: 300px;"></canvas> |
|
70 <object id="tuio" type="application/x-tuio">Plugin FAILED to load</object> |
|
71 |
|
72 </body> |
|
73 </html> |
|