front_idill/extern/fajran-npTuioClient/example/tracker.html
author bastiena
Thu, 19 Apr 2012 11:53:06 +0200
changeset 29 fcf435874395
parent 28 9ccef81f02ab
permissions -rw-r--r--
Middleware : Connection between middleware and front idill established with websockets.
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() {
28
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 21
diff changeset
    20
    if (updateStarted) return;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 21
diff changeset
    21
    updateStarted = true;
21
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    22
28
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 21
diff changeset
    23
    var nw = window.innerWidth;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 21
diff changeset
    24
    var nh = window.innerHeight;
21
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    25
28
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 21
diff changeset
    26
    if ((w != nw) || (h != nh)) {
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 21
diff changeset
    27
        w = nw;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 21
diff changeset
    28
        h = nh;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 21
diff changeset
    29
        canvas.style.width = w+'px';
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 21
diff changeset
    30
        canvas.style.height = h+'px';
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 21
diff changeset
    31
        canvas.width = w;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 21
diff changeset
    32
        canvas.height = h;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 21
diff changeset
    33
    }
21
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    34
28
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 21
diff changeset
    35
    ctx.clearRect(0, 0, w, h);
21
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    36
28
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 21
diff changeset
    37
    var i, len = tuio.cursors.length;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 21
diff changeset
    38
    for (i=0; i<len; i++) {
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 21
diff changeset
    39
        var obj = tuio.cursors[i];
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 21
diff changeset
    40
        var x = obj.x;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 21
diff changeset
    41
        var y = obj.y;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 21
diff changeset
    42
        var px = x * w;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 21
diff changeset
    43
        var py = y * h;
21
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    44
28
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 21
diff changeset
    45
        ctx.beginPath();
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 21
diff changeset
    46
        ctx.arc(px, py, 20, 0, 2*Math.PI, true);
21
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    47
28
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 21
diff changeset
    48
        ctx.fillStyle = "rgba(0, 0, 200, 0.2)";
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 21
diff changeset
    49
        ctx.fill();
21
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    50
28
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 21
diff changeset
    51
        ctx.lineWidth = 2.0;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 21
diff changeset
    52
        ctx.strokeStyle = "rgba(0, 0, 200, 0.8)";
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 21
diff changeset
    53
        ctx.stroke();
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 21
diff changeset
    54
    }
21
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    55
28
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 21
diff changeset
    56
    updateStarted = false;
21
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() {
28
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 21
diff changeset
    60
    canvas = document.getElementById('canvas');
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 21
diff changeset
    61
    ctx = canvas.getContext('2d');
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 21
diff changeset
    62
    timer = setInterval(update, 15);
21
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()">
28
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 21
diff changeset
    68
    
21
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>