Mercurial > MadButterfly
comparison 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 |
comparison
equal
deleted
inserted
replaced
938:13b9acbbe9a3 | 939:a74b4d986a91 |
---|---|
1 // -*- indent-tabs-mode: t; tab-width: 8; c-basic-offset: 4; -*- | |
2 // vim: sw=4:ts=8:sts=4 | |
3 var mbapp = require("mbapp"); | |
4 var sys=require("sys"); | |
5 var canvas=require("canvas"); | |
6 | |
7 app = new mbapp.app(); | |
8 | |
9 app.canvas = new canvas.canvas(app,app.mb_rt.root); | |
10 | |
11 app.canvas.background(0,0,0,1); | |
12 app.canvas.rect(0,0,400,400); | |
13 app.canvas.strokeWeight(8); | |
14 width=200; | |
15 height=200; | |
16 | |
17 setInterval(function() { | |
18 app.canvas.clear(); | |
19 | |
20 for(i=0;i<width;i++) { | |
21 x = Math.random()*255; | |
22 y = Math.random()*200; | |
23 cr = Math.random() | |
24 cg = Math.random() | |
25 cb = Math.random() | |
26 app.canvas.stroke(cr,cg,cb,1); | |
27 app.canvas.line(i,0,x,height); | |
28 } | |
29 app.update(); | |
30 },33); | |
31 app.loop(); |