annotate nodejs/paints.cc @ 766:be0e02948c1d

Improve resource management for coords, shapes and paints. - Make paint to use weak reference to release resource before collected. - Call Persistent<Object>::Dispose() before deleting the handle variable. Dispose() will real release Persistent handle. Handle variable is just a pointer to the handle.
author Thinker K.F. Li <thinker@codemud.net>
date Sun, 29 Aug 2010 13:34:40 +0800
parents a49358b040b5
children 01b514800fbe
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
766
be0e02948c1d Improve resource management for coords, shapes and paints.
Thinker K.F. Li <thinker@codemud.net>
parents: 765
diff changeset
33 xnjsmb_paint_recycle(Persistent<Value> obj, void *parameter) {
be0e02948c1d Improve resource management for coords, shapes and paints.
Thinker K.F. Li <thinker@codemud.net>
parents: 765
diff changeset
34 Persistent<Object> *paint_hdl = (Persistent<Object> *)parameter;
be0e02948c1d Improve resource management for coords, shapes and paints.
Thinker K.F. Li <thinker@codemud.net>
parents: 765
diff changeset
35 paint_t *paint;
be0e02948c1d Improve resource management for coords, shapes and paints.
Thinker K.F. Li <thinker@codemud.net>
parents: 765
diff changeset
36 Handle<Object> rt;
be0e02948c1d Improve resource management for coords, shapes and paints.
Thinker K.F. Li <thinker@codemud.net>
parents: 765
diff changeset
37 redraw_man_t *rdman;
be0e02948c1d Improve resource management for coords, shapes and paints.
Thinker K.F. Li <thinker@codemud.net>
parents: 765
diff changeset
38
be0e02948c1d Improve resource management for coords, shapes and paints.
Thinker K.F. Li <thinker@codemud.net>
parents: 765
diff changeset
39 paint = (paint_t *)UNWRAP(*paint_hdl);
be0e02948c1d Improve resource management for coords, shapes and paints.
Thinker K.F. Li <thinker@codemud.net>
parents: 765
diff changeset
40 rt = GET(*paint_hdl, "mbrt")->ToObject();
be0e02948c1d Improve resource management for coords, shapes and paints.
Thinker K.F. Li <thinker@codemud.net>
parents: 765
diff changeset
41 rdman = xnjsmb_rt_rdman(rt);
be0e02948c1d Improve resource management for coords, shapes and paints.
Thinker K.F. Li <thinker@codemud.net>
parents: 765
diff changeset
42
be0e02948c1d Improve resource management for coords, shapes and paints.
Thinker K.F. Li <thinker@codemud.net>
parents: 765
diff changeset
43 rdman_paint_free(rdman, paint);
be0e02948c1d Improve resource management for coords, shapes and paints.
Thinker K.F. Li <thinker@codemud.net>
parents: 765
diff changeset
44
be0e02948c1d Improve resource management for coords, shapes and paints.
Thinker K.F. Li <thinker@codemud.net>
parents: 765
diff changeset
45 paint_hdl->Dispose();
be0e02948c1d Improve resource management for coords, shapes and paints.
Thinker K.F. Li <thinker@codemud.net>
parents: 765
diff changeset
46 delete paint_hdl;
be0e02948c1d Improve resource management for coords, shapes and paints.
Thinker K.F. Li <thinker@codemud.net>
parents: 765
diff changeset
47 }
be0e02948c1d Improve resource management for coords, shapes and paints.
Thinker K.F. Li <thinker@codemud.net>
parents: 765
diff changeset
48
be0e02948c1d Improve resource management for coords, shapes and paints.
Thinker K.F. Li <thinker@codemud.net>
parents: 765
diff changeset
49 static void
be0e02948c1d Improve resource management for coords, shapes and paints.
Thinker K.F. Li <thinker@codemud.net>
parents: 765
diff changeset
50 xnjsmb_paint_mod(Handle<Object> self, void *paint) {
be0e02948c1d Improve resource management for coords, shapes and paints.
Thinker K.F. Li <thinker@codemud.net>
parents: 765
diff changeset
51 Persistent<Object> *paint_hdl;
be0e02948c1d Improve resource management for coords, shapes and paints.
Thinker K.F. Li <thinker@codemud.net>
parents: 765
diff changeset
52
be0e02948c1d Improve resource management for coords, shapes and paints.
Thinker K.F. Li <thinker@codemud.net>
parents: 765
diff changeset
53 paint_hdl = new Persistent<Object>();
be0e02948c1d Improve resource management for coords, shapes and paints.
Thinker K.F. Li <thinker@codemud.net>
parents: 765
diff changeset
54 *paint_hdl = Persistent<Object>::New(self);
be0e02948c1d Improve resource management for coords, shapes and paints.
Thinker K.F. Li <thinker@codemud.net>
parents: 765
diff changeset
55
be0e02948c1d Improve resource management for coords, shapes and paints.
Thinker K.F. Li <thinker@codemud.net>
parents: 765
diff changeset
56 paint_hdl->MakeWeak(paint_hdl, xnjsmb_paint_recycle);
be0e02948c1d Improve resource management for coords, shapes and paints.
Thinker K.F. Li <thinker@codemud.net>
parents: 765
diff changeset
57 }
be0e02948c1d Improve resource management for coords, shapes and paints.
Thinker K.F. Li <thinker@codemud.net>
parents: 765
diff changeset
58
be0e02948c1d Improve resource management for coords, shapes and paints.
Thinker K.F. Li <thinker@codemud.net>
parents: 765
diff changeset
59 static void
687
da12923a789a Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents: 684
diff changeset
60 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
61 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
62 Handle<Object> rt_o;
766
be0e02948c1d Improve resource management for coords, shapes and paints.
Thinker K.F. Li <thinker@codemud.net>
parents: 765
diff changeset
63 Handle<Object> sh_o;
569
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
64 redraw_man_t *rdman;
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
65
687
da12923a789a Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents: 684
diff changeset
66 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
67 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
68 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
69
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
70 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
71
576
5a68e2bcea17 Set font styles for stext in Javascript
Thinker K.F. Li <thinker@branda.to>
parents: 570
diff changeset
72 if(sh_get_coord(sh))
5a68e2bcea17 Set font styles for stext in Javascript
Thinker K.F. Li <thinker@branda.to>
parents: 570
diff changeset
73 rdman_shape_changed(rdman, sh);
766
be0e02948c1d Improve resource management for coords, shapes and paints.
Thinker K.F. Li <thinker@codemud.net>
parents: 765
diff changeset
74
be0e02948c1d Improve resource management for coords, shapes and paints.
Thinker K.F. Li <thinker@codemud.net>
parents: 765
diff changeset
75 sh_o = *(Persistent<Object> *)mb_prop_get(&sh->obj.props, PROP_JSOBJ);
be0e02948c1d Improve resource management for coords, shapes and paints.
Thinker K.F. Li <thinker@codemud.net>
parents: 765
diff changeset
76 SET(sh_o, "_fill_by", self);
569
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
687
da12923a789a Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents: 684
diff changeset
79 static void
da12923a789a Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents: 684
diff changeset
80 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
81 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
82 Handle<Object> rt_o;
766
be0e02948c1d Improve resource management for coords, shapes and paints.
Thinker K.F. Li <thinker@codemud.net>
parents: 765
diff changeset
83 Handle<Object> sh_o;
569
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
84 redraw_man_t *rdman;
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
85
687
da12923a789a Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents: 684
diff changeset
86 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
87 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
88 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
89
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
90 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
91
576
5a68e2bcea17 Set font styles for stext in Javascript
Thinker K.F. Li <thinker@branda.to>
parents: 570
diff changeset
92 if(sh_get_coord(sh))
5a68e2bcea17 Set font styles for stext in Javascript
Thinker K.F. Li <thinker@branda.to>
parents: 570
diff changeset
93 rdman_shape_changed(rdman, sh);
766
be0e02948c1d Improve resource management for coords, shapes and paints.
Thinker K.F. Li <thinker@codemud.net>
parents: 765
diff changeset
94
be0e02948c1d Improve resource management for coords, shapes and paints.
Thinker K.F. Li <thinker@codemud.net>
parents: 765
diff changeset
95 sh_o = *(Persistent<Object> *)mb_prop_get(&sh->obj.props, PROP_JSOBJ);
be0e02948c1d Improve resource management for coords, shapes and paints.
Thinker K.F. Li <thinker@codemud.net>
parents: 765
diff changeset
96 SET(sh_o, "_stroke_by", self);
569
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
97 }
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
98
699
0b98bdc53215 Add binding for color changing of paint_color_t in JS
Thinker K.F. Li <thinker@branda.to>
parents: 687
diff changeset
99 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
100 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
101 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
102 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
103 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
104 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
105
0b98bdc53215 Add binding for color changing of paint_color_t in JS
Thinker K.F. Li <thinker@branda.to>
parents: 687
diff changeset
106 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
107 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
108 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
109
0b98bdc53215 Add binding for color changing of paint_color_t in JS
Thinker K.F. Li <thinker@branda.to>
parents: 687
diff changeset
110 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
111
0b98bdc53215 Add binding for color changing of paint_color_t in JS
Thinker K.F. Li <thinker@branda.to>
parents: 687
diff changeset
112 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
113 }
0b98bdc53215 Add binding for color changing of paint_color_t in JS
Thinker K.F. Li <thinker@branda.to>
parents: 687
diff changeset
114
733
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
115 /*! \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
116 */
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
117 static void
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
118 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
119 Array *stops_o;
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
120 Array *stop_o;
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
121 int nstops;
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
122 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
123 int i;
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
124
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
125 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
126 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
127 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
128 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
129
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
130 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
131 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
132 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
133 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
134 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
135 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
136 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
137 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
138 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
139 }
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
140
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
141 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
142 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
143 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
144 * 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
145 * function. */
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
146 }
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
147
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
148 /*! \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
149 */
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
150 static void
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
151 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
152 Array *stops_o;
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
153 Array *stop_o;
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
154 int nstops;
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
155 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
156 int i;
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
157
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
158 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
159 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
160 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
161 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
162
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
163 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
164 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
165 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
166 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
167 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
168 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
169 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
170 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
171 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
172 }
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
173
735
d0ee92a96c47 Fix typo and add initialize code for linear and radial
Thinker K.F. Li <thinker@branda.to>
parents: 733
diff changeset
174 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
175 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
176 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
177 * 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
178 * function. */
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
179 }
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
180
687
da12923a789a Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents: 684
diff changeset
181 #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
182
687
da12923a789a Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents: 684
diff changeset
183 /*! \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
184 *
da12923a789a Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents: 684
diff changeset
185 * @{
567
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
186 */
687
da12923a789a Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents: 684
diff changeset
187 paint_t *
da12923a789a Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents: 684
diff changeset
188 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
189 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
190 const char **err) {
da12923a789a Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents: 684
diff changeset
191 paint_t *paint;
da12923a789a Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents: 684
diff changeset
192 redraw_man_t *rdman;
567
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
193
687
da12923a789a Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents: 684
diff changeset
194 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
195 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
196 if(paint == NULL) {
da12923a789a Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents: 684
diff changeset
197 *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
198 return NULL;
da12923a789a Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents: 684
diff changeset
199 }
567
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
200
687
da12923a789a Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents: 684
diff changeset
201 return paint;
567
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
687
da12923a789a Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents: 684
diff changeset
204 paint_t *
da12923a789a Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents: 684
diff changeset
205 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
206 const char **err) {
da12923a789a Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents: 684
diff changeset
207 paint_t *paint;
636
cc39cf3f623c paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents: 576
diff changeset
208 redraw_man_t *rdman;
cc39cf3f623c paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents: 576
diff changeset
209
687
da12923a789a Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents: 684
diff changeset
210 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
211 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
212 if(paint == NULL) {
da12923a789a Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents: 684
diff changeset
213 *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
214 return NULL;
da12923a789a Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents: 684
diff changeset
215 }
636
cc39cf3f623c paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents: 576
diff changeset
216
687
da12923a789a Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents: 684
diff changeset
217 return paint;
636
cc39cf3f623c paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents: 576
diff changeset
218 }
cc39cf3f623c paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents: 576
diff changeset
219
733
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
220 paint_t *
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
221 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
222 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
223 const char **err) {
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
224 paint_t *paint;
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
225 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
226
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
227 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
228 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
229 if(paint == NULL) {
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
230 *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
231 return NULL;
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
232 }
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
233
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
234 return paint;
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
235 }
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
236
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
237 paint_t *
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
238 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
239 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
240 const char **err) {
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
241 paint_t *paint;
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
242 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
243
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
244 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
245 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
246 if(paint == NULL) {
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
247 *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
248 return NULL;
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
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
251 return paint;
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
252 }
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
253
687
da12923a789a Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents: 684
diff changeset
254 /* @} */
636
cc39cf3f623c paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents: 576
diff changeset
255
687
da12923a789a Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents: 684
diff changeset
256 /*! \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
257 *
da12923a789a Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents: 684
diff changeset
258 * 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
259 * objects.
da12923a789a Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents: 684
diff changeset
260 *
da12923a789a Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents: 684
diff changeset
261 * @{
da12923a789a Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents: 684
diff changeset
262 */
da12923a789a Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents: 684
diff changeset
263 Handle<Value>
da12923a789a Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents: 684
diff changeset
264 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
265 Handle<Value> ret;
da12923a789a Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents: 684
diff changeset
266
da12923a789a Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents: 684
diff changeset
267 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
268
da12923a789a Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents: 684
diff changeset
269 return ret;
636
cc39cf3f623c paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents: 576
diff changeset
270 }
cc39cf3f623c paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents: 576
diff changeset
271
687
da12923a789a Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents: 684
diff changeset
272 Handle<Value>
da12923a789a Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents: 684
diff changeset
273 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
274 Handle<Value> ret;
569
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
275
687
da12923a789a Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents: 684
diff changeset
276 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
277
687
da12923a789a Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents: 684
diff changeset
278 return ret;
567
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
279 }
733
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
280
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
281 Handle<Value>
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
282 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
283 Handle<Value> ret;
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
284
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
285 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
286
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
287 return ret;
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
288 }
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
289
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
290 Handle<Value>
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
291 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
292 Handle<Value> ret;
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
293
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
294 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
295
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
296 return ret;
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
297 }
687
da12923a789a Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents: 684
diff changeset
298 /* @} */
567
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
299
637
714cd6470bd9 Doc on xnjsmb_paints_init_mb_rt_temp()
Thinker K.F. Li <thinker@branda.to>
parents: 636
diff changeset
300 /*! \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
301 *
714cd6470bd9 Doc on xnjsmb_paints_init_mb_rt_temp()
Thinker K.F. Li <thinker@branda.to>
parents: 636
diff changeset
302 * 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
303 * being loaded.
714cd6470bd9 Doc on xnjsmb_paints_init_mb_rt_temp()
Thinker K.F. Li <thinker@branda.to>
parents: 636
diff changeset
304 */
567
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
305 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
306 static int init_flag = 0;
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
307 Handle<ObjectTemplate> rt_proto_temp;
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
308
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
309 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
310 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
311 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
312 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
313 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
314 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
315
567
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
316 init_flag = 1;
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
317 }
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
318 }
684
b346e4699e55 Add more comment for JS binding
Thinker K.F. Li <thinker@branda.to>
parents: 637
diff changeset
319
b346e4699e55 Add more comment for JS binding
Thinker K.F. Li <thinker@branda.to>
parents: 637
diff changeset
320 /* @} */