annotate nodejs/examples/simple/test-translate.js @ 1412:3e80b5cf8da2

Testcase for redrawing image. There is a report from wycc that redrawing is not working for image (maybe other shapes). This testcase shows that he may forget to call redraw_changed() after updating transform matrix.
author Thinker K.F. Li <thinker@codemud.net>
date Wed, 06 Apr 2011 10:44:15 +0800
parents
children b8dfa491ed9d
rev   line source
1412
3e80b5cf8da2 Testcase for redrawing image.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
1 // -*- indent-tabs-mode: t; tab-width: 8; c-basic-offset: 4; -*-
3e80b5cf8da2 Testcase for redrawing image.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
2 // vim: sw=4:ts=8:sts=4
3e80b5cf8da2 Testcase for redrawing image.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
3 var svg = require("svg");
3e80b5cf8da2 Testcase for redrawing image.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
4 var mbapp = require("mbapp");
3e80b5cf8da2 Testcase for redrawing image.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
5 var sys=require("sys");
3e80b5cf8da2 Testcase for redrawing image.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
6 var animate=require("animate");
3e80b5cf8da2 Testcase for redrawing image.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
7
3e80b5cf8da2 Testcase for redrawing image.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
8 app = new mbapp.app();
3e80b5cf8da2 Testcase for redrawing image.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
9
3e80b5cf8da2 Testcase for redrawing image.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
10 coord_parent = app.mb_rt.coord_new(app.mb_rt.root);
3e80b5cf8da2 Testcase for redrawing image.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
11 coord = app.mb_rt.coord_new(coord_parent)
3e80b5cf8da2 Testcase for redrawing image.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
12 data=mbapp.ldr.load("sample.png");
3e80b5cf8da2 Testcase for redrawing image.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
13 paint = app.mb_rt.paint_image_new(data);
3e80b5cf8da2 Testcase for redrawing image.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
14 img = app.mb_rt.image_new(10,10,50,50);
3e80b5cf8da2 Testcase for redrawing image.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
15 paint.fill(img);
3e80b5cf8da2 Testcase for redrawing image.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
16 coord.opacity = 0.9;
3e80b5cf8da2 Testcase for redrawing image.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
17 coord.add_shape(img);
3e80b5cf8da2 Testcase for redrawing image.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
18
3e80b5cf8da2 Testcase for redrawing image.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
19 var shift = 0;
3e80b5cf8da2 Testcase for redrawing image.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
20 function translate_handler() {
3e80b5cf8da2 Testcase for redrawing image.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
21 coord_parent[2] = shift;
3e80b5cf8da2 Testcase for redrawing image.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
22 app.mb_rt.redraw_changed();
3e80b5cf8da2 Testcase for redrawing image.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
23 setTimeout(translate_handler, 100);
3e80b5cf8da2 Testcase for redrawing image.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
24 shift = shift + 10;
3e80b5cf8da2 Testcase for redrawing image.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
25 }
3e80b5cf8da2 Testcase for redrawing image.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
26
3e80b5cf8da2 Testcase for redrawing image.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
27 translate_handler();
3e80b5cf8da2 Testcase for redrawing image.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
28 app.loop()