annotate nodejs/paints.cc @ 570:49e79253b6d3 Android_Skia

Functions of setting/getting stroke width of a shape
author Thinker K.F. Li <thinker@branda.to>
date Wed, 09 Jun 2010 15:10:29 +0800
parents f87a368e847a
children 5a68e2bcea17
rev   line source
567
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
1 #include <v8.h>
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
2
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
3 extern "C" {
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
4 #include "mb.h"
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
5 }
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
6
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
7 #include "mbfly_njs.h"
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
8
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
9 using namespace v8;
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
10
568
d796e6b8b97e Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents: 567
diff changeset
11 #ifndef ASSERT
d796e6b8b97e Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents: 567
diff changeset
12 #define ASSERT(x)
d796e6b8b97e Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents: 567
diff changeset
13 #endif
567
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
14
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
15
569
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
16 /*! \brief Fill a shape with the paint.
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
17 */
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
18 static Handle<Value>
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
19 xnjsmb_paint_fill(const Arguments &args) {
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
20 int argc = args.Length();
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
21 Handle<Object> self = args.This();
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
22 Handle<Object> sh_obj;
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
23 Handle<Object> rt;
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
24 Handle<Value> rt_val;
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
25 paint_t *paint;
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
26 shape_t *sh;
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
27 redraw_man_t *rdman;
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
28
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
29 if(argc != 1)
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
30 THROW("Invalid number of arguments (!= 1)");
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
31 if(!args[0]->IsObject())
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
32 THROW("Invalid argument type (shape)");
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
33
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
34 paint = (paint_t *)UNWRAP(self);
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
35
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
36 sh_obj = args[0]->ToObject();
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
37 sh = (shape_t *)UNWRAP(sh_obj);
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
38
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
39 rt_val = GET(self, "mbrt");
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
40 rt = rt_val->ToObject();
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
41 rdman = xnjsmb_rt_rdman(rt);
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
42
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
43 rdman_paint_fill(rdman, paint, sh);
570
49e79253b6d3 Functions of setting/getting stroke width of a shape
Thinker K.F. Li <thinker@branda.to>
parents: 569
diff changeset
44
49e79253b6d3 Functions of setting/getting stroke width of a shape
Thinker K.F. Li <thinker@branda.to>
parents: 569
diff changeset
45 rdman_shape_changed(rdman, sh);
49e79253b6d3 Functions of setting/getting stroke width of a shape
Thinker K.F. Li <thinker@branda.to>
parents: 569
diff changeset
46
569
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
47 return Null();
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
48 }
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
49
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
50 /*! \brief Stroke a shape with the paint.
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
51 */
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
52 static Handle<Value>
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
53 xnjsmb_paint_stroke(const Arguments &args) {
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
54 int argc = args.Length();
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
55 Handle<Object> self = args.This();
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
56 Handle<Object> sh_obj;
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
57 Handle<Object> rt;
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
58 Handle<Value> rt_val, sh_val;
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
59 paint_t *paint;
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
60 shape_t *sh;
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
61 redraw_man_t *rdman;
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
62
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
63 if(argc != 1)
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
64 THROW("Invalid number of arguments (!= 1)");
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
65 if(!args[0]->IsObject())
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
66 THROW("Invalid argument type (shape)");
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
67
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
68 paint = (paint_t *)UNWRAP(self);
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
69
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
70 sh_val = args[0];
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
71 sh_obj = sh_val->ToObject();
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
72 sh = (shape_t *)UNWRAP(sh_obj);
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
73
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
74 rt_val = GET(self, "mbrt");
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
75 rt = rt_val->ToObject();
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
76 rdman = xnjsmb_rt_rdman(rt);
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
77
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
78 rdman_paint_stroke(rdman, paint, sh);
570
49e79253b6d3 Functions of setting/getting stroke width of a shape
Thinker K.F. Li <thinker@branda.to>
parents: 569
diff changeset
79
49e79253b6d3 Functions of setting/getting stroke width of a shape
Thinker K.F. Li <thinker@branda.to>
parents: 569
diff changeset
80 rdman_shape_changed(rdman, sh);
49e79253b6d3 Functions of setting/getting stroke width of a shape
Thinker K.F. Li <thinker@branda.to>
parents: 569
diff changeset
81
569
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
82 return Null();
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
83 }
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
84
567
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
85 /*! \brief Constructor of color paint_color_t object for Javascript.
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
86 */
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
87 static Handle<Value>
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
88 xnjsmb_paint_color(const Arguments &args) {
568
d796e6b8b97e Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents: 567
diff changeset
89 int argc = args.Length();
d796e6b8b97e Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents: 567
diff changeset
90 Handle<Object> self = args.This();
d796e6b8b97e Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents: 567
diff changeset
91 Handle<Object> rt;
d796e6b8b97e Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents: 567
diff changeset
92 redraw_man_t *rdman;
d796e6b8b97e Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents: 567
diff changeset
93 paint_t *paint;
d796e6b8b97e Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents: 567
diff changeset
94 float r, g, b, a;
d796e6b8b97e Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents: 567
diff changeset
95
d796e6b8b97e Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents: 567
diff changeset
96 if(argc != 5)
d796e6b8b97e Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents: 567
diff changeset
97 THROW("Invalid number of arguments (!= 5)");
d796e6b8b97e Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents: 567
diff changeset
98 if(!args[0]->IsObject() || !args[1]->IsNumber() ||
d796e6b8b97e Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents: 567
diff changeset
99 !args[2]->IsNumber() || !args[3]->IsNumber() ||
d796e6b8b97e Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents: 567
diff changeset
100 !args[4]->IsNumber())
d796e6b8b97e Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents: 567
diff changeset
101 THROW("Invalid argument type");
d796e6b8b97e Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents: 567
diff changeset
102
d796e6b8b97e Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents: 567
diff changeset
103 rt = args[0]->ToObject();
d796e6b8b97e Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents: 567
diff changeset
104 r = args[1]->ToNumber()->Value();
d796e6b8b97e Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents: 567
diff changeset
105 g = args[2]->ToNumber()->Value();
d796e6b8b97e Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents: 567
diff changeset
106 b = args[3]->ToNumber()->Value();
d796e6b8b97e Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents: 567
diff changeset
107 a = args[4]->ToNumber()->Value();
d796e6b8b97e Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents: 567
diff changeset
108
d796e6b8b97e Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents: 567
diff changeset
109 rdman = xnjsmb_rt_rdman(rt);
d796e6b8b97e Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents: 567
diff changeset
110 paint = rdman_paint_color_new(rdman, r, g, b, a);
d796e6b8b97e Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents: 567
diff changeset
111 ASSERT(sh != NULL);
d796e6b8b97e Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents: 567
diff changeset
112
d796e6b8b97e Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents: 567
diff changeset
113 WRAP(self, paint);
569
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
114 SET(self, "mbrt", rt);
568
d796e6b8b97e Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents: 567
diff changeset
115
d796e6b8b97e Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents: 567
diff changeset
116 return Null();
567
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
117 }
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
118
568
d796e6b8b97e Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents: 567
diff changeset
119 static Persistent<FunctionTemplate> xnjsmb_paint_temp;
d796e6b8b97e Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents: 567
diff changeset
120 static Persistent<FunctionTemplate> xnjsmb_paint_color_temp;
567
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
121
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
122 /*! \brief Create and return a paint_color object.
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
123 */
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
124 static Handle<Value>
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
125 xnjsmb_paint_color_new(const Arguments &args) {
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
126 HandleScope scope;
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
127 Handle<Object> rt = args.This();
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
128 Handle<Object> paint_color_obj;
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
129 Handle<Function> paint_color_func;
568
d796e6b8b97e Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents: 567
diff changeset
130 Handle<Value> pc_args[5];
567
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
131 int argc;
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
132 int i;
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
133
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
134 argc = args.Length();
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
135 if(argc != 4)
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
136 THROW("Invalid number of arguments (r, g, b, a)");
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
137 for(i = 0; i < 4; i++)
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
138 if(!args[i]->IsNumber())
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
139 THROW("Invalid argument type");
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
140
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
141 pc_args[0] = rt;
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
142 pc_args[1] = args[0]; // r
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
143 pc_args[2] = args[1]; // g
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
144 pc_args[3] = args[2]; // b
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
145 pc_args[4] = args[3]; // a
568
d796e6b8b97e Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents: 567
diff changeset
146 paint_color_func = xnjsmb_paint_color_temp->GetFunction();
d796e6b8b97e Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents: 567
diff changeset
147 paint_color_obj = paint_color_func->NewInstance(5, pc_args);
567
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
148
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
149 scope.Close(paint_color_obj);
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
150 return paint_color_obj;
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
151 }
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
152
568
d796e6b8b97e Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents: 567
diff changeset
153 static Persistent<FunctionTemplate> xnjsmb_paint_color_new_temp;
567
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
154
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
155 /*! \brief Create templates for paint types.
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
156 *
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
157 * This function is only called one time for every execution.
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
158 */
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
159 static void
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
160 xnjsmb_init_paints(void) {
569
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
161 Handle<FunctionTemplate> temp, meth;
568
d796e6b8b97e Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents: 567
diff changeset
162 Handle<ObjectTemplate> inst_temp;
569
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
163 Handle<ObjectTemplate> proto_temp;
567
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
164
568
d796e6b8b97e Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents: 567
diff changeset
165 /*
d796e6b8b97e Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents: 567
diff changeset
166 * Base type of paint types.
d796e6b8b97e Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents: 567
diff changeset
167 */
d796e6b8b97e Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents: 567
diff changeset
168 temp = FunctionTemplate::New();
d796e6b8b97e Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents: 567
diff changeset
169 xnjsmb_paint_temp = Persistent<FunctionTemplate>::New(temp);
d796e6b8b97e Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents: 567
diff changeset
170 xnjsmb_paint_temp->SetClassName(String::New("paint"));
569
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
171
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
172 meth = FunctionTemplate::New(xnjsmb_paint_fill);
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
173 proto_temp = xnjsmb_paint_temp->PrototypeTemplate();
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
174 SET(proto_temp, "fill", meth);
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
175
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
176 meth = FunctionTemplate::New(xnjsmb_paint_stroke);
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
177 proto_temp = xnjsmb_paint_temp->PrototypeTemplate();
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
178 SET(proto_temp, "stroke", meth);
567
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
179
568
d796e6b8b97e Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents: 567
diff changeset
180 /*
d796e6b8b97e Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents: 567
diff changeset
181 * Paint color
d796e6b8b97e Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents: 567
diff changeset
182 */
567
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
183 temp = FunctionTemplate::New(xnjsmb_paint_color);
568
d796e6b8b97e Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents: 567
diff changeset
184 xnjsmb_paint_color_temp = Persistent<FunctionTemplate>::New(temp);
d796e6b8b97e Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents: 567
diff changeset
185 xnjsmb_paint_color_temp->SetClassName(String::New("paint_color"));
d796e6b8b97e Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents: 567
diff changeset
186 xnjsmb_paint_color_temp->Inherit(xnjsmb_paint_temp);
d796e6b8b97e Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents: 567
diff changeset
187
d796e6b8b97e Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents: 567
diff changeset
188 inst_temp = xnjsmb_paint_color_temp->InstanceTemplate();
d796e6b8b97e Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents: 567
diff changeset
189 inst_temp->SetInternalFieldCount(1);
567
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
190
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
191 temp = FunctionTemplate::New(xnjsmb_paint_color_new);
568
d796e6b8b97e Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents: 567
diff changeset
192 xnjsmb_paint_color_new_temp = Persistent<FunctionTemplate>::New(temp);
567
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
193 }
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
194
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
195 void xnjsmb_paints_init_mb_rt_temp(Handle<FunctionTemplate> rt_temp) {
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
196 static int init_flag = 0;
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
197 Handle<ObjectTemplate> rt_proto_temp;
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
198
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
199 if(!init_flag) {
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
200 xnjsmb_init_paints();
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
201 init_flag = 1;
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
202 }
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
203
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
204 rt_proto_temp = rt_temp->PrototypeTemplate();
568
d796e6b8b97e Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents: 567
diff changeset
205 SET(rt_proto_temp, "paint_color_new", xnjsmb_paint_color_new_temp);
567
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
206 }