您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

caca-canvas.c 18 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652
  1. /*
  2. * libcaca 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 <caca.h>
  13. #include <errno.h>
  14. #include "caca-dither.h"
  15. #include "caca-font.h"
  16. #include "common.h"
  17. VALUE cCanvas;
  18. #define simple_func(x) \
  19. static VALUE x (VALUE self) \
  20. { \
  21. if( caca_##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(caca_get_##x (_SELF)); \
  30. }
  31. static void canvas_free(void * p)
  32. {
  33. caca_free_canvas((caca_canvas_t *)p);
  34. }
  35. static VALUE canvas_alloc(VALUE klass)
  36. {
  37. VALUE obj;
  38. obj = Data_Wrap_Struct(klass, NULL, canvas_free, NULL);
  39. return obj;
  40. }
  41. VALUE canvas_create(caca_canvas_t *canvas)
  42. {
  43. return Data_Wrap_Struct(cCanvas, NULL, NULL, canvas);
  44. }
  45. static VALUE canvas_initialize(VALUE self, VALUE width, VALUE height)
  46. {
  47. caca_canvas_t *canvas;
  48. canvas = caca_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. caca_set_canvas_size(_SELF, NUM2INT(width), caca_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. caca_set_canvas_size(_SELF, caca_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. caca_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( caca_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. caca_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 = caca_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. caca_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 = caca_get_attr(_SELF, NUM2INT(x), NUM2INT(y));
  114. return INT2NUM(ch);
  115. }
  116. static VALUE set_attr(VALUE self, VALUE attr)
  117. {
  118. if(caca_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(caca_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(caca_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(caca_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. caca_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. caca_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. caca_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 Caca::Canvas");
  173. }
  174. Data_Get_Struct(src, caca_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 Caca::Canvas");
  180. }
  181. Data_Get_Struct(mask, caca_canvas_t, cmask);
  182. }
  183. else
  184. cmask = NULL;
  185. if(caca_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(caca_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. caca_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. caca_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. caca_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. caca_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. caca_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. caca_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. caca_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. caca_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. caca_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. caca_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. caca_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. caca_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. caca_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. caca_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. caca_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 Caca::Dither");
  368. Check_Type(pixels, T_STRING);
  369. caca_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(caca_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(caca_get_frame_name(_SELF));
  388. }
  389. static VALUE set_frame_name(VALUE self, VALUE name)
  390. {
  391. if(caca_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(caca_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(caca_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. caca_font_t *f;
  419. VALUE b;
  420. if(CLASS_OF(font) != cFont)
  421. {
  422. rb_raise(rb_eArgError, "First argument is not a Caca::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. caca_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_from_memory(VALUE self, VALUE data, VALUE format)
  436. {
  437. long int bytes;
  438. bytes = caca_import_canvas_from_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_from_file(VALUE self, VALUE filename, VALUE format)
  444. {
  445. long int bytes;
  446. bytes = caca_import_canvas_from_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_to_memory(VALUE self, VALUE format)
  452. {
  453. size_t bytes;
  454. void *result;
  455. VALUE ret;
  456. result = caca_export_canvas_to_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_caca_canvas(VALUE mCaca)
  465. {
  466. cCanvas = rb_define_class_under(mCaca, "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_from_memory", import_from_memory, 2);
  529. rb_define_method(cCanvas, "import_from_file", import_from_file, 2);
  530. rb_define_method(cCanvas, "export_to_memory", export_to_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. }