annotate nodejs/testcanvas.js @ 751:9f4a1134ec82

Use the coord.remove() to implement the processing canvas
author wycc
date Thu, 26 Aug 2010 00:28:12 +0800
parents cdd578c1f866
children cf60cf8983f8
rev   line source
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
1 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
2 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
3 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
4
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 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
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.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
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.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
10 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
11 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
12 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
13 height=200;
751
9f4a1134ec82 Use the coord.remove() to implement the processing canvas
wycc
parents: 736
diff changeset
14
9f4a1134ec82 Use the coord.remove() to implement the processing canvas
wycc
parents: 736
diff changeset
15 setInterval(function() {
9f4a1134ec82 Use the coord.remove() to implement the processing canvas
wycc
parents: 736
diff changeset
16 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
17
751
9f4a1134ec82 Use the coord.remove() to implement the processing canvas
wycc
parents: 736
diff changeset
18 for(i=0;i<width;i++) {
9f4a1134ec82 Use the coord.remove() to implement the processing canvas
wycc
parents: 736
diff changeset
19 x = Math.random()*255;
9f4a1134ec82 Use the coord.remove() to implement the processing canvas
wycc
parents: 736
diff changeset
20 y = Math.random()*200;
9f4a1134ec82 Use the coord.remove() to implement the processing canvas
wycc
parents: 736
diff changeset
21 cr = Math.random()
9f4a1134ec82 Use the coord.remove() to implement the processing canvas
wycc
parents: 736
diff changeset
22 cg = Math.random()
9f4a1134ec82 Use the coord.remove() to implement the processing canvas
wycc
parents: 736
diff changeset
23 cb = Math.random()
9f4a1134ec82 Use the coord.remove() to implement the processing canvas
wycc
parents: 736
diff changeset
24 app.canvas.stroke(cr,cg,cb,1);
9f4a1134ec82 Use the coord.remove() to implement the processing canvas
wycc
parents: 736
diff changeset
25 app.canvas.line(i,0,x,height);
9f4a1134ec82 Use the coord.remove() to implement the processing canvas
wycc
parents: 736
diff changeset
26 }
9f4a1134ec82 Use the coord.remove() to implement the processing canvas
wycc
parents: 736
diff changeset
27 app.update();
9f4a1134ec82 Use the coord.remove() to implement the processing canvas
wycc
parents: 736
diff changeset
28 },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
29 app.loop();