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.

cucul-canvas.c 18 KiB

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