changeset 751:9f4a1134ec82

Use the coord.remove() to implement the processing canvas
author wycc
date Thu, 26 Aug 2010 00:28:12 +0800
parents 199bac90b90a
children ffbf9910213c
files nodejs/canvas.js nodejs/testcanvas.js
diffstat 2 files changed, 64 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/nodejs/canvas.js	Thu Aug 26 00:16:12 2010 +0800
+++ b/nodejs/canvas.js	Thu Aug 26 00:28:12 2010 +0800
@@ -4,6 +4,7 @@
 
 function canvas(app,root) {
     this.mb_rt = app.mb_rt;
+	this.parent = root;
     this.root = this.mb_rt.coord_new(root);
 	this.bg_r = 0;
 	this.bg_g = 0;
@@ -53,5 +54,54 @@
     this.stroke_w = w;
 }
 
+canvas.prototype.alpha=function(c) {
+}
+
+canvas.prototype.red=function(c) {
+}
+canvas.prototype.green=function(c) {
+}
+canvas.prototype.blue=function(c) {
+}
+
+
+canvas.prototype.clear=function() {
+    this.root.remove();
+    this.root = this.mb_rt.coord_new(this.parent);
+}
+
+canvas.prototype.arc=function(x,y,w,h,start,end) {
+}
+
+canvas.prototype.ellipse=function(x, y, width, height) {
+}
+
+canvas.prototype.point=function(x,y) {
+}
+
+canvas.prototype.quad=function(x1,y1,x2,y2,x3,y3,x4,y4) {
+}
+
+canvas.prototype.triangle=function(x1,y1,x2,y2,x3,y3) {
+}
+
+canvas.prototype.bezier=function(x1, y1, cx1, cy1, cx2, cy2, x2, y2) {
+}
+
+canvas.prototype.curveTightness=function(squishy) {
+}
+
+canvas.prototype.colorMode=function() {
+}
+
+canvas.prototype.fill=function(color) {
+}
+
+canvas.prototype.noFill=function() {
+}
+
+canvas.prototype.noStroke=function() {
+}
+
 
 exports.canvas = canvas;
--- a/nodejs/testcanvas.js	Thu Aug 26 00:16:12 2010 +0800
+++ b/nodejs/testcanvas.js	Thu Aug 26 00:28:12 2010 +0800
@@ -11,14 +11,19 @@
 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);
-}
+
+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();