Mercurial > MadButterfly
annotate nodejs/paints.cc @ 641:f60d8fa1c55b
Javascript binding for shape_image_t
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Mon, 26 Jul 2010 22:29:33 +0800 |
parents | 714cd6470bd9 |
children | b346e4699e55 |
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 |
576
5a68e2bcea17
Set font styles for stext in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
570
diff
changeset
|
45 if(sh_get_coord(sh)) |
5a68e2bcea17
Set font styles for stext in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
570
diff
changeset
|
46 rdman_shape_changed(rdman, sh); |
570
49e79253b6d3
Functions of setting/getting stroke width of a shape
Thinker K.F. Li <thinker@branda.to>
parents:
569
diff
changeset
|
47 |
569
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
48 return Null(); |
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 |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
51 /*! \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
|
52 */ |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
53 static Handle<Value> |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
54 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
|
55 int argc = args.Length(); |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
56 Handle<Object> self = args.This(); |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
57 Handle<Object> sh_obj; |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
58 Handle<Object> rt; |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
59 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
|
60 paint_t *paint; |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
61 shape_t *sh; |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
62 redraw_man_t *rdman; |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
63 |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
64 if(argc != 1) |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
65 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
|
66 if(!args[0]->IsObject()) |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
67 THROW("Invalid argument type (shape)"); |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
68 |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
69 paint = (paint_t *)UNWRAP(self); |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
70 |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
71 sh_val = args[0]; |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
72 sh_obj = sh_val->ToObject(); |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
73 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
|
74 |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
75 rt_val = GET(self, "mbrt"); |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
76 rt = rt_val->ToObject(); |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
77 rdman = xnjsmb_rt_rdman(rt); |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
78 |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
79 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
|
80 |
576
5a68e2bcea17
Set font styles for stext in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
570
diff
changeset
|
81 if(sh_get_coord(sh)) |
5a68e2bcea17
Set font styles for stext in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
570
diff
changeset
|
82 rdman_shape_changed(rdman, sh); |
570
49e79253b6d3
Functions of setting/getting stroke width of a shape
Thinker K.F. Li <thinker@branda.to>
parents:
569
diff
changeset
|
83 |
569
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
84 return Null(); |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
85 } |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
86 |
567
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
87 /*! \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
|
88 */ |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
89 static Handle<Value> |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
90 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
|
91 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
|
92 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
|
93 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
|
94 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
|
95 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
|
96 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
|
97 |
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(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
|
99 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
|
100 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
|
101 !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
|
102 !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
|
103 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
|
104 |
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 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
|
106 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
|
107 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
|
108 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
|
109 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
|
110 |
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 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
|
112 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
|
113 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
|
114 |
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 WRAP(self, paint); |
569
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
116 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
|
117 |
d796e6b8b97e
Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents:
567
diff
changeset
|
118 return Null(); |
567
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
119 } |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
120 |
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
|
121 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
|
122 static Persistent<FunctionTemplate> xnjsmb_paint_color_temp; |
567
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 /*! \brief Create and return a paint_color object. |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
125 */ |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
126 static Handle<Value> |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
127 xnjsmb_paint_color_new(const Arguments &args) { |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
128 HandleScope scope; |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
129 Handle<Object> rt = args.This(); |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
130 Handle<Object> paint_color_obj; |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
131 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
|
132 Handle<Value> pc_args[5]; |
567
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
133 int argc; |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
134 int i; |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
135 |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
136 argc = args.Length(); |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
137 if(argc != 4) |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
138 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
|
139 for(i = 0; i < 4; i++) |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
140 if(!args[i]->IsNumber()) |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
141 THROW("Invalid argument type"); |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
142 |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
143 pc_args[0] = rt; |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
144 pc_args[1] = args[0]; // r |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
145 pc_args[2] = args[1]; // g |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
146 pc_args[3] = args[2]; // b |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
147 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
|
148 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
|
149 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
|
150 |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
151 scope.Close(paint_color_obj); |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
152 return paint_color_obj; |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
153 } |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
154 |
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
|
155 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
|
156 |
636
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
157 /*! \brief Constructor of paint_image_t objects for Javascript. |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
158 */ |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
159 static Handle<Value> |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
160 xnjsmb_paint_image(const Arguments &args) { |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
161 int argc = args.Length(); |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
162 Handle<Object> rt; |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
163 Handle<Object> self = args.This(); |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
164 Handle<Object> img_obj; |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
165 redraw_man_t *rdman; |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
166 mb_img_data_t *img; |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
167 paint_t *paint; |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
168 |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
169 if(argc != 2) |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
170 THROW("Invalid number of arguments (!= 2)"); |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
171 if(!args[0]->IsObject() || !args[1]->IsObject()) |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
172 THROW("Invalid argument type"); |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
173 |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
174 rt = args[0]->ToObject(); |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
175 img_obj = args[1]->ToObject(); |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
176 |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
177 rdman = xnjsmb_rt_rdman(rt); |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
178 img = (mb_img_data_t *)UNWRAP(img_obj); |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
179 |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
180 paint = rdman_paint_image_new(rdman, img); |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
181 ASSERT(paint != NULL); |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
182 |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
183 WRAP(self, paint); |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
184 SET(self, "mbrt", rt); |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
185 |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
186 return Null(); |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
187 } |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
188 |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
189 static Persistent<FunctionTemplate> xnjsmb_paint_image_temp; |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
190 |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
191 /*! \brief Create and return a paint_image object. |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
192 */ |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
193 static Handle<Value> |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
194 xnjsmb_paint_image_new(const Arguments &args) { |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
195 int argc = args.Length(); |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
196 HandleScope scope; |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
197 Handle<Object> rt = args.This(); |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
198 Handle<Object> paint_image_obj; |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
199 Handle<Value> pi_args[2]; |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
200 Handle<Function> paint_image_func; |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
201 |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
202 if(argc != 1) |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
203 THROW("Invalid number of arguments (!= 2)"); |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
204 if(!args[0]->IsObject()) |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
205 THROW("Invalid argument type"); |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
206 |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
207 pi_args[0] = rt; |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
208 pi_args[1] = args[0]; // image |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
209 paint_image_func = xnjsmb_paint_image_temp->GetFunction(); |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
210 paint_image_obj = paint_image_func->NewInstance(2, pi_args); |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
211 |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
212 scope.Close(paint_image_obj); |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
213 return paint_image_obj; |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
214 } |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
215 |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
216 static Persistent<FunctionTemplate> xnjsmb_paint_image_new_temp; |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
217 |
567
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
218 /*! \brief Create templates for paint types. |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
219 * |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
220 * 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
|
221 */ |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
222 static void |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
223 xnjsmb_init_paints(void) { |
569
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
224 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
|
225 Handle<ObjectTemplate> inst_temp; |
569
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
226 Handle<ObjectTemplate> proto_temp; |
567
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
227 |
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
|
228 /* |
d796e6b8b97e
Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents:
567
diff
changeset
|
229 * 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
|
230 */ |
d796e6b8b97e
Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents:
567
diff
changeset
|
231 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
|
232 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
|
233 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
|
234 |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
235 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
|
236 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
|
237 SET(proto_temp, "fill", meth); |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
238 |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
239 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
|
240 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
|
241 SET(proto_temp, "stroke", meth); |
567
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
242 |
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
|
243 /* |
d796e6b8b97e
Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents:
567
diff
changeset
|
244 * 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
|
245 */ |
567
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
246 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
|
247 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
|
248 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
|
249 xnjsmb_paint_color_temp->Inherit(xnjsmb_paint_temp); |
636
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
250 |
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
|
251 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
|
252 inst_temp->SetInternalFieldCount(1); |
567
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
253 |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
254 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
|
255 xnjsmb_paint_color_new_temp = Persistent<FunctionTemplate>::New(temp); |
636
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
256 |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
257 /* |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
258 * Paint image |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
259 */ |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
260 temp = FunctionTemplate::New(xnjsmb_paint_image); |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
261 xnjsmb_paint_image_temp = Persistent<FunctionTemplate>::New(temp); |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
262 xnjsmb_paint_image_temp->SetClassName(String::New("paint_image")); |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
263 xnjsmb_paint_image_temp->Inherit(xnjsmb_paint_temp); |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
264 |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
265 inst_temp = xnjsmb_paint_image_temp->InstanceTemplate(); |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
266 inst_temp->SetInternalFieldCount(1); |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
267 |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
268 temp = FunctionTemplate::New(xnjsmb_paint_image_new); |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
269 xnjsmb_paint_image_new_temp = Persistent<FunctionTemplate>::New(temp); |
567
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
270 } |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
271 |
637
714cd6470bd9
Doc on xnjsmb_paints_init_mb_rt_temp()
Thinker K.F. Li <thinker@branda.to>
parents:
636
diff
changeset
|
272 /*! \brief Initialize paints for mbfly. |
714cd6470bd9
Doc on xnjsmb_paints_init_mb_rt_temp()
Thinker K.F. Li <thinker@branda.to>
parents:
636
diff
changeset
|
273 * |
714cd6470bd9
Doc on xnjsmb_paints_init_mb_rt_temp()
Thinker K.F. Li <thinker@branda.to>
parents:
636
diff
changeset
|
274 * This function is called by init() in mbfly_njs.cc when the module |
714cd6470bd9
Doc on xnjsmb_paints_init_mb_rt_temp()
Thinker K.F. Li <thinker@branda.to>
parents:
636
diff
changeset
|
275 * being loaded. |
714cd6470bd9
Doc on xnjsmb_paints_init_mb_rt_temp()
Thinker K.F. Li <thinker@branda.to>
parents:
636
diff
changeset
|
276 */ |
567
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
277 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
|
278 static int init_flag = 0; |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
279 Handle<ObjectTemplate> rt_proto_temp; |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
280 |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
281 if(!init_flag) { |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
282 xnjsmb_init_paints(); |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
283 init_flag = 1; |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
284 } |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
285 |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
286 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
|
287 SET(rt_proto_temp, "paint_color_new", xnjsmb_paint_color_new_temp); |
636
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
288 SET(rt_proto_temp, "paint_image_new", xnjsmb_paint_image_new_temp); |
567
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
289 } |