front_idill/extern/fajran-tuiojs/examples/paint.html
changeset 25 a7b0e40bcab0
equal deleted inserted replaced
24:2bdf5d51d434 25:a7b0e40bcab0
       
     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 </style>
       
     7 <script type="text/javascript" src="../src/tuio.js"></script>
       
     8 <script type="text/javascript" src="../connector/npTuioClient/tuiojs.npTuioClient.js"></script>
       
     9 <script type="text/javascript">
       
    10 
       
    11 var canvas;
       
    12 var ctx;
       
    13 var w = 300;
       
    14 var h = 300;
       
    15 
       
    16 function updateCanvasSize() {
       
    17 	var nw = window.innerWidth;
       
    18 	var nh = window.innerHeight;
       
    19 
       
    20 	if ((w != nw) || (h != nh)) {
       
    21 		w = nw;
       
    22 		h = nh;
       
    23 		canvas.style.width = w+'px';
       
    24 		canvas.style.height = h+'px';
       
    25 		canvas.width = w;
       
    26 		canvas.height = h;
       
    27 	}
       
    28 }
       
    29 
       
    30 tuio.cursor_update(function(data) {
       
    31 	var px = data.x * w;
       
    32 	var py = data.y * h;
       
    33 
       
    34 	ctx.beginPath();
       
    35 	ctx.fillStyle = "rgba(0, 0, 200, 0.2)";
       
    36 	ctx.arc(px, py, 15, 0, 2*Math.PI, true);
       
    37 	ctx.fill();
       
    38 });
       
    39 
       
    40 function init() {
       
    41 	canvas = document.getElementById('canvas');
       
    42 	ctx = canvas.getContext('2d');
       
    43 	tuio.start();
       
    44 	updateCanvasSize();
       
    45 }
       
    46 
       
    47 </script>
       
    48 </head>
       
    49 <body onload="init()">
       
    50 	
       
    51 <canvas id="canvas" width="300" height="300" style="top:0px; left:0px; width: 300px; height: 300px;"></canvas>
       
    52 
       
    53 </body>
       
    54 </html>