No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 
 
 
 

654 líneas
18 KiB

  1. /*
  2. * libcucul Ruby bindings
  3. * Copyright (c) 2007 Pascal Terjan <pterjan@linuxfr.org>
  4. *
  5. * This library is free software. It comes without any warranty, to
  6. * the extent permitted by applicable law. You can redistribute it
  7. * and/or modify it under the terms of the Do What The Fuck You Want
  8. * To Public License, Version 2, as published by Sam Hocevar. See
  9. * http://sam.zoy.org/wtfpl/COPYING for more details.
  10. */
  11. #include <ruby.h>
  12. #include <cucul.h>
  13. #include <errno.h>
  14. #include "cucul-dither.h"
  15. #include "cucul-font.h"
  16. #include "common.h"
  17. VALUE cCanvas;
  18. #define simple_func(x) \
  19. static VALUE x (VALUE self) \
  20. { \
  21. if( cucul_##x (_SELF) <0) \
  22. rb_raise(rb_eRuntimeError, strerror(errno)); \
  23. \
  24. return self; \
  25. }
  26. #define get_int(x) \
  27. static VALUE get_##x (VALUE self) \
  28. { \
  29. return INT2NUM(cucul_get_##x (_SELF)); \
  30. }
  31. static void canvas_free(void * p)
  32. {
  33. cucul_free_canvas((cucul_canvas_t *)p);
  34. }
  35. static VALUE canvas_alloc(VALUE klass)
  36. {
  37. VALUE obj;
  38. obj = Data_Wrap_Struct(klass, 0, canvas_free, NULL);
  39. return obj;
  40. }
  41. VALUE canvas_create(cucul_canvas_t *canvas)
  42. {
  43. return Data_Wrap_Struct(cCanvas, 0, canvas_free, canvas);
  44. }
  45. static VALUE canvas_initialize(VALUE self, VALUE width, VALUE height)
  46. {
  47. cucul_canvas_t *canvas;
  48. canvas = cucul_create_canvas(NUM2INT(width), NUM2INT(height));
  49. if(canvas == NULL)
  50. {
  51. rb_raise(rb_eRuntimeError, strerror(errno));
  52. }
  53. _SELF = canvas;
  54. return self;
  55. }
  56. get_int(canvas_height)
  57. get_int(canvas_width)
  58. static VALUE set_canvas_width(VALUE self, VALUE width)
  59. {
  60. cucul_set_canvas_size(_SELF, NUM2INT(width), cucul_get_canvas_height(_SELF));
  61. return width;
  62. }
  63. static VALUE set_canvas_width2(VALUE self, VALUE width)
  64. {
  65. set_canvas_width(self, width);
  66. return self;
  67. }
  68. static VALUE set_canvas_height(VALUE self, VALUE height)
  69. {
  70. cucul_set_canvas_size(_SELF, cucul_get_canvas_width(_SELF), NUM2INT(height));
  71. return height;
  72. }
  73. static VALUE set_canvas_height2(VALUE self, VALUE height)
  74. {
  75. set_canvas_height(self, height);
  76. return self;
  77. }
  78. static VALUE set_canvas_size(VALUE self, VALUE height, VALUE width)
  79. {
  80. cucul_set_canvas_size(_SELF, NUM2INT(width), NUM2INT(height));
  81. return self;
  82. }
  83. /****/
  84. static VALUE gotoxy(VALUE self, VALUE x, VALUE y)
  85. {
  86. if( cucul_gotoxy(_SELF, NUM2INT(x), NUM2INT(y)) <0) {
  87. rb_raise(rb_eRuntimeError, strerror(errno));
  88. }
  89. return self;
  90. }
  91. get_int(cursor_x)
  92. get_int(cursor_y)
  93. simple_func(clear_canvas)
  94. static VALUE put_char(VALUE self, VALUE x, VALUE y, VALUE ch)
  95. {
  96. cucul_put_char(_SELF, NUM2INT(x), NUM2INT(y), NUM2ULONG(ch));
  97. return self;
  98. }
  99. static VALUE get_char(VALUE self, VALUE x, VALUE y)
  100. {
  101. unsigned long int ch;
  102. ch = cucul_get_char(_SELF, NUM2INT(x), NUM2INT(y));
  103. return INT2NUM(ch);
  104. }
  105. static VALUE put_str(VALUE self, VALUE x, VALUE y, VALUE str)
  106. {
  107. cucul_put_str(_SELF, NUM2INT(x), NUM2INT(y), StringValuePtr(str));
  108. return self;
  109. }
  110. static VALUE get_attr(VALUE self, VALUE x, VALUE y)
  111. {
  112. unsigned long int ch;
  113. ch = cucul_get_attr(_SELF, NUM2INT(x), NUM2INT(y));
  114. return INT2NUM(ch);
  115. }
  116. static VALUE set_attr(VALUE self, VALUE attr)
  117. {
  118. if(cucul_set_attr(_SELF, NUM2ULONG(attr)) <0)
  119. rb_raise(rb_eRuntimeError, strerror(errno));
  120. return self;
  121. }
  122. static VALUE set_attr2(VALUE self, VALUE attr)
  123. {
  124. set_attr(self, attr);
  125. return self;
  126. }
  127. static VALUE put_attr(VALUE self, VALUE x, VALUE y, VALUE attr)
  128. {
  129. if(cucul_put_attr(_SELF, NUM2INT(x), NUM2INT(y), NUM2ULONG(attr)) <0)
  130. rb_raise(rb_eRuntimeError, strerror(errno));
  131. return self;
  132. }
  133. static VALUE set_color_ansi(VALUE self, VALUE fg, VALUE bg)
  134. {
  135. if(cucul_set_color_ansi(_SELF, NUM2INT(fg), NUM2INT(bg)) <0)
  136. rb_raise(rb_eRuntimeError, strerror(errno));
  137. return self;
  138. }
  139. static VALUE set_color_argb(VALUE self, VALUE fg, VALUE bg)
  140. {
  141. if(cucul_set_color_argb(_SELF, NUM2UINT(fg), NUM2UINT(bg)) <0) {
  142. rb_raise(rb_eRuntimeError, strerror(errno));
  143. }
  144. return self;
  145. }
  146. static VALUE cprintf(int argc, VALUE* argv, VALUE self)
  147. {
  148. int x, y;
  149. VALUE rx, ry, format, rest, string;
  150. rb_scan_args(argc, argv, "3*", &rx, &ry, &format, &rest);
  151. x = NUM2INT(rx);
  152. y = NUM2INT(ry);
  153. string = rb_funcall2(rb_mKernel, rb_intern("sprintf"), argc-2, argv+2);
  154. cucul_put_str(_SELF, x, y, StringValuePtr(string));
  155. return self;
  156. }
  157. get_int(canvas_handle_x)
  158. get_int(canvas_handle_y)
  159. static VALUE set_canvas_handle(VALUE self, VALUE x, VALUE y)
  160. {
  161. cucul_set_canvas_handle(_SELF, NUM2INT(x), NUM2INT(y));
  162. return self;
  163. }
  164. static VALUE blit(int argc, VALUE* argv, VALUE self) {
  165. VALUE x, y, src, mask;
  166. cucul_canvas_t *csrc, *cmask;
  167. rb_scan_args(argc, argv, "31", &x, &y, &src, &mask);
  168. Check_Type(x, T_FIXNUM);
  169. Check_Type(y, T_FIXNUM);
  170. if(CLASS_OF(src) != cCanvas)
  171. {
  172. rb_raise(rb_eArgError, "src is not a Cucul::Canvas");
  173. }
  174. Data_Get_Struct(src, cucul_canvas_t, csrc);
  175. if(!NIL_P(mask))
  176. {
  177. if(CLASS_OF(mask) != cCanvas)
  178. {
  179. rb_raise(rb_eArgError, "mask is not a Cucul::Canvas");
  180. }
  181. Data_Get_Struct(mask, cucul_canvas_t, cmask);
  182. }
  183. else
  184. cmask = NULL;
  185. if(cucul_blit(_SELF, NUM2INT(x), NUM2INT(y), csrc, cmask)<0)
  186. rb_raise(rb_eRuntimeError, strerror(errno));
  187. return self;
  188. }
  189. static VALUE set_canvas_boundaries(VALUE self, VALUE x, VALUE y, VALUE w, VALUE h)
  190. {
  191. if(cucul_set_canvas_boundaries(_SELF, NUM2INT(x), NUM2INT(y), NUM2UINT(w), NUM2UINT(h))<0)
  192. {
  193. rb_raise(rb_eRuntimeError, strerror(errno));
  194. }
  195. return self;
  196. }
  197. /****/
  198. simple_func(invert)
  199. simple_func(flip)
  200. simple_func(flop)
  201. simple_func(rotate_180)
  202. simple_func(rotate_left)
  203. simple_func(rotate_right)
  204. simple_func(stretch_left)
  205. simple_func(stretch_right)
  206. /****/
  207. static VALUE draw_line(VALUE self, VALUE x1, VALUE y1, VALUE x2, VALUE y2, VALUE ch)
  208. {
  209. cucul_draw_line(_SELF, NUM2INT(x1), NUM2INT(y1), NUM2INT(x2), NUM2INT(y2),NUM2ULONG(ch));
  210. return self;
  211. }
  212. static VALUE draw_polyline(VALUE self, VALUE points, VALUE ch)
  213. {
  214. int i, n;
  215. int *ax, *ay;
  216. int error = 0;
  217. VALUE v, x, y;
  218. n = RARRAY(points)->len;
  219. ax = (int*)malloc(n*sizeof(int));
  220. if(!ax)
  221. rb_raise(rb_eNoMemError,"Out of memory");
  222. ay = (int*)malloc(n*sizeof(int));
  223. if(!ay)
  224. {
  225. free(ax);
  226. rb_raise(rb_eNoMemError,"Out of memory");
  227. }
  228. for(i=0; i<n; i++)
  229. {
  230. v = rb_ary_entry(points, i);
  231. if((TYPE(v) == T_ARRAY) && (RARRAY(v)->len == 2))
  232. {
  233. x = rb_ary_entry(v,0);
  234. y = rb_ary_entry(v,1);
  235. if(rb_obj_is_kind_of(x, rb_cInteger) &&
  236. rb_obj_is_kind_of(y, rb_cInteger))
  237. {
  238. ax[i] = NUM2INT(x);
  239. ay[i] = NUM2INT(y);
  240. } else
  241. error = 1;
  242. }
  243. else
  244. error = 1;
  245. }
  246. if(error)
  247. {
  248. free(ax);
  249. free(ay);
  250. rb_raise(rb_eArgError, "Invalid list of points");
  251. }
  252. n--;
  253. cucul_draw_polyline(_SELF, ax, ay, n, NUM2ULONG(ch));
  254. free(ax);
  255. free(ay);
  256. return self;
  257. }
  258. static VALUE draw_thin_line(VALUE self, VALUE x1, VALUE y1, VALUE x2, VALUE y2)
  259. {
  260. cucul_draw_thin_line(_SELF, NUM2INT(x1), NUM2INT(y1), NUM2INT(x2), NUM2INT(y2));
  261. return self;
  262. }
  263. static VALUE draw_thin_polyline(VALUE self, VALUE points)
  264. {
  265. int i, n;
  266. int *ax, *ay;
  267. int error = 0;
  268. VALUE v, x, y;
  269. n = RARRAY(points)->len;
  270. ax = (int*)malloc(n*sizeof(int));
  271. if(!ax)
  272. rb_raise(rb_eNoMemError,"Out of memory");
  273. ay = (int*)malloc(n*sizeof(int));
  274. if(!ay)
  275. {
  276. free(ax);
  277. rb_raise(rb_eNoMemError,"Out of memory");
  278. }
  279. for(i=0; i<n; i++)
  280. {
  281. v = rb_ary_entry(points, i);
  282. if((TYPE(v) == T_ARRAY) && (RARRAY(v)->len == 2))
  283. {
  284. x = rb_ary_entry(v,0);
  285. y = rb_ary_entry(v,1);
  286. if(rb_obj_is_kind_of(x, rb_cInteger) &&
  287. rb_obj_is_kind_of(y, rb_cInteger))
  288. {
  289. ax[i] = NUM2INT(x);
  290. ay[i] = NUM2INT(y);
  291. } else
  292. error = 1;
  293. }
  294. else
  295. error = 1;
  296. }
  297. if(error)
  298. {
  299. free(ax);
  300. free(ay);
  301. rb_raise(rb_eArgError, "Invalid list of points");
  302. }
  303. n--;
  304. cucul_draw_thin_polyline(_SELF, ax, ay, n);
  305. free(ax);
  306. free(ay);
  307. return self;
  308. }
  309. static VALUE draw_circle(VALUE self, VALUE x, VALUE y, VALUE r, VALUE ch)
  310. {
  311. cucul_draw_circle(_SELF, NUM2INT(x), NUM2INT(y), NUM2INT(r), NUM2ULONG(ch));
  312. return self;
  313. }
  314. static VALUE draw_ellipse(VALUE self, VALUE x, VALUE y, VALUE a, VALUE b, VALUE ch)
  315. {
  316. cucul_draw_ellipse(_SELF, NUM2INT(x), NUM2INT(y), NUM2INT(a), NUM2INT(b), NUM2ULONG(ch));
  317. return self;
  318. }
  319. static VALUE draw_thin_ellipse(VALUE self, VALUE x, VALUE y, VALUE a, VALUE b)
  320. {
  321. cucul_draw_thin_ellipse(_SELF, NUM2INT(x), NUM2INT(y), NUM2INT(a), NUM2INT(b));
  322. return self;
  323. }
  324. static VALUE fill_ellipse(VALUE self, VALUE x, VALUE y, VALUE a, VALUE b, VALUE ch)
  325. {
  326. cucul_fill_ellipse(_SELF, NUM2INT(x), NUM2INT(y), NUM2INT(a), NUM2INT(b), NUM2ULONG(ch));
  327. return self;
  328. }
  329. static VALUE draw_box(VALUE self, VALUE x, VALUE y, VALUE w, VALUE h, VALUE ch)
  330. {
  331. cucul_draw_box(_SELF, NUM2INT(x), NUM2INT(y), NUM2INT(w), NUM2INT(h), NUM2ULONG(ch));
  332. return self;
  333. }
  334. static VALUE draw_thin_box(VALUE self, VALUE x, VALUE y, VALUE w, VALUE h)
  335. {
  336. cucul_draw_thin_box(_SELF, NUM2INT(x), NUM2INT(y), NUM2INT(w), NUM2INT(h));
  337. return self;
  338. }
  339. static VALUE draw_cp437_box(VALUE self, VALUE x, VALUE y, VALUE w, VALUE h)
  340. {
  341. cucul_draw_cp437_box(_SELF, NUM2INT(x), NUM2INT(y), NUM2INT(w), NUM2INT(h));
  342. return self;
  343. }
  344. static VALUE fill_box(VALUE self, VALUE x, VALUE y, VALUE w, VALUE h, VALUE ch)
  345. {
  346. cucul_fill_box(_SELF, NUM2INT(x), NUM2INT(y), NUM2INT(w), NUM2INT(h), NUM2ULONG(ch));
  347. return self;
  348. }
  349. static VALUE draw_triangle(VALUE self, VALUE x1, VALUE y1, VALUE x2, VALUE y2, VALUE x3, VALUE y3, VALUE ch)
  350. {
  351. cucul_draw_triangle(_SELF, NUM2INT(x1), NUM2INT(y1), NUM2INT(x2), NUM2INT(y2), NUM2INT(x3), NUM2INT(y3), NUM2ULONG(ch));
  352. return self;
  353. }
  354. static VALUE draw_thin_triangle(VALUE self, VALUE x1, VALUE y1, VALUE x2, VALUE y2, VALUE x3, VALUE y3)
  355. {
  356. cucul_draw_thin_triangle(_SELF, NUM2INT(x1), NUM2INT(y1), NUM2INT(x2), NUM2INT(y2), NUM2INT(x3), NUM2INT(y3));
  357. return self;
  358. }
  359. static VALUE fill_triangle(VALUE self, VALUE x1, VALUE y1, VALUE x2, VALUE y2, VALUE x3, VALUE y3, VALUE ch)
  360. {
  361. cucul_fill_triangle(_SELF, NUM2INT(x1), NUM2INT(y1), NUM2INT(x2), NUM2INT(y2), NUM2INT(x3), NUM2INT(y3), NUM2ULONG(ch));
  362. return self;
  363. }
  364. static VALUE dither_bitmap(VALUE self, VALUE x, VALUE y, VALUE w, VALUE h, VALUE d, VALUE pixels)
  365. {
  366. if(CLASS_OF(d) != cDither)
  367. rb_raise(rb_eArgError, "d is not a Cucul::Dither");
  368. Check_Type(pixels, T_STRING);
  369. cucul_dither_bitmap(_SELF, NUM2INT(x), NUM2INT(y), NUM2INT(w), NUM2INT(h), DATA_PTR(d), StringValuePtr(pixels));
  370. return self;
  371. }
  372. /****/
  373. get_int(frame_count)
  374. static VALUE set_frame(VALUE self, VALUE id)
  375. {
  376. if(cucul_set_frame(_SELF, NUM2INT(id))<0)
  377. rb_raise(rb_eArgError, strerror(errno));
  378. return self;
  379. }
  380. static VALUE set_frame2(VALUE self, VALUE id)
  381. {
  382. set_frame(self, id);
  383. return self;
  384. }
  385. static VALUE get_frame_name(VALUE self)
  386. {
  387. return rb_str_new2(cucul_get_frame_name(_SELF));
  388. }
  389. static VALUE set_frame_name(VALUE self, VALUE name)
  390. {
  391. if(cucul_set_frame_name(_SELF, StringValuePtr(name))<0)
  392. rb_raise(rb_eRuntimeError, strerror(errno));
  393. return self;
  394. }
  395. static VALUE set_frame_name2(VALUE self, VALUE name)
  396. {
  397. set_frame_name(self, name);
  398. return self;
  399. }
  400. static VALUE create_frame(VALUE self, VALUE id)
  401. {
  402. if(cucul_create_frame(_SELF, NUM2INT(id))<0) {
  403. rb_raise(rb_eRuntimeError, strerror(errno));
  404. }
  405. return self;
  406. }
  407. static VALUE free_frame(VALUE self, VALUE id)
  408. {
  409. if(cucul_free_frame(_SELF, NUM2INT(id))<0) {
  410. rb_raise(rb_eArgError, strerror(errno));
  411. }
  412. return self;
  413. }
  414. /****/
  415. static VALUE render_canvas(VALUE self, VALUE font, VALUE width, VALUE height, VALUE pitch)
  416. {
  417. void *buf;
  418. cucul_font_t *f;
  419. VALUE b;
  420. if(CLASS_OF(font) != cFont)
  421. {
  422. rb_raise(rb_eArgError, "First argument is not a Cucul::Font");
  423. }
  424. buf = malloc(width*height*4);
  425. if(buf == NULL)
  426. {
  427. rb_raise(rb_eNoMemError, "Out of memory");
  428. }
  429. f = DATA_PTR(font);
  430. cucul_render_canvas(_SELF, f, buf, NUM2UINT(width), NUM2UINT(height), NUM2UINT(pitch));
  431. b = rb_str_new(buf, width*height*4);
  432. free(buf);
  433. return b;
  434. }
  435. static VALUE import_memory(VALUE self, VALUE data, VALUE format)
  436. {
  437. long int bytes;
  438. bytes = cucul_import_memory (_SELF, StringValuePtr(data), RSTRING(StringValue(data))->len, StringValuePtr(format));
  439. if(bytes <= 0)
  440. rb_raise(rb_eRuntimeError, strerror(errno));
  441. return self;
  442. }
  443. static VALUE import_file(VALUE self, VALUE filename, VALUE format)
  444. {
  445. long int bytes;
  446. bytes = cucul_import_file (_SELF, StringValuePtr(filename), StringValuePtr(format));
  447. if(bytes <= 0)
  448. rb_raise(rb_eRuntimeError, strerror(errno));
  449. return self;
  450. }
  451. static VALUE export_memory(VALUE self, VALUE format)
  452. {
  453. unsigned long int bytes;
  454. void *result;
  455. VALUE ret;
  456. result = cucul_export_memory (_SELF, StringValuePtr(format), &bytes);
  457. ret = rb_str_new(result, bytes);
  458. free(result);
  459. return ret;
  460. }
  461. get_singleton_double_list(export)
  462. get_singleton_double_list(import)
  463. /****/
  464. void Init_cucul_canvas(VALUE mCucul)
  465. {
  466. cCanvas = rb_define_class_under(mCucul, "Canvas", rb_cObject);
  467. rb_define_alloc_func(cCanvas, canvas_alloc);
  468. rb_define_method(cCanvas, "initialize", canvas_initialize, 2);
  469. rb_define_method(cCanvas, "width", get_canvas_width, 0);
  470. rb_define_method(cCanvas, "width=", set_canvas_width, 1);
  471. rb_define_method(cCanvas, "set_width", set_canvas_width2, 1);
  472. rb_define_method(cCanvas, "height", get_canvas_height, 0);
  473. rb_define_method(cCanvas, "height=", set_canvas_height, 1);
  474. rb_define_method(cCanvas, "set_height", set_canvas_height2, 1);
  475. rb_define_method(cCanvas, "set_size", set_canvas_size, 2);
  476. rb_define_method(cCanvas, "gotoxy", gotoxy, 2);
  477. rb_define_method(cCanvas, "cursor_x", get_cursor_x, 0);
  478. rb_define_method(cCanvas, "cursor_y", get_cursor_y, 0);
  479. rb_define_method(cCanvas, "handle_x", get_canvas_handle_x, 0);
  480. rb_define_method(cCanvas, "handle_y", get_canvas_handle_y, 0);
  481. rb_define_method(cCanvas, "set_handle", set_canvas_handle, 2);
  482. rb_define_method(cCanvas, "blit", blit, -1);
  483. rb_define_method(cCanvas, "set_boundaries", set_canvas_boundaries, 4);
  484. rb_define_method(cCanvas, "clear", clear_canvas, 0);
  485. rb_define_method(cCanvas, "put_char", put_char, 3);
  486. rb_define_method(cCanvas, "get_char", get_char, 2);
  487. rb_define_method(cCanvas, "put_str", put_str, 3);
  488. rb_define_method(cCanvas, "printf", cprintf, -1);
  489. rb_define_method(cCanvas, "get_attr", get_attr, 3);
  490. rb_define_method(cCanvas, "attr=", set_attr, 1);
  491. rb_define_method(cCanvas, "set_attr", set_attr2, 1);
  492. rb_define_method(cCanvas, "put_attr", put_attr, 3);
  493. rb_define_method(cCanvas, "set_color_ansi", set_color_ansi, 2);
  494. rb_define_method(cCanvas, "set_color_argb", set_color_argb, 2);
  495. rb_define_method(cCanvas, "invert", invert, 0);
  496. rb_define_method(cCanvas, "flip", flip, 0);
  497. rb_define_method(cCanvas, "flop", flop, 0);
  498. rb_define_method(cCanvas, "rotate_180", rotate_180, 0);
  499. rb_define_method(cCanvas, "rotate_left", rotate_left, 0);
  500. rb_define_method(cCanvas, "rotate_right", rotate_right, 0);
  501. rb_define_method(cCanvas, "stretch_left", stretch_left, 0);
  502. rb_define_method(cCanvas, "stretch_right", stretch_right, 0);
  503. rb_define_method(cCanvas, "draw_line", draw_line, 5);
  504. rb_define_method(cCanvas, "draw_polyline", draw_polyline, 2);
  505. rb_define_method(cCanvas, "draw_thin_line", draw_thin_line, 4);
  506. rb_define_method(cCanvas, "draw_thin_polyline", draw_thin_polyline, 1);
  507. rb_define_method(cCanvas, "draw_circle", draw_circle, 4);
  508. rb_define_method(cCanvas, "draw_ellipse", draw_ellipse, 5);
  509. rb_define_method(cCanvas, "draw_thin_ellipse", draw_thin_ellipse, 4);
  510. rb_define_method(cCanvas, "fill_ellipse", fill_ellipse, 5);
  511. rb_define_method(cCanvas, "draw_box", draw_box, 5);
  512. rb_define_method(cCanvas, "draw_thin_box", draw_thin_box, 4);
  513. rb_define_method(cCanvas, "draw_cp437_box", draw_cp437_box, 4);
  514. rb_define_method(cCanvas, "fill_box", fill_box, 5);
  515. rb_define_method(cCanvas, "draw_triangle", draw_triangle, 7);
  516. rb_define_method(cCanvas, "draw_thin_triangle", draw_thin_triangle, 6);
  517. rb_define_method(cCanvas, "fill_triangle", fill_triangle, 7);
  518. rb_define_method(cCanvas, "dither_bitmap", dither_bitmap, 6);
  519. rb_define_method(cCanvas, "frame_count", get_frame_count, 0);
  520. rb_define_method(cCanvas, "frame=", set_frame, 1);
  521. rb_define_method(cCanvas, "set_frame", set_frame2, 1);
  522. rb_define_method(cCanvas, "frame_name", get_frame_name, 0);
  523. rb_define_method(cCanvas, "frame_name=", set_frame_name, 1);
  524. rb_define_method(cCanvas, "set_frame_name", set_frame_name2, 1);
  525. rb_define_method(cCanvas, "create_frame", create_frame, 1);
  526. rb_define_method(cCanvas, "free_frame", free_frame, 1);
  527. rb_define_method(cCanvas, "render", render_canvas, 4);
  528. rb_define_method(cCanvas, "import_memory", import_memory, 2);
  529. rb_define_method(cCanvas, "import_file", import_file, 2);
  530. rb_define_method(cCanvas, "export_memory", export_memory, 1);
  531. rb_define_singleton_method(cCanvas, "export_list", export_list, 0);
  532. rb_define_singleton_method(cCanvas, "import_list", import_list, 0);
  533. }