Mercurial > MadButterfly
annotate nodejs/testcanvas.js @ 780:16d8a1d48717
Doc for xnjsmb_sh_stext_set_style
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Mon, 30 Aug 2010 17:42:15 +0800 |
parents | cf60cf8983f8 |
children | 586e50f82c1f |
rev | line source |
---|---|
761 | 1 // vim: ts=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
|
2 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
|
3 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
|
4 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
|
5 |
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 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
|
7 |
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 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
|
9 |
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.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
|
11 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
|
12 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
|
13 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
|
14 height=200; |
751
9f4a1134ec82
Use the coord.remove() to implement the processing canvas
wycc
parents:
736
diff
changeset
|
15 |
9f4a1134ec82
Use the coord.remove() to implement the processing canvas
wycc
parents:
736
diff
changeset
|
16 setInterval(function() { |
9f4a1134ec82
Use the coord.remove() to implement the processing canvas
wycc
parents:
736
diff
changeset
|
17 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
|
18 |
751
9f4a1134ec82
Use the coord.remove() to implement the processing canvas
wycc
parents:
736
diff
changeset
|
19 for(i=0;i<width;i++) { |
9f4a1134ec82
Use the coord.remove() to implement the processing canvas
wycc
parents:
736
diff
changeset
|
20 x = Math.random()*255; |
9f4a1134ec82
Use the coord.remove() to implement the processing canvas
wycc
parents:
736
diff
changeset
|
21 y = Math.random()*200; |
9f4a1134ec82
Use the coord.remove() to implement the processing canvas
wycc
parents:
736
diff
changeset
|
22 cr = Math.random() |
9f4a1134ec82
Use the coord.remove() to implement the processing canvas
wycc
parents:
736
diff
changeset
|
23 cg = Math.random() |
9f4a1134ec82
Use the coord.remove() to implement the processing canvas
wycc
parents:
736
diff
changeset
|
24 cb = Math.random() |
9f4a1134ec82
Use the coord.remove() to implement the processing canvas
wycc
parents:
736
diff
changeset
|
25 app.canvas.stroke(cr,cg,cb,1); |
9f4a1134ec82
Use the coord.remove() to implement the processing canvas
wycc
parents:
736
diff
changeset
|
26 app.canvas.line(i,0,x,height); |
9f4a1134ec82
Use the coord.remove() to implement the processing canvas
wycc
parents:
736
diff
changeset
|
27 } |
9f4a1134ec82
Use the coord.remove() to implement the processing canvas
wycc
parents:
736
diff
changeset
|
28 app.update(); |
9f4a1134ec82
Use the coord.remove() to implement the processing canvas
wycc
parents:
736
diff
changeset
|
29 },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
|
30 app.loop(); |