Mercurial > MadButterfly
comparison nodejs/paints.cc @ 822:586e50f82c1f
Unify coding style tag for emacs and vim.
author | Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com> |
---|---|
date | Tue, 14 Sep 2010 01:08:39 +0800 |
parents | 01b514800fbe |
children | df6ee4568ca2 |
comparison
equal
deleted
inserted
replaced
821:bfdc82bbd6e4 | 822:586e50f82c1f |
---|---|
1 // -*- indent-tabs-mode: t; tab-width: 8; c-basic-offset: 4; -*- | |
2 // vim: sw=4:ts=8:sts=4 | |
1 #include <v8.h> | 3 #include <v8.h> |
2 | 4 |
3 extern "C" { | 5 extern "C" { |
4 #include "mb.h" | 6 #include "mb.h" |
5 } | 7 } |
34 Persistent<Object> *paint_hdl = (Persistent<Object> *)parameter; | 36 Persistent<Object> *paint_hdl = (Persistent<Object> *)parameter; |
35 paint_t *paint; | 37 paint_t *paint; |
36 Handle<Object> rt; | 38 Handle<Object> rt; |
37 redraw_man_t *rdman; | 39 redraw_man_t *rdman; |
38 int r; | 40 int r; |
39 | 41 |
40 paint = (paint_t *)UNWRAP(*paint_hdl); | 42 paint = (paint_t *)UNWRAP(*paint_hdl); |
41 rt = GET(*paint_hdl, "mbrt")->ToObject(); | 43 rt = GET(*paint_hdl, "mbrt")->ToObject(); |
42 rdman = xnjsmb_rt_rdman(rt); | 44 rdman = xnjsmb_rt_rdman(rt); |
43 | 45 |
44 r = rdman_paint_free(rdman, paint); | 46 r = rdman_paint_free(rdman, paint); |
45 ASSERT(r == 0); | 47 ASSERT(r == 0); |
46 | 48 |
47 paint_hdl->Dispose(); | 49 paint_hdl->Dispose(); |
48 delete paint_hdl; | 50 delete paint_hdl; |
49 } | 51 } |
50 | 52 |
51 static void | 53 static void |
52 xnjsmb_paint_mod(Handle<Object> self, void *paint) { | 54 xnjsmb_paint_mod(Handle<Object> self, void *paint) { |
53 Persistent<Object> *paint_hdl; | 55 Persistent<Object> *paint_hdl; |
54 | 56 |
55 paint_hdl = new Persistent<Object>(); | 57 paint_hdl = new Persistent<Object>(); |
56 *paint_hdl = Persistent<Object>::New(self); | 58 *paint_hdl = Persistent<Object>::New(self); |
57 | 59 |
58 paint_hdl->MakeWeak(paint_hdl, xnjsmb_paint_recycle); | 60 paint_hdl->MakeWeak(paint_hdl, xnjsmb_paint_recycle); |
59 } | 61 } |
66 redraw_man_t *rdman; | 68 redraw_man_t *rdman; |
67 | 69 |
68 rt_v = GET(self, "mbrt"); | 70 rt_v = GET(self, "mbrt"); |
69 rt_o = rt_v->ToObject(); | 71 rt_o = rt_v->ToObject(); |
70 rdman = xnjsmb_rt_rdman(rt_o); | 72 rdman = xnjsmb_rt_rdman(rt_o); |
71 | 73 |
72 rdman_paint_fill(rdman, paint, sh); | 74 rdman_paint_fill(rdman, paint, sh); |
73 | 75 |
74 if(sh_get_coord(sh)) | 76 if(sh_get_coord(sh)) |
75 rdman_shape_changed(rdman, sh); | 77 rdman_shape_changed(rdman, sh); |
76 | 78 |
77 sh_o = *(Persistent<Object> *)mb_prop_get(&sh->obj.props, PROP_JSOBJ); | 79 sh_o = *(Persistent<Object> *)mb_prop_get(&sh->obj.props, PROP_JSOBJ); |
78 SET(sh_o, "_fill_by", self); | 80 SET(sh_o, "_fill_by", self); |
86 redraw_man_t *rdman; | 88 redraw_man_t *rdman; |
87 | 89 |
88 rt_v = GET(self, "mbrt"); | 90 rt_v = GET(self, "mbrt"); |
89 rt_o = rt_v->ToObject(); | 91 rt_o = rt_v->ToObject(); |
90 rdman = xnjsmb_rt_rdman(rt_o); | 92 rdman = xnjsmb_rt_rdman(rt_o); |
91 | 93 |
92 rdman_paint_stroke(rdman, paint, sh); | 94 rdman_paint_stroke(rdman, paint, sh); |
93 | 95 |
94 if(sh_get_coord(sh)) | 96 if(sh_get_coord(sh)) |
95 rdman_shape_changed(rdman, sh); | 97 rdman_shape_changed(rdman, sh); |
96 | 98 |
97 sh_o = *(Persistent<Object> *)mb_prop_get(&sh->obj.props, PROP_JSOBJ); | 99 sh_o = *(Persistent<Object> *)mb_prop_get(&sh->obj.props, PROP_JSOBJ); |
98 SET(sh_o, "_stroke_by", self); | 100 SET(sh_o, "_stroke_by", self); |
137 stop_o->Get(1)->ToNumber()->Value(), /* r */ | 139 stop_o->Get(1)->ToNumber()->Value(), /* r */ |
138 stop_o->Get(2)->ToNumber()->Value(), /* g */ | 140 stop_o->Get(2)->ToNumber()->Value(), /* g */ |
139 stop_o->Get(3)->ToNumber()->Value(), /* b */ | 141 stop_o->Get(3)->ToNumber()->Value(), /* b */ |
140 stop_o->Get(4)->ToNumber()->Value()); /* a */ | 142 stop_o->Get(4)->ToNumber()->Value()); /* a */ |
141 } | 143 } |
142 | 144 |
143 old_grad_stops = paint_linear_stops(paint, nstops, grad_stops); | 145 old_grad_stops = paint_linear_stops(paint, nstops, grad_stops); |
144 if(old_grad_stops) | 146 if(old_grad_stops) |
145 free(old_grad_stops); /* The stops, here, were allocated for | 147 free(old_grad_stops); /* The stops, here, were allocated for |
146 * previous calling of this | 148 * previous calling of this |
147 * function. */ | 149 * function. */ |
170 stop_o->Get(1)->ToNumber()->Value(), /* r */ | 172 stop_o->Get(1)->ToNumber()->Value(), /* r */ |
171 stop_o->Get(2)->ToNumber()->Value(), /* g */ | 173 stop_o->Get(2)->ToNumber()->Value(), /* g */ |
172 stop_o->Get(3)->ToNumber()->Value(), /* b */ | 174 stop_o->Get(3)->ToNumber()->Value(), /* b */ |
173 stop_o->Get(4)->ToNumber()->Value()); /* a */ | 175 stop_o->Get(4)->ToNumber()->Value()); /* a */ |
174 } | 176 } |
175 | 177 |
176 old_grad_stops = paint_radial_stops(paint, nstops, grad_stops); | 178 old_grad_stops = paint_radial_stops(paint, nstops, grad_stops); |
177 if(old_grad_stops) | 179 if(old_grad_stops) |
178 free(old_grad_stops); /* The stops, here, were allocated for | 180 free(old_grad_stops); /* The stops, here, were allocated for |
179 * previous calling of this | 181 * previous calling of this |
180 * function. */ | 182 * function. */ |
263 * @{ | 265 * @{ |
264 */ | 266 */ |
265 Handle<Value> | 267 Handle<Value> |
266 export_xnjsmb_auto_paint_color_new(paint_t *paint) { | 268 export_xnjsmb_auto_paint_color_new(paint_t *paint) { |
267 Handle<Value> ret; | 269 Handle<Value> ret; |
268 | 270 |
269 ret = xnjsmb_auto_paint_color_new(paint); | 271 ret = xnjsmb_auto_paint_color_new(paint); |
270 | 272 |
271 return ret; | 273 return ret; |
272 } | 274 } |
273 | 275 |
274 Handle<Value> | 276 Handle<Value> |
275 export_xnjsmb_auto_paint_image_new(paint_t *paint) { | 277 export_xnjsmb_auto_paint_image_new(paint_t *paint) { |
276 Handle<Value> ret; | 278 Handle<Value> ret; |
277 | 279 |
278 ret = xnjsmb_auto_paint_image_new(paint); | 280 ret = xnjsmb_auto_paint_image_new(paint); |
279 | 281 |
280 return ret; | 282 return ret; |
281 } | 283 } |
282 | 284 |
283 Handle<Value> | 285 Handle<Value> |
284 export_xnjsmb_auto_paint_linear_new(paint_t *paint) { | 286 export_xnjsmb_auto_paint_linear_new(paint_t *paint) { |
285 Handle<Value> ret; | 287 Handle<Value> ret; |
286 | 288 |
287 ret = xnjsmb_auto_paint_linear_new(paint); | 289 ret = xnjsmb_auto_paint_linear_new(paint); |
288 | 290 |
289 return ret; | 291 return ret; |
290 } | 292 } |
291 | 293 |
292 Handle<Value> | 294 Handle<Value> |
293 export_xnjsmb_auto_paint_radial_new(paint_t *paint) { | 295 export_xnjsmb_auto_paint_radial_new(paint_t *paint) { |
294 Handle<Value> ret; | 296 Handle<Value> ret; |
295 | 297 |
296 ret = xnjsmb_auto_paint_radial_new(paint); | 298 ret = xnjsmb_auto_paint_radial_new(paint); |
297 | 299 |
298 return ret; | 300 return ret; |
299 } | 301 } |
300 /* @} */ | 302 /* @} */ |
301 | 303 |
302 /*! \brief Initialize paints for mbfly. | 304 /*! \brief Initialize paints for mbfly. |
312 xnjsmb_auto_paint_init(); | 314 xnjsmb_auto_paint_init(); |
313 xnjsmb_auto_paint_color_init(); | 315 xnjsmb_auto_paint_color_init(); |
314 xnjsmb_auto_paint_image_init(); | 316 xnjsmb_auto_paint_image_init(); |
315 xnjsmb_auto_paint_linear_init(); | 317 xnjsmb_auto_paint_linear_init(); |
316 xnjsmb_auto_paint_radial_init(); | 318 xnjsmb_auto_paint_radial_init(); |
317 | 319 |
318 init_flag = 1; | 320 init_flag = 1; |
319 } | 321 } |
320 } | 322 } |
321 | 323 |
322 /* @} */ | 324 /* @} */ |