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