Mercurial > MadButterfly
comparison nodejs/coord.cc @ 843:2bcacd29d95f
Define accessor for x and y to implement absolute location
author | wycc |
---|---|
date | Sun, 19 Sep 2010 11:36:03 +0800 |
parents | 379fd510ba38 |
children | 88bd0eee2b00 |
comparison
equal
deleted
inserted
replaced
842:76fe4afce640 | 843:2bcacd29d95f |
---|---|
280 | 280 |
281 opacity = coord_get_opacity(coord); | 281 opacity = coord_get_opacity(coord); |
282 return Number::New(opacity); | 282 return Number::New(opacity); |
283 } | 283 } |
284 | 284 |
285 #define cc(i) (coord_get_matrix(coord)[i]) | |
286 static void | |
287 xnjsmb_coord_set_y(Handle<Object> self, coord_t *coord, Handle<Value> value, const char **str) | |
288 { | |
289 Handle<Object> js_rt; | |
290 redraw_man_t *rdman; | |
291 co_aix y,ty; | |
292 co_aix xx,yy; | |
293 | |
294 js_rt = GET(self, "mbrt")->ToObject(); | |
295 ASSERT(js_rt != NULL); | |
296 rdman = xnjsmb_rt_rdman(js_rt); | |
297 | |
298 | |
299 ty = value->NumberValue(); | |
300 xx = GET(self,"_x")->ToNumber()->NumberValue(); | |
301 yy = GET(self,"_y")->ToNumber()->NumberValue(); | |
302 y = ty-cc(3)*xx-cc(4)*yy; | |
303 coord_get_matrix(coord)[5] = y; | |
304 rdman_coord_changed(rdman, coord); | |
305 } | |
306 | |
307 static Handle<Value> | |
308 xnjsmb_coord_get_y(Handle<Object> self, coord_t *coord, | |
309 const char **err) { | |
310 co_aix y; | |
311 co_aix xx,yy; | |
312 | |
313 xx = GET(self,"_x")->ToNumber()->NumberValue(); | |
314 yy = GET(self,"_y")->ToNumber()->NumberValue(); | |
315 | |
316 y = cc(3)*xx+cc(4)*yy+cc(5); | |
317 return Number::New(y); | |
318 } | |
319 static void | |
320 xnjsmb_coord_set_x(Handle<Object> self, coord_t *coord, Handle<Value> value, const char **str) | |
321 { | |
322 Handle<Object> js_rt; | |
323 redraw_man_t *rdman; | |
324 co_aix x,tx; | |
325 co_aix xx,yy; | |
326 | |
327 xx = GET(self,"_x")->ToNumber()->NumberValue(); | |
328 yy = GET(self,"_y")->ToNumber()->NumberValue(); | |
329 js_rt = GET(self, "mbrt")->ToObject(); | |
330 ASSERT(js_rt != NULL); | |
331 rdman = xnjsmb_rt_rdman(js_rt); | |
332 | |
333 tx = value->NumberValue(); | |
334 x = tx-cc(0)*xx-cc(1)*yy; | |
335 coord_get_matrix(coord)[2] = x; | |
336 rdman_coord_changed(rdman, coord); | |
337 } | |
338 | |
339 static Handle<Value> | |
340 xnjsmb_coord_get_x(Handle<Object> self, coord_t *coord, | |
341 const char **err) { | |
342 co_aix x; | |
343 co_aix xx,yy; | |
344 | |
345 xx = GET(self,"_x")->ToNumber()->NumberValue(); | |
346 yy = GET(self,"_y")->ToNumber()->NumberValue(); | |
347 | |
348 x = cc(0)*xx+cc(1)*yy+cc(2); | |
349 return Number::New(x); | |
350 } | |
351 #undef m | |
352 | |
285 #include "coord-inc.h" | 353 #include "coord-inc.h" |
286 | 354 |
287 /*! \brief This function used by \ref xnjsmb_mb_rt to wrap coord object. | 355 /*! \brief This function used by \ref xnjsmb_mb_rt to wrap coord object. |
288 */ | 356 */ |
289 Handle<Value> export_xnjsmb_auto_coord_new(coord_t *coord) { | 357 Handle<Value> export_xnjsmb_auto_coord_new(coord_t *coord) { |