front_idill/extern/fajran-npTuioClient/example/tracker.html
author bastiena
Fri, 06 Apr 2012 10:44:54 +0200
changeset 21 e4e5f02787a1
child 28 9ccef81f02ab
permissions -rw-r--r--
Front IDILL : Added Communication extern named fajran-npTuioClient It contains the project generating a dll used as a browser plugin.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
21
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
     1
<!DOCTYPE html>
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
     2
<html>
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
     3
<head><title>TUIO Client plugin test</title>
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
     4
<style type="text/css">
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
     5
body { margin: 0px; overflow: hidden; }
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
     6
canvas { border: 1px solid black; }
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
     7
</style>
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
     8
<script type="text/javascript" src="tuio.js"></script>
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
     9
<script type="text/javascript">
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    10
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    11
var canvas;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    12
var ctx;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    13
var w = 0;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    14
var h = 0;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    15
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    16
var timer;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    17
var updateStarted = false;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    18
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    19
function update() {
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    20
	if (updateStarted) return;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    21
	updateStarted = true;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    22
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    23
	var nw = window.innerWidth;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    24
	var nh = window.innerHeight;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    25
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    26
	if ((w != nw) || (h != nh)) {
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    27
		w = nw;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    28
		h = nh;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    29
		canvas.style.width = w+'px';
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    30
		canvas.style.height = h+'px';
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    31
		canvas.width = w;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    32
		canvas.height = h;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    33
	}
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    34
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    35
	ctx.clearRect(0, 0, w, h);
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    36
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    37
	var i, len = tuio.cursors.length;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    38
	for (i=0; i<len; i++) {
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    39
		var obj = tuio.cursors[i];
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    40
		var x = obj.x;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    41
		var y = obj.y;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    42
		var px = x * w;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    43
		var py = y * h;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    44
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    45
		ctx.beginPath();
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    46
		ctx.arc(px, py, 20, 0, 2*Math.PI, true);
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    47
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    48
		ctx.fillStyle = "rgba(0, 0, 200, 0.2)";
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    49
		ctx.fill();
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    50
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    51
		ctx.lineWidth = 2.0;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    52
		ctx.strokeStyle = "rgba(0, 0, 200, 0.8)";
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    53
		ctx.stroke();
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    54
	}
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    55
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    56
	updateStarted = false;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    57
}
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    58
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    59
function ol() {
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    60
	canvas = document.getElementById('canvas');
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    61
	ctx = canvas.getContext('2d');
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    62
	timer = setInterval(update, 15);
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    63
};
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    64
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    65
</script>
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    66
</head>
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    67
<body onload="ol()">
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    68
	
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    69
<canvas id="canvas" width="300" height="300" style="top:0px; left:0px; width: 300px; height: 300px;"></canvas>
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    70
<object id="tuio" type="application/x-tuio">Plugin FAILED to load</object>
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    71
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    72
</body>
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    73
</html>