summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2010-04-03 23:27:21 +0200
committerAlexander Larsson <alexl@redhat.com>2010-04-03 23:27:21 +0200
commita9ec034c28065fdf33e5695e5966cf123aa467b2 (patch)
treee2c17f10a80803688dab8d2aabf547460569de78
parente2696dbbd6f561feb041fda71a8ca548d2d33558 (diff)
Draw some rects
-rw-r--r--client.html38
-rw-r--r--daemon.c4
2 files changed, 36 insertions, 6 deletions
diff --git a/client.html b/client.html
index da5c7cf..c141278 100644
--- a/client.html
+++ b/client.html
@@ -36,12 +36,39 @@ function sendRequest()
function handleLoad(event)
{
- document.getElementById("responseOutput").style.display = "";
- document.getElementById("responseOutput").innerHTML += "<h3>text:</h3>" + event.target.responseText;
+ cmd = event.target.responseText;
+
+ canvas = document.getElementById("display");
+ context = canvas.getContext("2d");
+
+ i = 0;
+ switch (cmd[i]) {
+ case "r":
+ i++;
+ x = parseInt(cmd.slice(i))
+ i = cmd.indexOf(",", i) + 1
+ y = parseInt(cmd.slice(i))
+ i = cmd.indexOf(",", i) + 1
+ w = parseInt(cmd.slice(i))
+ i = cmd.indexOf(",", i) + 1
+ h = parseInt(cmd.slice(i))
+
+ context.fillStyle = 'rgba(255,0,0,0.5)';
+ context.fillRect(x, y, w, h);
+
+ break;
+ default:
+ alert("Unknown op " + cmd[i]);
+ }
}
window.onload = function ()
-{
+{
+ canvas = document.getElementById("display");
+ context = canvas.getContext("2d");
+ context.fillStyle = 'rgba(0,0,0,1.0)';
+ context.fillRect(0, 0, context.canvas.width, context.canvas.height);
+
document.requestForm.requestButton.onclick = function () { sendRequest(); };
};
@@ -56,6 +83,9 @@ window.onload = function ()
</form>
<br />
<div id="responseOutput" class="results" style="display:none;">&nbsp;</div>
-
+
+<canvas id="display" width="800" height="600">
+</canvas>
+
</body>
</html>
diff --git a/daemon.c b/daemon.c
index a2c5b96..df6fbb8 100644
--- a/daemon.c
+++ b/daemon.c
@@ -104,8 +104,8 @@ send_draw_ops(GOutputStream *out)
while (1)
{
- data = g_strdup_printf ("test %d", i++);
-
+ data = g_strdup_printf ("r%d,%d,%d,%d", i*10, i*10, 5, 5);
+ i ++;
g_output_stream_write_all (cout,
data, strlen(data),
NULL, NULL, NULL);