front_idill/extern/fajran-npTuioClient/example/tracker.html
changeset 21 e4e5f02787a1
child 28 9ccef81f02ab
equal deleted inserted replaced
20:f4303074311f 21:e4e5f02787a1
       
     1 <!DOCTYPE html>
       
     2 <html>
       
     3 <head><title>TUIO Client plugin test</title>
       
     4 <style type="text/css">
       
     5 body { margin: 0px; overflow: hidden; }
       
     6 canvas { border: 1px solid black; }
       
     7 </style>
       
     8 <script type="text/javascript" src="tuio.js"></script>
       
     9 <script type="text/javascript">
       
    10 
       
    11 var canvas;
       
    12 var ctx;
       
    13 var w = 0;
       
    14 var h = 0;
       
    15 
       
    16 var timer;
       
    17 var updateStarted = false;
       
    18 
       
    19 function update() {
       
    20 	if (updateStarted) return;
       
    21 	updateStarted = true;
       
    22 
       
    23 	var nw = window.innerWidth;
       
    24 	var nh = window.innerHeight;
       
    25 
       
    26 	if ((w != nw) || (h != nh)) {
       
    27 		w = nw;
       
    28 		h = nh;
       
    29 		canvas.style.width = w+'px';
       
    30 		canvas.style.height = h+'px';
       
    31 		canvas.width = w;
       
    32 		canvas.height = h;
       
    33 	}
       
    34 
       
    35 	ctx.clearRect(0, 0, w, h);
       
    36 
       
    37 	var i, len = tuio.cursors.length;
       
    38 	for (i=0; i<len; i++) {
       
    39 		var obj = tuio.cursors[i];
       
    40 		var x = obj.x;
       
    41 		var y = obj.y;
       
    42 		var px = x * w;
       
    43 		var py = y * h;
       
    44 
       
    45 		ctx.beginPath();
       
    46 		ctx.arc(px, py, 20, 0, 2*Math.PI, true);
       
    47 
       
    48 		ctx.fillStyle = "rgba(0, 0, 200, 0.2)";
       
    49 		ctx.fill();
       
    50 
       
    51 		ctx.lineWidth = 2.0;
       
    52 		ctx.strokeStyle = "rgba(0, 0, 200, 0.8)";
       
    53 		ctx.stroke();
       
    54 	}
       
    55 
       
    56 	updateStarted = false;
       
    57 }
       
    58 
       
    59 function ol() {
       
    60 	canvas = document.getElementById('canvas');
       
    61 	ctx = canvas.getContext('2d');
       
    62 	timer = setInterval(update, 15);
       
    63 };
       
    64 
       
    65 </script>
       
    66 </head>
       
    67 <body onload="ol()">
       
    68 	
       
    69 <canvas id="canvas" 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>