comparison nodejs/canvas.js @ 1067:7b4e80ab671a openvg

merge from default branch
author Thinker K.F. Li <thinker@codemud.net>
date Wed, 01 Dec 2010 12:25:56 +0800
parents 586e50f82c1f
children
comparison
equal deleted inserted replaced
630:bd18951b51d5 1067:7b4e80ab671a
1 // -*- indent-tabs-mode: t; tab-width: 8; c-basic-offset: 4; -*-
2 // vim: sw=4:ts=8:sts=4
3 var mbfly = require("mbfly");
4 var sys=require("sys");
5
6
7 function canvas(app,root) {
8 this.mb_rt = app.mb_rt;
9 this.parent = root;
10 this.root = this.mb_rt.coord_new(root);
11 this.bg_r = 0;
12 this.bg_g = 0;
13 this.bg_b = 0;
14 this.bg_a = 0;
15 this.stroke_r = 0;
16 this.stroke_g = 0;
17 this.stroke_b = 0;
18 this.stroke_a = 0;
19 this.stroke_w = 1;
20 }
21
22 canvas.prototype.background=function(r,g,b,a) {
23 this.bg_r = r;
24 this.bg_g = g;
25 this.bg_b = b;
26 this.bg_a = a;
27 }
28
29 canvas.prototype.rect=function(x,y,w,h) {
30 var rect = this.mb_rt.rect_new(x,y,w,h,0,0);
31 var paint = this.mb_rt.paint_color_new(this.bg_r,this.bg_g,this.bg_b,this.bg_a);
32 paint.fill(rect);
33 this.root.add_shape(rect);
34 }
35
36 canvas.prototype.stroke=function(r,g,b,a) {
37 this.stroke_r = r;
38 this.stroke_g = g;
39 this.stroke_b = b;
40 this.stroke_a = a;
41 }
42
43
44 canvas.prototype.line=function(x1,y1,x2,y2) {
45 var s = "M "+x1+","+y1+" L "+x2+","+y2;
46 //sys.puts(s);
47
48 var p = this.mb_rt.path_new(s);
49 this.root.add_shape(p);
50 var paint = this.mb_rt.paint_color_new(this.stroke_r,this.stroke_g,this.stroke_b,this.stroke_a);
51 paint.stroke(p);
52 p.stroke_width = this.stroke_w;
53 }
54
55 canvas.prototype.strokeWeight=function(w) {
56 this.stroke_w = w;
57 }
58
59 canvas.prototype.alpha=function(c) {
60 }
61
62 canvas.prototype.red=function(c) {
63 }
64 canvas.prototype.green=function(c) {
65 }
66 canvas.prototype.blue=function(c) {
67 }
68
69
70 canvas.prototype.clear=function() {
71 this.root.remove();
72 this.root = this.mb_rt.coord_new(this.parent);
73 }
74
75 canvas.prototype.arc=function(x,y,w,h,start,end) {
76 }
77
78 canvas.prototype.ellipse=function(x, y, width, height) {
79 }
80
81 canvas.prototype.point=function(x,y) {
82 }
83
84 canvas.prototype.quad=function(x1,y1,x2,y2,x3,y3,x4,y4) {
85 }
86
87 canvas.prototype.triangle=function(x1,y1,x2,y2,x3,y3) {
88 }
89
90 canvas.prototype.bezier=function(x1, y1, cx1, cy1, cx2, cy2, x2, y2) {
91 }
92
93 canvas.prototype.curveTightness=function(squishy) {
94 }
95
96 canvas.prototype.colorMode=function() {
97 }
98
99 canvas.prototype.fill=function(color) {
100 }
101
102 canvas.prototype.noFill=function() {
103 }
104
105 canvas.prototype.noStroke=function() {
106 }
107
108
109 exports.canvas = canvas;