Mercurial > MadButterfly
annotate nodejs/testcanvas.js @ 776:77b561bb7929
Implement new algorithm to calculate the origin of the SVG elemnts so that we can implement object resize without changing the position of the object.
However, the image does not work here since it does not use the transformation of the group.
author | wycc |
---|---|
date | Mon, 30 Aug 2010 08:56:44 +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(); |