changeset 754:86f2c0fbadfc

Merge from head
author Thinker K.F. Li <thinker@codemud.net>
date Thu, 26 Aug 2010 13:35:48 +0800
parents cedfe4966fd6 (current diff) ffbf9910213c (diff)
children 82836f1290b6
files
diffstat 4 files changed, 219 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/nodejs/canvas.js	Thu Aug 26 13:35:21 2010 +0800
+++ b/nodejs/canvas.js	Thu Aug 26 13:35:48 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;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nodejs/desktop.svg	Thu Aug 26 13:35:48 2010 +0800
@@ -0,0 +1,108 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+   xmlns:dc="http://purl.org/dc/elements/1.1/"
+   xmlns:cc="http://creativecommons.org/ns#"
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+   xmlns:svg="http://www.w3.org/2000/svg"
+   xmlns="http://www.w3.org/2000/svg"
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+   width="744.09448"
+   height="480"
+   id="svg2"
+   version="1.1"
+   inkscape:version="0.47+devel r9312"
+   sodipodi:docname="desktop.svg">
+  <defs
+     id="defs4" />
+  <sodipodi:namedview
+     id="base"
+     pagecolor="#ffffff"
+     bordercolor="#666666"
+     borderopacity="1.0"
+     inkscape:pageopacity="0.0"
+     inkscape:pageshadow="2"
+     inkscape:zoom="0.98994949"
+     inkscape:cx="375"
+     inkscape:cy="177.14286"
+     inkscape:document-units="px"
+     inkscape:current-layer="layer1"
+     showgrid="false"
+     inkscape:window-width="1920"
+     inkscape:window-height="1006"
+     inkscape:window-x="0"
+     inkscape:window-y="25"
+     inkscape:window-maximized="1" />
+  <metadata
+     id="metadata7">
+    <rdf:RDF>
+      <cc:Work
+         rdf:about="">
+        <dc:format>image/svg+xml</dc:format>
+        <dc:type
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+        <dc:title></dc:title>
+      </cc:Work>
+    </rdf:RDF>
+  </metadata>
+  <g
+     inkscape:label="Layer 1"
+     inkscape:groupmode="layer"
+     id="layer1"
+     transform="translate(0,-572.36218)">
+    <g
+       id="g2917"
+       transform="translate(106.06602,-7.0710678)"
+       mbname="video">
+      <rect
+         transform="translate(0,572.36218)"
+         y="238.57355"
+         x="63.63961"
+         height="74.751289"
+         width="83.842659"
+         id="rect2915"
+         style="fill:#0000ff;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
+    </g>
+    <g
+       id="g2917-8"
+       transform="translate(194.45437,-7.071074)"
+       mbname="audio">
+      <rect
+         transform="translate(0,572.36218)"
+         y="238.57355"
+         x="63.63961"
+         height="74.751289"
+         width="83.842659"
+         id="rect2915-9"
+         style="fill:#0000ff;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
+    </g>
+    <g
+       id="g2917-88"
+       transform="translate(282.59017,-7.0710688)"
+       mbname="picture">
+      <rect
+         transform="translate(0,572.36218)"
+         y="238.57355"
+         x="63.63961"
+         height="74.751289"
+         width="83.842659"
+         id="rect2915-8"
+         style="fill:#0000ff;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
+    </g>
+    <g
+       id="g2917-8-6"
+       transform="translate(370.97852,-7.0710788)"
+       mbname="setting">
+      <rect
+         transform="translate(0,572.36218)"
+         y="238.57355"
+         x="63.63961"
+         height="74.751289"
+         width="83.842659"
+         id="rect2915-9-8"
+         style="fill:#0000ff;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
+    </g>
+  </g>
+</svg>
--- a/nodejs/testcanvas.js	Thu Aug 26 13:35:21 2010 +0800
+++ b/nodejs/testcanvas.js	Thu Aug 26 13:35:48 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();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nodejs/testdesktop.js	Thu Aug 26 13:35:48 2010 +0800
@@ -0,0 +1,47 @@
+var svg = require("./svg");
+var mbapp = require("./mbapp");
+var sys=require("sys");
+var animate=require("./animate");
+var fs = require("fs");
+
+app = new mbapp.app();
+app.loadSVG("desktop.svg");
+
+video = app.get("video");
+audio = app.get("audio");
+picture = app.get("picture");
+setting = app.get("setting");
+items=[video,audio,picture,setting];
+item = 2;
+an = new animate.scale(app,items[item],1,1.5,0.3);
+an.start();
+
+app.addKeyListener(mbapp.KEY_UP, function() {
+	var old = items[item];
+	item = item - 1;
+	if (item == -1) {
+		item = 0;
+		return;
+	}
+    var target = items[item];
+	var an = new animate.scale(app,old,1,1,0.3);
+    an.start();
+	an = new animate.scale(app,target,1,1.5,0.3);
+    an.start();
+});
+
+app.addKeyListener(mbapp.KEY_DOWN, function() {
+	var old = items[item];
+	item = item + 1;
+	if (item == items.length) {
+		item = item - 1;
+		return;
+	}
+    var target = items[item];
+	var an = new animate.scale(app,old,1,1,0.3);
+    an.start();
+	an = new animate.scale(app,target,1,1.5,0.3);
+    an.start();
+});
+
+app.loop();