annotate nodejs/testcanvas.js @ 928:35b6a9411e26

Use inkscape:label to be the same way as the mbname. In this way, we can use the property editor to define name of the object.
author wycc
date Wed, 03 Nov 2010 22:02:23 +0800
parents 586e50f82c1f
children
rev   line source
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 761
diff changeset
1 // -*- indent-tabs-mode: t; tab-width: 8; c-basic-offset: 4; -*-
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 761
diff changeset
2 // vim: sw=4:ts=8:sts=4
736
cdd578c1f866 Add Canvas class for the dynamic content generation. The testcanvas.js is used to demostrate the capability of it.
wycc
parents:
diff changeset
3 var mbapp = require("./mbapp");
cdd578c1f866 Add Canvas class for the dynamic content generation. The testcanvas.js is used to demostrate the capability of it.
wycc
parents:
diff changeset
4 var sys=require("sys");
cdd578c1f866 Add Canvas class for the dynamic content generation. The testcanvas.js is used to demostrate the capability of it.
wycc
parents:
diff changeset
5 var canvas=require("./canvas");
cdd578c1f866 Add Canvas class for the dynamic content generation. The testcanvas.js is used to demostrate the capability of it.
wycc
parents:
diff changeset
6
cdd578c1f866 Add Canvas class for the dynamic content generation. The testcanvas.js is used to demostrate the capability of it.
wycc
parents:
diff changeset
7 app = new mbapp.app();
cdd578c1f866 Add Canvas class for the dynamic content generation. The testcanvas.js is used to demostrate the capability of it.
wycc
parents:
diff changeset
8
cdd578c1f866 Add Canvas class for the dynamic content generation. The testcanvas.js is used to demostrate the capability of it.
wycc
parents:
diff changeset
9 app.canvas = new canvas.canvas(app,app.mb_rt.root);
cdd578c1f866 Add Canvas class for the dynamic content generation. The testcanvas.js is used to demostrate the capability of it.
wycc
parents:
diff changeset
10
cdd578c1f866 Add Canvas class for the dynamic content generation. The testcanvas.js is used to demostrate the capability of it.
wycc
parents:
diff changeset
11 app.canvas.background(0,0,0,1);
cdd578c1f866 Add Canvas class for the dynamic content generation. The testcanvas.js is used to demostrate the capability of it.
wycc
parents:
diff changeset
12 app.canvas.rect(0,0,400,400);
cdd578c1f866 Add Canvas class for the dynamic content generation. The testcanvas.js is used to demostrate the capability of it.
wycc
parents:
diff changeset
13 app.canvas.strokeWeight(8);
cdd578c1f866 Add Canvas class for the dynamic content generation. The testcanvas.js is used to demostrate the capability of it.
wycc
parents:
diff changeset
14 width=200;
cdd578c1f866 Add Canvas class for the dynamic content generation. The testcanvas.js is used to demostrate the capability of it.
wycc
parents:
diff changeset
15 height=200;
751
9f4a1134ec82 Use the coord.remove() to implement the processing canvas
wycc
parents: 736
diff changeset
16
9f4a1134ec82 Use the coord.remove() to implement the processing canvas
wycc
parents: 736
diff changeset
17 setInterval(function() {
9f4a1134ec82 Use the coord.remove() to implement the processing canvas
wycc
parents: 736
diff changeset
18 app.canvas.clear();
736
cdd578c1f866 Add Canvas class for the dynamic content generation. The testcanvas.js is used to demostrate the capability of it.
wycc
parents:
diff changeset
19
751
9f4a1134ec82 Use the coord.remove() to implement the processing canvas
wycc
parents: 736
diff changeset
20 for(i=0;i<width;i++) {
9f4a1134ec82 Use the coord.remove() to implement the processing canvas
wycc
parents: 736
diff changeset
21 x = Math.random()*255;
9f4a1134ec82 Use the coord.remove() to implement the processing canvas
wycc
parents: 736
diff changeset
22 y = Math.random()*200;
9f4a1134ec82 Use the coord.remove() to implement the processing canvas
wycc
parents: 736
diff changeset
23 cr = Math.random()
9f4a1134ec82 Use the coord.remove() to implement the processing canvas
wycc
parents: 736
diff changeset
24 cg = Math.random()
9f4a1134ec82 Use the coord.remove() to implement the processing canvas
wycc
parents: 736
diff changeset
25 cb = Math.random()
9f4a1134ec82 Use the coord.remove() to implement the processing canvas
wycc
parents: 736
diff changeset
26 app.canvas.stroke(cr,cg,cb,1);
9f4a1134ec82 Use the coord.remove() to implement the processing canvas
wycc
parents: 736
diff changeset
27 app.canvas.line(i,0,x,height);
9f4a1134ec82 Use the coord.remove() to implement the processing canvas
wycc
parents: 736
diff changeset
28 }
9f4a1134ec82 Use the coord.remove() to implement the processing canvas
wycc
parents: 736
diff changeset
29 app.update();
9f4a1134ec82 Use the coord.remove() to implement the processing canvas
wycc
parents: 736
diff changeset
30 },33);
736
cdd578c1f866 Add Canvas class for the dynamic content generation. The testcanvas.js is used to demostrate the capability of it.
wycc
parents:
diff changeset
31 app.loop();