Mercurial > MadButterfly
diff nodejs/examples/simple/testcanvas.js @ 939:a74b4d986a91
Move examples for nodejs into nodejs/examples/ sub-directories.
See INSTALL.txt. Use nodejs/examples/run.sh to run examples.
For example,
cd nodejs/examples; ./run.sh examples/testsvg/testsvg.js
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Fri, 12 Nov 2010 17:39:04 +0800 |
parents | nodejs/testcanvas.js@586e50f82c1f |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nodejs/examples/simple/testcanvas.js Fri Nov 12 17:39:04 2010 +0800 @@ -0,0 +1,31 @@ +// -*- indent-tabs-mode: t; tab-width: 8; c-basic-offset: 4; -*- +// vim: sw=4:ts=8:sts=4 +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; + +setInterval(function() { + app.canvas.clear(); + + 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.update(); +},33); +app.loop();