Mercurial > MadButterfly
annotate nodejs/paints.cc @ 765:a49358b040b5
Doc on how to manage life-cycle of paints for JS
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Sun, 29 Aug 2010 00:42:16 +0800 |
parents | d0ee92a96c47 |
children | be0e02948c1d |
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 |
684
b346e4699e55
Add more comment for JS binding
Thinker K.F. Li <thinker@branda.to>
parents:
637
diff
changeset
|
15 /*! \defgroup xnjsmb_paints JS binding for paints |
b346e4699e55
Add more comment for JS binding
Thinker K.F. Li <thinker@branda.to>
parents:
637
diff
changeset
|
16 * \ingroup xnjsmb |
b346e4699e55
Add more comment for JS binding
Thinker K.F. Li <thinker@branda.to>
parents:
637
diff
changeset
|
17 * |
b346e4699e55
Add more comment for JS binding
Thinker K.F. Li <thinker@branda.to>
parents:
637
diff
changeset
|
18 * @{ |
b346e4699e55
Add more comment for JS binding
Thinker K.F. Li <thinker@branda.to>
parents:
637
diff
changeset
|
19 */ |
567
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
20 |
765
a49358b040b5
Doc on how to manage life-cycle of paints for JS
Thinker K.F. Li <thinker@codemud.net>
parents:
735
diff
changeset
|
21 /*! \page paint_gc How to manage life-cycle of paints? |
a49358b040b5
Doc on how to manage life-cycle of paints for JS
Thinker K.F. Li <thinker@codemud.net>
parents:
735
diff
changeset
|
22 * |
a49358b040b5
Doc on how to manage life-cycle of paints for JS
Thinker K.F. Li <thinker@codemud.net>
parents:
735
diff
changeset
|
23 * A paint is used to fill and stroke shapes. It should keep live |
a49358b040b5
Doc on how to manage life-cycle of paints for JS
Thinker K.F. Li <thinker@codemud.net>
parents:
735
diff
changeset
|
24 * before all shapes being stroked/or filled by it are dead or |
a49358b040b5
Doc on how to manage life-cycle of paints for JS
Thinker K.F. Li <thinker@codemud.net>
parents:
735
diff
changeset
|
25 * filled/stroked by other paints. So, every shape that uses a paint |
a49358b040b5
Doc on how to manage life-cycle of paints for JS
Thinker K.F. Li <thinker@codemud.net>
parents:
735
diff
changeset
|
26 * should keep a reference to the paint. The reference are removed |
a49358b040b5
Doc on how to manage life-cycle of paints for JS
Thinker K.F. Li <thinker@codemud.net>
parents:
735
diff
changeset
|
27 * when a shape is filled/or stroked by other paints. |
a49358b040b5
Doc on how to manage life-cycle of paints for JS
Thinker K.F. Li <thinker@codemud.net>
parents:
735
diff
changeset
|
28 * |
a49358b040b5
Doc on how to manage life-cycle of paints for JS
Thinker K.F. Li <thinker@codemud.net>
parents:
735
diff
changeset
|
29 * A paint should keep a weak reference to itself. It is used to free |
a49358b040b5
Doc on how to manage life-cycle of paints for JS
Thinker K.F. Li <thinker@codemud.net>
parents:
735
diff
changeset
|
30 * resource before it being collected. |
a49358b040b5
Doc on how to manage life-cycle of paints for JS
Thinker K.F. Li <thinker@codemud.net>
parents:
735
diff
changeset
|
31 */ |
687
da12923a789a
Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
684
diff
changeset
|
32 static void |
da12923a789a
Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
684
diff
changeset
|
33 xnjsmb_paint_fill(paint_t *paint, Handle<Object> self, shape_t *sh) { |
da12923a789a
Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
684
diff
changeset
|
34 Handle<Value> rt_v; |
da12923a789a
Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
684
diff
changeset
|
35 Handle<Object> rt_o; |
569
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
36 redraw_man_t *rdman; |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
37 |
687
da12923a789a
Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
684
diff
changeset
|
38 rt_v = GET(self, "mbrt"); |
da12923a789a
Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
684
diff
changeset
|
39 rt_o = rt_v->ToObject(); |
da12923a789a
Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
684
diff
changeset
|
40 rdman = xnjsmb_rt_rdman(rt_o); |
569
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
41 |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
42 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
|
43 |
576
5a68e2bcea17
Set font styles for stext in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
570
diff
changeset
|
44 if(sh_get_coord(sh)) |
5a68e2bcea17
Set font styles for stext in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
570
diff
changeset
|
45 rdman_shape_changed(rdman, sh); |
569
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
46 } |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
47 |
687
da12923a789a
Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
684
diff
changeset
|
48 static void |
da12923a789a
Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
684
diff
changeset
|
49 xnjsmb_paint_stroke(paint_t *paint, Handle<Object> self, shape_t *sh) { |
da12923a789a
Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
684
diff
changeset
|
50 Handle<Value> rt_v; |
da12923a789a
Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
684
diff
changeset
|
51 Handle<Object> rt_o; |
569
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
52 redraw_man_t *rdman; |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
53 |
687
da12923a789a
Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
684
diff
changeset
|
54 rt_v = GET(self, "mbrt"); |
da12923a789a
Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
684
diff
changeset
|
55 rt_o = rt_v->ToObject(); |
da12923a789a
Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
684
diff
changeset
|
56 rdman = xnjsmb_rt_rdman(rt_o); |
569
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
57 |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
58 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
|
59 |
576
5a68e2bcea17
Set font styles for stext in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
570
diff
changeset
|
60 if(sh_get_coord(sh)) |
5a68e2bcea17
Set font styles for stext in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
570
diff
changeset
|
61 rdman_shape_changed(rdman, sh); |
569
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 |
699
0b98bdc53215
Add binding for color changing of paint_color_t in JS
Thinker K.F. Li <thinker@branda.to>
parents:
687
diff
changeset
|
64 static void |
0b98bdc53215
Add binding for color changing of paint_color_t in JS
Thinker K.F. Li <thinker@branda.to>
parents:
687
diff
changeset
|
65 xnjsmb_paint_color_set_color(paint_t *paint, Handle<Object> self, |
0b98bdc53215
Add binding for color changing of paint_color_t in JS
Thinker K.F. Li <thinker@branda.to>
parents:
687
diff
changeset
|
66 float r, float g, float b, float a) { |
0b98bdc53215
Add binding for color changing of paint_color_t in JS
Thinker K.F. Li <thinker@branda.to>
parents:
687
diff
changeset
|
67 Handle<Value> rt_v; |
0b98bdc53215
Add binding for color changing of paint_color_t in JS
Thinker K.F. Li <thinker@branda.to>
parents:
687
diff
changeset
|
68 Handle<Object> rt_o; |
0b98bdc53215
Add binding for color changing of paint_color_t in JS
Thinker K.F. Li <thinker@branda.to>
parents:
687
diff
changeset
|
69 redraw_man_t *rdman; |
0b98bdc53215
Add binding for color changing of paint_color_t in JS
Thinker K.F. Li <thinker@branda.to>
parents:
687
diff
changeset
|
70 |
0b98bdc53215
Add binding for color changing of paint_color_t in JS
Thinker K.F. Li <thinker@branda.to>
parents:
687
diff
changeset
|
71 rt_v = GET(self, "mbrt"); |
0b98bdc53215
Add binding for color changing of paint_color_t in JS
Thinker K.F. Li <thinker@branda.to>
parents:
687
diff
changeset
|
72 rt_o = rt_v->ToObject(); |
0b98bdc53215
Add binding for color changing of paint_color_t in JS
Thinker K.F. Li <thinker@branda.to>
parents:
687
diff
changeset
|
73 rdman = xnjsmb_rt_rdman(rt_o); |
0b98bdc53215
Add binding for color changing of paint_color_t in JS
Thinker K.F. Li <thinker@branda.to>
parents:
687
diff
changeset
|
74 |
0b98bdc53215
Add binding for color changing of paint_color_t in JS
Thinker K.F. Li <thinker@branda.to>
parents:
687
diff
changeset
|
75 paint_color_set(paint, r, g, b, a); |
0b98bdc53215
Add binding for color changing of paint_color_t in JS
Thinker K.F. Li <thinker@branda.to>
parents:
687
diff
changeset
|
76 |
0b98bdc53215
Add binding for color changing of paint_color_t in JS
Thinker K.F. Li <thinker@branda.to>
parents:
687
diff
changeset
|
77 rdman_paint_changed(rdman, paint); |
0b98bdc53215
Add binding for color changing of paint_color_t in JS
Thinker K.F. Li <thinker@branda.to>
parents:
687
diff
changeset
|
78 } |
0b98bdc53215
Add binding for color changing of paint_color_t in JS
Thinker K.F. Li <thinker@branda.to>
parents:
687
diff
changeset
|
79 |
733
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
80 /*! \brief Set stops for linear paint for Javascript code. |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
81 */ |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
82 static void |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
83 xnjsmb_paint_linear_set_stops(paint_t *paint, Handle<Value> stops) { |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
84 Array *stops_o; |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
85 Array *stop_o; |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
86 int nstops; |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
87 grad_stop_t *grad_stops, *old_grad_stops; |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
88 int i; |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
89 |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
90 stops_o = Array::Cast(*stops); |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
91 nstops = stops_o->Length(); |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
92 grad_stops = (grad_stop_t *)malloc(sizeof(grad_stop_t) * nstops); |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
93 ASSERT(grad_stops != NULL); |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
94 |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
95 for(i = 0; i < nstops; i++) { |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
96 stop_o = Array::Cast(*stops_o->Get(i)); |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
97 ASSERT(stop_o->Length() == 5); |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
98 grad_stop_init(grad_stops + i, |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
99 stop_o->Get(0)->ToNumber()->Value(), /* off */ |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
100 stop_o->Get(1)->ToNumber()->Value(), /* r */ |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
101 stop_o->Get(2)->ToNumber()->Value(), /* g */ |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
102 stop_o->Get(3)->ToNumber()->Value(), /* b */ |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
103 stop_o->Get(4)->ToNumber()->Value()); /* a */ |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
104 } |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
105 |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
106 old_grad_stops = paint_linear_stops(paint, nstops, grad_stops); |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
107 if(old_grad_stops) |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
108 free(old_grad_stops); /* The stops, here, were allocated for |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
109 * previous calling of this |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
110 * function. */ |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
111 } |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
112 |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
113 /*! \brief Set stops for radial paint for Javascript code. |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
114 */ |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
115 static void |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
116 xnjsmb_paint_radial_set_stops(paint_t *paint, Handle<Value> stops) { |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
117 Array *stops_o; |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
118 Array *stop_o; |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
119 int nstops; |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
120 grad_stop_t *grad_stops, *old_grad_stops; |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
121 int i; |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
122 |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
123 stops_o = Array::Cast(*stops); |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
124 nstops = stops_o->Length(); |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
125 grad_stops = (grad_stop_t *)malloc(sizeof(grad_stop_t) * nstops); |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
126 ASSERT(grad_stops != NULL); |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
127 |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
128 for(i = 0; i < nstops; i++) { |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
129 stop_o = Array::Cast(*stops_o->Get(i)); |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
130 ASSERT(stop_o->Length() == 5); |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
131 grad_stop_init(grad_stops + i, |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
132 stop_o->Get(0)->ToNumber()->Value(), /* off */ |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
133 stop_o->Get(1)->ToNumber()->Value(), /* r */ |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
134 stop_o->Get(2)->ToNumber()->Value(), /* g */ |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
135 stop_o->Get(3)->ToNumber()->Value(), /* b */ |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
136 stop_o->Get(4)->ToNumber()->Value()); /* a */ |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
137 } |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
138 |
735
d0ee92a96c47
Fix typo and add initialize code for linear and radial
Thinker K.F. Li <thinker@branda.to>
parents:
733
diff
changeset
|
139 old_grad_stops = paint_radial_stops(paint, nstops, grad_stops); |
733
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
140 if(old_grad_stops) |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
141 free(old_grad_stops); /* The stops, here, were allocated for |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
142 * previous calling of this |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
143 * function. */ |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
144 } |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
145 |
687
da12923a789a
Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
684
diff
changeset
|
146 #include "paints-inc.h" |
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
|
147 |
687
da12923a789a
Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
684
diff
changeset
|
148 /*! \defgroup xnjsmb_paints_cons Constructor of paints |
da12923a789a
Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
684
diff
changeset
|
149 * |
da12923a789a
Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
684
diff
changeset
|
150 * @{ |
567
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
151 */ |
687
da12923a789a
Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
684
diff
changeset
|
152 paint_t * |
da12923a789a
Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
684
diff
changeset
|
153 xnjsmb_paint_color_new(njs_runtime_t *rt, |
da12923a789a
Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
684
diff
changeset
|
154 float r, float g, float b, float a, |
da12923a789a
Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
684
diff
changeset
|
155 const char **err) { |
da12923a789a
Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
684
diff
changeset
|
156 paint_t *paint; |
da12923a789a
Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
684
diff
changeset
|
157 redraw_man_t *rdman; |
567
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
158 |
687
da12923a789a
Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
684
diff
changeset
|
159 rdman = X_njs_MB_rdman(rt); |
da12923a789a
Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
684
diff
changeset
|
160 paint = rdman_paint_color_new(rdman, r, g, b, a); |
da12923a789a
Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
684
diff
changeset
|
161 if(paint == NULL) { |
da12923a789a
Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
684
diff
changeset
|
162 *err = "can not allocate a paint_color_t"; |
da12923a789a
Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
684
diff
changeset
|
163 return NULL; |
da12923a789a
Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
684
diff
changeset
|
164 } |
567
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
165 |
687
da12923a789a
Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
684
diff
changeset
|
166 return paint; |
567
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
167 } |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
168 |
687
da12923a789a
Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
684
diff
changeset
|
169 paint_t * |
da12923a789a
Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
684
diff
changeset
|
170 xnjsmb_paint_image_new(njs_runtime_t *rt, mb_img_data_t *img, |
da12923a789a
Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
684
diff
changeset
|
171 const char **err) { |
da12923a789a
Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
684
diff
changeset
|
172 paint_t *paint; |
636
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
173 redraw_man_t *rdman; |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
174 |
687
da12923a789a
Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
684
diff
changeset
|
175 rdman = X_njs_MB_rdman(rt); |
da12923a789a
Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
684
diff
changeset
|
176 paint = rdman_paint_image_new(rdman, img); |
da12923a789a
Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
684
diff
changeset
|
177 if(paint == NULL) { |
da12923a789a
Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
684
diff
changeset
|
178 *err = "can not allocate a paint_image_t"; |
da12923a789a
Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
684
diff
changeset
|
179 return NULL; |
da12923a789a
Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
684
diff
changeset
|
180 } |
636
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
181 |
687
da12923a789a
Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
684
diff
changeset
|
182 return paint; |
636
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
183 } |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
184 |
733
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
185 paint_t * |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
186 xnjsmb_paint_linear_new(njs_runtime_t *rt, |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
187 float x1, float y1, float x2, float y2, |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
188 const char **err) { |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
189 paint_t *paint; |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
190 redraw_man_t *rdman; |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
191 |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
192 rdman = X_njs_MB_rdman(rt); |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
193 paint = rdman_paint_linear_new(rdman, x1, y1, x2, y2); |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
194 if(paint == NULL) { |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
195 *err = "can not allocate a paint_linear_t"; |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
196 return NULL; |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
197 } |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
198 |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
199 return paint; |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
200 } |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
201 |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
202 paint_t * |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
203 xnjsmb_paint_radial_new(njs_runtime_t *rt, |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
204 float cx, float cy, float r, |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
205 const char **err) { |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
206 paint_t *paint; |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
207 redraw_man_t *rdman; |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
208 |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
209 rdman = X_njs_MB_rdman(rt); |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
210 paint = rdman_paint_radial_new(rdman, cx, cy, r); |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
211 if(paint == NULL) { |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
212 *err = "can not allocate a paint_radial_t"; |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
213 return NULL; |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
214 } |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
215 |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
216 return paint; |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
217 } |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
218 |
687
da12923a789a
Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
684
diff
changeset
|
219 /* @} */ |
636
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
220 |
687
da12923a789a
Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
684
diff
changeset
|
221 /*! \defgroup xnjsmb_paints_export Exported wrapper maker for paints |
da12923a789a
Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
684
diff
changeset
|
222 * |
da12923a789a
Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
684
diff
changeset
|
223 * These functions are used by MB runtime to wrap C paints to JS |
da12923a789a
Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
684
diff
changeset
|
224 * objects. |
da12923a789a
Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
684
diff
changeset
|
225 * |
da12923a789a
Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
684
diff
changeset
|
226 * @{ |
da12923a789a
Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
684
diff
changeset
|
227 */ |
da12923a789a
Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
684
diff
changeset
|
228 Handle<Value> |
da12923a789a
Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
684
diff
changeset
|
229 export_xnjsmb_auto_paint_color_new(paint_t *paint) { |
da12923a789a
Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
684
diff
changeset
|
230 Handle<Value> ret; |
da12923a789a
Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
684
diff
changeset
|
231 |
da12923a789a
Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
684
diff
changeset
|
232 ret = xnjsmb_auto_paint_color_new(paint); |
da12923a789a
Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
684
diff
changeset
|
233 |
da12923a789a
Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
684
diff
changeset
|
234 return ret; |
636
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
235 } |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
236 |
687
da12923a789a
Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
684
diff
changeset
|
237 Handle<Value> |
da12923a789a
Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
684
diff
changeset
|
238 export_xnjsmb_auto_paint_image_new(paint_t *paint) { |
da12923a789a
Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
684
diff
changeset
|
239 Handle<Value> ret; |
569
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
240 |
687
da12923a789a
Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
684
diff
changeset
|
241 ret = xnjsmb_auto_paint_image_new(paint); |
636
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
242 |
687
da12923a789a
Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
684
diff
changeset
|
243 return ret; |
567
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
244 } |
733
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
245 |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
246 Handle<Value> |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
247 export_xnjsmb_auto_paint_linear_new(paint_t *paint) { |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
248 Handle<Value> ret; |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
249 |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
250 ret = xnjsmb_auto_paint_linear_new(paint); |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
251 |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
252 return ret; |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
253 } |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
254 |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
255 Handle<Value> |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
256 export_xnjsmb_auto_paint_radial_new(paint_t *paint) { |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
257 Handle<Value> ret; |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
258 |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
259 ret = xnjsmb_auto_paint_radial_new(paint); |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
260 |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
261 return ret; |
163f0d9e6382
Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents:
699
diff
changeset
|
262 } |
687
da12923a789a
Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
684
diff
changeset
|
263 /* @} */ |
567
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
264 |
637
714cd6470bd9
Doc on xnjsmb_paints_init_mb_rt_temp()
Thinker K.F. Li <thinker@branda.to>
parents:
636
diff
changeset
|
265 /*! \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
|
266 * |
714cd6470bd9
Doc on xnjsmb_paints_init_mb_rt_temp()
Thinker K.F. Li <thinker@branda.to>
parents:
636
diff
changeset
|
267 * 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
|
268 * being loaded. |
714cd6470bd9
Doc on xnjsmb_paints_init_mb_rt_temp()
Thinker K.F. Li <thinker@branda.to>
parents:
636
diff
changeset
|
269 */ |
567
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
270 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
|
271 static int init_flag = 0; |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
272 Handle<ObjectTemplate> rt_proto_temp; |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
273 |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
274 if(!init_flag) { |
687
da12923a789a
Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
684
diff
changeset
|
275 xnjsmb_auto_paint_init(); |
da12923a789a
Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
684
diff
changeset
|
276 xnjsmb_auto_paint_color_init(); |
da12923a789a
Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
684
diff
changeset
|
277 xnjsmb_auto_paint_image_init(); |
735
d0ee92a96c47
Fix typo and add initialize code for linear and radial
Thinker K.F. Li <thinker@branda.to>
parents:
733
diff
changeset
|
278 xnjsmb_auto_paint_linear_init(); |
d0ee92a96c47
Fix typo and add initialize code for linear and radial
Thinker K.F. Li <thinker@branda.to>
parents:
733
diff
changeset
|
279 xnjsmb_auto_paint_radial_init(); |
687
da12923a789a
Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
684
diff
changeset
|
280 |
567
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
281 init_flag = 1; |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
282 } |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
283 } |
684
b346e4699e55
Add more comment for JS binding
Thinker K.F. Li <thinker@branda.to>
parents:
637
diff
changeset
|
284 |
b346e4699e55
Add more comment for JS binding
Thinker K.F. Li <thinker@branda.to>
parents:
637
diff
changeset
|
285 /* @} */ |