front_idill/extern/fajran-tuiojs/examples/paint.html
author bastiena
Fri, 06 Apr 2012 18:32:13 +0200
changeset 25 a7b0e40bcab0
permissions -rw-r--r--
Front IDILL : Basic JS TUIO lib loaded
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
25
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
     1
<!DOCTYPE html>
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
     2
<html>
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
     3
<head><title>TUIO Client plugin test</title>
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
     4
<style type="text/css">
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
     5
body { margin: 0px; overflow: hidden; }
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
     6
</style>
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
     7
<script type="text/javascript" src="../src/tuio.js"></script>
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
     8
<script type="text/javascript" src="../connector/npTuioClient/tuiojs.npTuioClient.js"></script>
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
     9
<script type="text/javascript">
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    10
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    11
var canvas;
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    12
var ctx;
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    13
var w = 300;
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    14
var h = 300;
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    15
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    16
function updateCanvasSize() {
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    17
	var nw = window.innerWidth;
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    18
	var nh = window.innerHeight;
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    19
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    20
	if ((w != nw) || (h != nh)) {
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    21
		w = nw;
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    22
		h = nh;
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    23
		canvas.style.width = w+'px';
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    24
		canvas.style.height = h+'px';
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    25
		canvas.width = w;
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    26
		canvas.height = h;
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    27
	}
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    28
}
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    29
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    30
tuio.cursor_update(function(data) {
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    31
	var px = data.x * w;
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    32
	var py = data.y * h;
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    33
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    34
	ctx.beginPath();
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    35
	ctx.fillStyle = "rgba(0, 0, 200, 0.2)";
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    36
	ctx.arc(px, py, 15, 0, 2*Math.PI, true);
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    37
	ctx.fill();
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    38
});
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    39
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    40
function init() {
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    41
	canvas = document.getElementById('canvas');
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    42
	ctx = canvas.getContext('2d');
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    43
	tuio.start();
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    44
	updateCanvasSize();
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    45
}
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    46
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    47
</script>
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    48
</head>
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    49
<body onload="init()">
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    50
	
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    51
<canvas id="canvas" width="300" height="300" style="top:0px; left:0px; width: 300px; height: 300px;"></canvas>
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    52
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    53
</body>
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    54
</html>