You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

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