VALUE shoes_canvas_image(int argc, VALUE *argv, VALUE self) { VALUE path, attr, _w, _h, image, block; if (argc == 0 || (argc == 1 && rb_obj_is_kind_of(argv[0], rb_cHash))) { rb_scan_args(argc, argv, "01&", &attr, &block); if (NIL_P(attr)) attr = rb_hash_new(); _w = ATTR(attr, width); _h = ATTR(attr, height); } else rb_scan_args(argc, argv, "12&", &_w, &_h, &attr, &block); if (NIL_P(_w) || FIXNUM_P(_w)) { path = Qnil; if (FIXNUM_P(_w)) ATTRSET(attr, width, _w); if (FIXNUM_P(_h)) ATTRSET(attr, height, _h); ATTRSET(attr, draw, block); } else { rb_scan_args(argc, argv, "11&", &path, &attr, &block); if (!NIL_P(block)) { if (NIL_P(attr)) attr = rb_hash_new(); rb_hash_aset(attr, ID2SYM(s_click), block); } } if (rb_obj_is_kind_of(self, cImage)) { shoes_image_image(self, path, attr); return self; } SETUP(); image = shoes_image_new(cImage, path, attr, self, canvas->st); shoes_add_ele(canvas, image); return image; }
VALUE shoes_canvas_image(int argc, VALUE *argv, VALUE self) { rb_arg_list args; VALUE path = Qnil, attr = Qnil, _w, _h, image; switch (rb_parse_args(argc, argv, "ii|h,s|h,|h", &args)) { case 1: _w = args.a[0]; _h = args.a[1]; attr = args.a[2]; ATTRSET(attr, width, _w); ATTRSET(attr, height, _h); if (rb_block_given_p()) ATTRSET(attr, draw, rb_block_proc()); break; case 2: path = args.a[0]; attr = args.a[1]; if (rb_block_given_p()) ATTRSET(attr, click, rb_block_proc()); break; case 3: attr = args.a[0]; if (rb_block_given_p()) ATTRSET(attr, draw, rb_block_proc()); break; } if (rb_obj_is_kind_of(self, cImage)) { shoes_image_image(self, path, attr); return self; } SETUP(); image = shoes_image_new(cImage, path, attr, self, canvas->st); shoes_add_ele(canvas, image); return image; }