Mercurial > MadButterfly
diff nodejs/testcanvas.js @ 736:cdd578c1f866
Add Canvas class for the dynamic content generation. The testcanvas.js is used to demostrate the capability of it.
author | wycc |
---|---|
date | Sat, 21 Aug 2010 19:12:43 +0800 |
parents | |
children | 9f4a1134ec82 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nodejs/testcanvas.js Sat Aug 21 19:12:43 2010 +0800 @@ -0,0 +1,24 @@ +var mbapp = require("./mbapp"); +var sys=require("sys"); +var canvas=require("./canvas"); + +app = new mbapp.app(); + +app.canvas = new canvas.canvas(app,app.mb_rt.root); + +app.canvas.background(0,0,0,1); +app.canvas.rect(0,0,400,400); +app.canvas.strokeWeight(8); +width=200; +height=200; +for(i=0;i<width;i++) { + x = Math.random()*255; + y = Math.random()*200; + cr = Math.random() + cg = Math.random() + cb = Math.random() + app.canvas.stroke(cr,cg,cb,1); + app.canvas.line(i,0,x,height); +} + +app.loop();