annotate nodejs/paints.cc @ 1324:740b3239030e

Clear dup group before running animation. User may change content of groups. TweenObject would not aware the changes if we don't clear the dup group before running animation.
author Thinker K.F. Li <thinker@codemud.net>
date Sun, 30 Jan 2011 20:03:21 +0800
parents df6ee4568ca2
children
rev   line source
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 771
diff changeset
1 // -*- indent-tabs-mode: t; tab-width: 8; c-basic-offset: 4; -*-
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 771
diff changeset
2 // vim: sw=4:ts=8:sts=4
567
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
3 #include <v8.h>
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
4
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
5 extern "C" {
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
6 #include "mb.h"
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
7 }
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 #include "mbfly_njs.h"
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
10
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
11 using namespace v8;
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
12
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
13 #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
14 #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
15 #endif
567
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
16
684
b346e4699e55 Add more comment for JS binding
Thinker K.F. Li <thinker@branda.to>
parents: 637
diff changeset
17 /*! \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
18 * \ingroup xnjsmb
b346e4699e55 Add more comment for JS binding
Thinker K.F. Li <thinker@branda.to>
parents: 637
diff changeset
19 *
b346e4699e55 Add more comment for JS binding
Thinker K.F. Li <thinker@branda.to>
parents: 637
diff changeset
20 * @{
b346e4699e55 Add more comment for JS binding
Thinker K.F. Li <thinker@branda.to>
parents: 637
diff changeset
21 */
567
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
22
765
a49358b040b5 Doc on how to manage life-cycle of paints for JS
Thinker K.F. Li <thinker@codemud.net>
parents: 735
diff changeset
23 /*! \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
24 *
a49358b040b5 Doc on how to manage life-cycle of paints for JS
Thinker K.F. Li <thinker@codemud.net>
parents: 735
diff changeset
25 * 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
26 * 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
27 * 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
28 * 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
29 * 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
30 *
a49358b040b5 Doc on how to manage life-cycle of paints for JS
Thinker K.F. Li <thinker@codemud.net>
parents: 735
diff changeset
31 * 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
32 * 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
33 */
687
da12923a789a Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents: 684
diff changeset
34 static void
766
be0e02948c1d Improve resource management for coords, shapes and paints.
Thinker K.F. Li <thinker@codemud.net>
parents: 765
diff changeset
35 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
36 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
37 paint_t *paint;
be0e02948c1d Improve resource management for coords, shapes and paints.
Thinker K.F. Li <thinker@codemud.net>
parents: 765
diff changeset
38 Handle<Object> rt;
be0e02948c1d Improve resource management for coords, shapes and paints.
Thinker K.F. Li <thinker@codemud.net>
parents: 765
diff changeset
39 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
40 int r;
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 771
diff changeset
41
766
be0e02948c1d Improve resource management for coords, shapes and paints.
Thinker K.F. Li <thinker@codemud.net>
parents: 765
diff changeset
42 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
43 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
44 rdman = xnjsmb_rt_rdman(rt);
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 771
diff changeset
45
771
01b514800fbe Fix logic error of checking clear flag for paint.
Thinker K.F. Li <thinker@codemud.net>
parents: 766
diff changeset
46 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
47 ASSERT(r == 0);
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 771
diff changeset
48
766
be0e02948c1d Improve resource management for coords, shapes and paints.
Thinker K.F. Li <thinker@codemud.net>
parents: 765
diff changeset
49 paint_hdl->Dispose();
be0e02948c1d Improve resource management for coords, shapes and paints.
Thinker K.F. Li <thinker@codemud.net>
parents: 765
diff changeset
50 delete paint_hdl;
be0e02948c1d Improve resource management for coords, shapes and paints.
Thinker K.F. Li <thinker@codemud.net>
parents: 765
diff changeset
51 }
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 static void
be0e02948c1d Improve resource management for coords, shapes and paints.
Thinker K.F. Li <thinker@codemud.net>
parents: 765
diff changeset
54 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
55 Persistent<Object> *paint_hdl;
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 771
diff changeset
56
766
be0e02948c1d Improve resource management for coords, shapes and paints.
Thinker K.F. Li <thinker@codemud.net>
parents: 765
diff changeset
57 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
58 *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
59
be0e02948c1d Improve resource management for coords, shapes and paints.
Thinker K.F. Li <thinker@codemud.net>
parents: 765
diff changeset
60 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
61 }
be0e02948c1d Improve resource management for coords, shapes and paints.
Thinker K.F. Li <thinker@codemud.net>
parents: 765
diff changeset
62
be0e02948c1d Improve resource management for coords, shapes and paints.
Thinker K.F. Li <thinker@codemud.net>
parents: 765
diff changeset
63 static void
687
da12923a789a Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents: 684
diff changeset
64 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
65 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
66 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
67 Handle<Object> sh_o;
569
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
68 redraw_man_t *rdman;
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
69
687
da12923a789a Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents: 684
diff changeset
70 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
71 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
72 rdman = xnjsmb_rt_rdman(rt_o);
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 771
diff changeset
73
569
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
74 rdman_paint_fill(rdman, paint, sh);
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 771
diff changeset
75
576
5a68e2bcea17 Set font styles for stext in Javascript
Thinker K.F. Li <thinker@branda.to>
parents: 570
diff changeset
76 if(sh_get_coord(sh))
5a68e2bcea17 Set font styles for stext in Javascript
Thinker K.F. Li <thinker@branda.to>
parents: 570
diff changeset
77 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
78
be0e02948c1d Improve resource management for coords, shapes and paints.
Thinker K.F. Li <thinker@codemud.net>
parents: 765
diff changeset
79 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
80 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
81 }
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
82
687
da12923a789a Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents: 684
diff changeset
83 static void
da12923a789a Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents: 684
diff changeset
84 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
85 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
86 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
87 Handle<Object> sh_o;
569
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
88 redraw_man_t *rdman;
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
89
687
da12923a789a Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents: 684
diff changeset
90 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
91 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
92 rdman = xnjsmb_rt_rdman(rt_o);
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 771
diff changeset
93
569
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
94 rdman_paint_stroke(rdman, paint, sh);
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 771
diff changeset
95
576
5a68e2bcea17 Set font styles for stext in Javascript
Thinker K.F. Li <thinker@branda.to>
parents: 570
diff changeset
96 if(sh_get_coord(sh))
5a68e2bcea17 Set font styles for stext in Javascript
Thinker K.F. Li <thinker@branda.to>
parents: 570
diff changeset
97 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
98
be0e02948c1d Improve resource management for coords, shapes and paints.
Thinker K.F. Li <thinker@codemud.net>
parents: 765
diff changeset
99 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
100 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
101 }
f87a368e847a Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents: 568
diff changeset
102
699
0b98bdc53215 Add binding for color changing of paint_color_t in JS
Thinker K.F. Li <thinker@branda.to>
parents: 687
diff changeset
103 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
104 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
105 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
106 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
107 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
108 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
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 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
111 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
112 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
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 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
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 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
117 }
0b98bdc53215 Add binding for color changing of paint_color_t in JS
Thinker K.F. Li <thinker@branda.to>
parents: 687
diff changeset
118
733
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
119 /*! \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
120 */
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
121 static void
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
122 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
123 Array *stops_o;
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
124 Array *stop_o;
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
125 int nstops;
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
126 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
127 int i;
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
128
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
129 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
130 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
131 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
132 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
133
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
134 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
135 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
136 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
137 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
138 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
139 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
140 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
141 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
142 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
143 }
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 771
diff changeset
144
733
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
145 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
146 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
147 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
148 * 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
149 * function. */
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
150 }
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 /*! \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
153 */
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
154 static void
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
155 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
156 Array *stops_o;
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
157 Array *stop_o;
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
158 int nstops;
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
159 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
160 int i;
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
161
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
162 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
163 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
164 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
165 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
166
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
167 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
168 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
169 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
170 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
171 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
172 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
173 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
174 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
175 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
176 }
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 771
diff changeset
177
735
d0ee92a96c47 Fix typo and add initialize code for linear and radial
Thinker K.F. Li <thinker@branda.to>
parents: 733
diff changeset
178 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
179 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
180 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
181 * 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
182 * function. */
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
183 }
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
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 #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
186
687
da12923a789a Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents: 684
diff changeset
187 /*! \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
188 *
da12923a789a Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents: 684
diff changeset
189 * @{
567
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
190 */
687
da12923a789a Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents: 684
diff changeset
191 paint_t *
da12923a789a Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents: 684
diff changeset
192 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
193 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
194 const char **err) {
da12923a789a Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents: 684
diff changeset
195 paint_t *paint;
da12923a789a Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents: 684
diff changeset
196 redraw_man_t *rdman;
567
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
197
1053
df6ee4568ca2 Rename X_njs_MB_* to njs_mb_* for nodejs plugin.
Thinker K.F. Li <thinker@codemud.net>
parents: 822
diff changeset
198 rdman = njs_mb_rdman(rt);
687
da12923a789a Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents: 684
diff changeset
199 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
200 if(paint == NULL) {
da12923a789a Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents: 684
diff changeset
201 *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
202 return NULL;
da12923a789a Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents: 684
diff changeset
203 }
567
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
204
687
da12923a789a Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents: 684
diff changeset
205 return paint;
567
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
206 }
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
207
687
da12923a789a Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents: 684
diff changeset
208 paint_t *
da12923a789a Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents: 684
diff changeset
209 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
210 const char **err) {
da12923a789a Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents: 684
diff changeset
211 paint_t *paint;
636
cc39cf3f623c paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents: 576
diff changeset
212 redraw_man_t *rdman;
cc39cf3f623c paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents: 576
diff changeset
213
1053
df6ee4568ca2 Rename X_njs_MB_* to njs_mb_* for nodejs plugin.
Thinker K.F. Li <thinker@codemud.net>
parents: 822
diff changeset
214 rdman = njs_mb_rdman(rt);
687
da12923a789a Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents: 684
diff changeset
215 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
216 if(paint == NULL) {
da12923a789a Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents: 684
diff changeset
217 *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
218 return NULL;
da12923a789a Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents: 684
diff changeset
219 }
636
cc39cf3f623c paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents: 576
diff changeset
220
687
da12923a789a Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents: 684
diff changeset
221 return paint;
636
cc39cf3f623c paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents: 576
diff changeset
222 }
cc39cf3f623c paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents: 576
diff changeset
223
733
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
224 paint_t *
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
225 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
226 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
227 const char **err) {
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
228 paint_t *paint;
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
229 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
230
1053
df6ee4568ca2 Rename X_njs_MB_* to njs_mb_* for nodejs plugin.
Thinker K.F. Li <thinker@codemud.net>
parents: 822
diff changeset
231 rdman = njs_mb_rdman(rt);
733
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
232 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
233 if(paint == NULL) {
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
234 *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
235 return NULL;
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
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
238 return paint;
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
239 }
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
240
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
241 paint_t *
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
242 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
243 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
244 const char **err) {
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
245 paint_t *paint;
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
246 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
247
1053
df6ee4568ca2 Rename X_njs_MB_* to njs_mb_* for nodejs plugin.
Thinker K.F. Li <thinker@codemud.net>
parents: 822
diff changeset
248 rdman = njs_mb_rdman(rt);
733
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
249 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
250 if(paint == NULL) {
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
251 *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
252 return NULL;
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
253 }
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
254
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
255 return paint;
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
256 }
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
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 /* @} */
636
cc39cf3f623c paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents: 576
diff changeset
259
687
da12923a789a Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents: 684
diff changeset
260 /*! \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
261 *
da12923a789a Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents: 684
diff changeset
262 * 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
263 * objects.
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 * @{
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 Handle<Value>
da12923a789a Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents: 684
diff changeset
268 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
269 Handle<Value> ret;
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 771
diff changeset
270
687
da12923a789a Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents: 684
diff changeset
271 ret = xnjsmb_auto_paint_color_new(paint);
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 771
diff changeset
272
687
da12923a789a Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents: 684
diff changeset
273 return ret;
636
cc39cf3f623c paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents: 576
diff changeset
274 }
cc39cf3f623c paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents: 576
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 Handle<Value>
da12923a789a Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents: 684
diff changeset
277 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
278 Handle<Value> ret;
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 771
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 ret = xnjsmb_auto_paint_image_new(paint);
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 771
diff changeset
281
687
da12923a789a Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents: 684
diff changeset
282 return ret;
567
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
283 }
733
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 Handle<Value>
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
286 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
287 Handle<Value> ret;
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 771
diff changeset
288
733
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
289 ret = xnjsmb_auto_paint_linear_new(paint);
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 771
diff changeset
290
733
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
291 return ret;
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
292 }
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 Handle<Value>
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
295 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
296 Handle<Value> ret;
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 771
diff changeset
297
733
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
298 ret = xnjsmb_auto_paint_radial_new(paint);
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 771
diff changeset
299
733
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
300 return ret;
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 699
diff changeset
301 }
687
da12923a789a Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents: 684
diff changeset
302 /* @} */
567
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
303
637
714cd6470bd9 Doc on xnjsmb_paints_init_mb_rt_temp()
Thinker K.F. Li <thinker@branda.to>
parents: 636
diff changeset
304 /*! \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
305 *
714cd6470bd9 Doc on xnjsmb_paints_init_mb_rt_temp()
Thinker K.F. Li <thinker@branda.to>
parents: 636
diff changeset
306 * 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
307 * being loaded.
714cd6470bd9 Doc on xnjsmb_paints_init_mb_rt_temp()
Thinker K.F. Li <thinker@branda.to>
parents: 636
diff changeset
308 */
567
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
309 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
310 static int init_flag = 0;
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
311 Handle<ObjectTemplate> rt_proto_temp;
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
312
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
313 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
314 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
315 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
316 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
317 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
318 xnjsmb_auto_paint_radial_init();
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 771
diff changeset
319
567
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
320 init_flag = 1;
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
321 }
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
322 }
684
b346e4699e55 Add more comment for JS binding
Thinker K.F. Li <thinker@branda.to>
parents: 637
diff changeset
323
b346e4699e55 Add more comment for JS binding
Thinker K.F. Li <thinker@branda.to>
parents: 637
diff changeset
324 /* @} */