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.

caca-canvas.c 18 KiB

17 jaren geleden
17 jaren geleden
17 jaren geleden
17 jaren geleden
17 jaren geleden
17 jaren geleden
17 jaren geleden
17 jaren geleden
17 jaren geleden
17 jaren geleden
17 jaren geleden
17 jaren geleden
17 jaren geleden
17 jaren geleden
17 jaren geleden
17 jaren geleden
17 jaren geleden
17 jaren geleden
17 jaren geleden
17 jaren geleden
17 jaren geleden
17 jaren geleden
17 jaren geleden
17 jaren geleden
17 jaren geleden
17 jaren geleden
17 jaren geleden
17 jaren geleden
17 jaren geleden
17 jaren geleden
17 jaren geleden
17 jaren geleden
17 jaren geleden
17 jaren geleden
17 jaren geleden
17 jaren geleden
17 jaren geleden
17 jaren geleden
17 jaren geleden
17 jaren geleden
17 jaren geleden
17 jaren geleden
17 jaren geleden
17 jaren geleden
17 jaren geleden
17 jaren geleden
17 jaren geleden
17 jaren geleden
17 jaren geleden
17 jaren geleden
17 jaren geleden
17 jaren geleden
17 jaren geleden
17 jaren geleden
17 jaren geleden
17 jaren geleden
17 jaren geleden
17 jaren geleden
17 jaren geleden
17 jaren geleden
17 jaren geleden
17 jaren geleden
17 jaren geleden
17 jaren geleden
17 jaren geleden
17 jaren geleden
17 jaren geleden
17 jaren geleden
17 jaren geleden
17 jaren geleden
17 jaren geleden
17 jaren geleden
17 jaren geleden
17 jaren geleden
17 jaren geleden
17 jaren geleden
17 jaren geleden
17 jaren geleden
16 jaren geleden
17 jaren geleden
17 jaren geleden
17 jaren geleden
17 jaren geleden
17 jaren geleden
17 jaren geleden
17 jaren geleden
17 jaren geleden
17 jaren geleden
17 jaren geleden
17 jaren geleden
17 jaren geleden
17 jaren geleden
17 jaren geleden
17 jaren geleden
17 jaren geleden
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659
  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. static VALUE wherex(VALUE self)
  92. {
  93. return INT2NUM(caca_wherex(_SELF));
  94. }
  95. static VALUE wherey(VALUE self)
  96. {
  97. return INT2NUM(caca_wherey(_SELF));
  98. }
  99. simple_func(clear_canvas)
  100. static VALUE put_char(VALUE self, VALUE x, VALUE y, VALUE ch)
  101. {
  102. caca_put_char(_SELF, NUM2INT(x), NUM2INT(y), NUM2ULONG(ch));
  103. return self;
  104. }
  105. static VALUE get_char(VALUE self, VALUE x, VALUE y)
  106. {
  107. unsigned long int ch;
  108. ch = caca_get_char(_SELF, NUM2INT(x), NUM2INT(y));
  109. return INT2NUM(ch);
  110. }
  111. static VALUE put_str(VALUE self, VALUE x, VALUE y, VALUE str)
  112. {
  113. caca_put_str(_SELF, NUM2INT(x), NUM2INT(y), StringValuePtr(str));
  114. return self;
  115. }
  116. static VALUE get_attr(VALUE self, VALUE x, VALUE y)
  117. {
  118. unsigned long int ch;
  119. ch = caca_get_attr(_SELF, NUM2INT(x), NUM2INT(y));
  120. return INT2NUM(ch);
  121. }
  122. static VALUE set_attr(VALUE self, VALUE attr)
  123. {
  124. if(caca_set_attr(_SELF, NUM2ULONG(attr)) <0)
  125. rb_raise(rb_eRuntimeError, strerror(errno));
  126. return self;
  127. }
  128. static VALUE set_attr2(VALUE self, VALUE attr)
  129. {
  130. set_attr(self, attr);
  131. return self;
  132. }
  133. static VALUE put_attr(VALUE self, VALUE x, VALUE y, VALUE attr)
  134. {
  135. if(caca_put_attr(_SELF, NUM2INT(x), NUM2INT(y), NUM2ULONG(attr)) <0)
  136. rb_raise(rb_eRuntimeError, strerror(errno));
  137. return self;
  138. }
  139. static VALUE set_color_ansi(VALUE self, VALUE fg, VALUE bg)
  140. {
  141. if(caca_set_color_ansi(_SELF, NUM2INT(fg), NUM2INT(bg)) <0)
  142. rb_raise(rb_eRuntimeError, strerror(errno));
  143. return self;
  144. }
  145. static VALUE set_color_argb(VALUE self, VALUE fg, VALUE bg)
  146. {
  147. if(caca_set_color_argb(_SELF, NUM2UINT(fg), NUM2UINT(bg)) <0) {
  148. rb_raise(rb_eRuntimeError, strerror(errno));
  149. }
  150. return self;
  151. }
  152. static VALUE cprintf(int argc, VALUE* argv, VALUE self)
  153. {
  154. int x, y;
  155. VALUE rx, ry, format, rest, string;
  156. rb_scan_args(argc, argv, "3*", &rx, &ry, &format, &rest);
  157. x = NUM2INT(rx);
  158. y = NUM2INT(ry);
  159. string = rb_funcall2(rb_mKernel, rb_intern("sprintf"), argc-2, argv+2);
  160. caca_put_str(_SELF, x, y, StringValuePtr(string));
  161. return self;
  162. }
  163. get_int(canvas_handle_x)
  164. get_int(canvas_handle_y)
  165. static VALUE set_canvas_handle(VALUE self, VALUE x, VALUE y)
  166. {
  167. caca_set_canvas_handle(_SELF, NUM2INT(x), NUM2INT(y));
  168. return self;
  169. }
  170. static VALUE blit(int argc, VALUE* argv, VALUE self) {
  171. VALUE x, y, src, mask;
  172. caca_canvas_t *csrc, *cmask;
  173. rb_scan_args(argc, argv, "31", &x, &y, &src, &mask);
  174. Check_Type(x, T_FIXNUM);
  175. Check_Type(y, T_FIXNUM);
  176. if(CLASS_OF(src) != cCanvas)
  177. {
  178. rb_raise(rb_eArgError, "src is not a Caca::Canvas");
  179. }
  180. Data_Get_Struct(src, caca_canvas_t, csrc);
  181. if(!NIL_P(mask))
  182. {
  183. if(CLASS_OF(mask) != cCanvas)
  184. {
  185. rb_raise(rb_eArgError, "mask is not a Caca::Canvas");
  186. }
  187. Data_Get_Struct(mask, caca_canvas_t, cmask);
  188. }
  189. else
  190. cmask = NULL;
  191. if(caca_blit(_SELF, NUM2INT(x), NUM2INT(y), csrc, cmask)<0)
  192. rb_raise(rb_eRuntimeError, strerror(errno));
  193. return self;
  194. }
  195. static VALUE set_canvas_boundaries(VALUE self, VALUE x, VALUE y, VALUE w, VALUE h)
  196. {
  197. if(caca_set_canvas_boundaries(_SELF, NUM2INT(x), NUM2INT(y), NUM2UINT(w), NUM2UINT(h))<0)
  198. {
  199. rb_raise(rb_eRuntimeError, strerror(errno));
  200. }
  201. return self;
  202. }
  203. /****/
  204. simple_func(invert)
  205. simple_func(flip)
  206. simple_func(flop)
  207. simple_func(rotate_180)
  208. simple_func(rotate_left)
  209. simple_func(rotate_right)
  210. simple_func(stretch_left)
  211. simple_func(stretch_right)
  212. /****/
  213. static VALUE draw_line(VALUE self, VALUE x1, VALUE y1, VALUE x2, VALUE y2, VALUE ch)
  214. {
  215. caca_draw_line(_SELF, NUM2INT(x1), NUM2INT(y1), NUM2INT(x2), NUM2INT(y2),NUM2ULONG(ch));
  216. return self;
  217. }
  218. static VALUE draw_polyline(VALUE self, VALUE points, VALUE ch)
  219. {
  220. int i, n;
  221. int *ax, *ay;
  222. int error = 0;
  223. VALUE v, x, y;
  224. n = RARRAY(points)->len;
  225. ax = (int*)malloc(n*sizeof(int));
  226. if(!ax)
  227. rb_raise(rb_eNoMemError,"Out of memory");
  228. ay = (int*)malloc(n*sizeof(int));
  229. if(!ay)
  230. {
  231. free(ax);
  232. rb_raise(rb_eNoMemError,"Out of memory");
  233. }
  234. for(i=0; i<n; i++)
  235. {
  236. v = rb_ary_entry(points, i);
  237. if((TYPE(v) == T_ARRAY) && (RARRAY(v)->len == 2))
  238. {
  239. x = rb_ary_entry(v,0);
  240. y = rb_ary_entry(v,1);
  241. if(rb_obj_is_kind_of(x, rb_cInteger) &&
  242. rb_obj_is_kind_of(y, rb_cInteger))
  243. {
  244. ax[i] = NUM2INT(x);
  245. ay[i] = NUM2INT(y);
  246. } else
  247. error = 1;
  248. }
  249. else
  250. error = 1;
  251. }
  252. if(error)
  253. {
  254. free(ax);
  255. free(ay);
  256. rb_raise(rb_eArgError, "Invalid list of points");
  257. }
  258. n--;
  259. caca_draw_polyline(_SELF, ax, ay, n, NUM2ULONG(ch));
  260. free(ax);
  261. free(ay);
  262. return self;
  263. }
  264. static VALUE draw_thin_line(VALUE self, VALUE x1, VALUE y1, VALUE x2, VALUE y2)
  265. {
  266. caca_draw_thin_line(_SELF, NUM2INT(x1), NUM2INT(y1), NUM2INT(x2), NUM2INT(y2));
  267. return self;
  268. }
  269. static VALUE draw_thin_polyline(VALUE self, VALUE points)
  270. {
  271. int i, n;
  272. int *ax, *ay;
  273. int error = 0;
  274. VALUE v, x, y;
  275. n = RARRAY(points)->len;
  276. ax = (int*)malloc(n*sizeof(int));
  277. if(!ax)
  278. rb_raise(rb_eNoMemError,"Out of memory");
  279. ay = (int*)malloc(n*sizeof(int));
  280. if(!ay)
  281. {
  282. free(ax);
  283. rb_raise(rb_eNoMemError,"Out of memory");
  284. }
  285. for(i=0; i<n; i++)
  286. {
  287. v = rb_ary_entry(points, i);
  288. if((TYPE(v) == T_ARRAY) && (RARRAY(v)->len == 2))
  289. {
  290. x = rb_ary_entry(v,0);
  291. y = rb_ary_entry(v,1);
  292. if(rb_obj_is_kind_of(x, rb_cInteger) &&
  293. rb_obj_is_kind_of(y, rb_cInteger))
  294. {
  295. ax[i] = NUM2INT(x);
  296. ay[i] = NUM2INT(y);
  297. } else
  298. error = 1;
  299. }
  300. else
  301. error = 1;
  302. }
  303. if(error)
  304. {
  305. free(ax);
  306. free(ay);
  307. rb_raise(rb_eArgError, "Invalid list of points");
  308. }
  309. n--;
  310. caca_draw_thin_polyline(_SELF, ax, ay, n);
  311. free(ax);
  312. free(ay);
  313. return self;
  314. }
  315. static VALUE draw_circle(VALUE self, VALUE x, VALUE y, VALUE r, VALUE ch)
  316. {
  317. caca_draw_circle(_SELF, NUM2INT(x), NUM2INT(y), NUM2INT(r), NUM2ULONG(ch));
  318. return self;
  319. }
  320. static VALUE draw_ellipse(VALUE self, VALUE x, VALUE y, VALUE a, VALUE b, VALUE ch)
  321. {
  322. caca_draw_ellipse(_SELF, NUM2INT(x), NUM2INT(y), NUM2INT(a), NUM2INT(b), NUM2ULONG(ch));
  323. return self;
  324. }
  325. static VALUE draw_thin_ellipse(VALUE self, VALUE x, VALUE y, VALUE a, VALUE b)
  326. {
  327. caca_draw_thin_ellipse(_SELF, NUM2INT(x), NUM2INT(y), NUM2INT(a), NUM2INT(b));
  328. return self;
  329. }
  330. static VALUE fill_ellipse(VALUE self, VALUE x, VALUE y, VALUE a, VALUE b, VALUE ch)
  331. {
  332. caca_fill_ellipse(_SELF, NUM2INT(x), NUM2INT(y), NUM2INT(a), NUM2INT(b), NUM2ULONG(ch));
  333. return self;
  334. }
  335. static VALUE draw_box(VALUE self, VALUE x, VALUE y, VALUE w, VALUE h, VALUE ch)
  336. {
  337. caca_draw_box(_SELF, NUM2INT(x), NUM2INT(y), NUM2INT(w), NUM2INT(h), NUM2ULONG(ch));
  338. return self;
  339. }
  340. static VALUE draw_thin_box(VALUE self, VALUE x, VALUE y, VALUE w, VALUE h)
  341. {
  342. caca_draw_thin_box(_SELF, NUM2INT(x), NUM2INT(y), NUM2INT(w), NUM2INT(h));
  343. return self;
  344. }
  345. static VALUE draw_cp437_box(VALUE self, VALUE x, VALUE y, VALUE w, VALUE h)
  346. {
  347. caca_draw_cp437_box(_SELF, NUM2INT(x), NUM2INT(y), NUM2INT(w), NUM2INT(h));
  348. return self;
  349. }
  350. static VALUE fill_box(VALUE self, VALUE x, VALUE y, VALUE w, VALUE h, VALUE ch)
  351. {
  352. caca_fill_box(_SELF, NUM2INT(x), NUM2INT(y), NUM2INT(w), NUM2INT(h), NUM2ULONG(ch));
  353. return self;
  354. }
  355. static VALUE draw_triangle(VALUE self, VALUE x1, VALUE y1, VALUE x2, VALUE y2, VALUE x3, VALUE y3, VALUE ch)
  356. {
  357. caca_draw_triangle(_SELF, NUM2INT(x1), NUM2INT(y1), NUM2INT(x2), NUM2INT(y2), NUM2INT(x3), NUM2INT(y3), NUM2ULONG(ch));
  358. return self;
  359. }
  360. static VALUE draw_thin_triangle(VALUE self, VALUE x1, VALUE y1, VALUE x2, VALUE y2, VALUE x3, VALUE y3)
  361. {
  362. caca_draw_thin_triangle(_SELF, NUM2INT(x1), NUM2INT(y1), NUM2INT(x2), NUM2INT(y2), NUM2INT(x3), NUM2INT(y3));
  363. return self;
  364. }
  365. static VALUE fill_triangle(VALUE self, VALUE x1, VALUE y1, VALUE x2, VALUE y2, VALUE x3, VALUE y3, VALUE ch)
  366. {
  367. caca_fill_triangle(_SELF, NUM2INT(x1), NUM2INT(y1), NUM2INT(x2), NUM2INT(y2), NUM2INT(x3), NUM2INT(y3), NUM2ULONG(ch));
  368. return self;
  369. }
  370. static VALUE dither_bitmap(VALUE self, VALUE x, VALUE y, VALUE w, VALUE h, VALUE d, VALUE pixels)
  371. {
  372. if(CLASS_OF(d) != cDither)
  373. rb_raise(rb_eArgError, "d is not a Caca::Dither");
  374. Check_Type(pixels, T_STRING);
  375. caca_dither_bitmap(_SELF, NUM2INT(x), NUM2INT(y), NUM2INT(w), NUM2INT(h), DATA_PTR(d), StringValuePtr(pixels));
  376. return self;
  377. }
  378. /****/
  379. get_int(frame_count)
  380. static VALUE set_frame(VALUE self, VALUE id)
  381. {
  382. if(caca_set_frame(_SELF, NUM2INT(id))<0)
  383. rb_raise(rb_eArgError, strerror(errno));
  384. return self;
  385. }
  386. static VALUE set_frame2(VALUE self, VALUE id)
  387. {
  388. set_frame(self, id);
  389. return self;
  390. }
  391. static VALUE get_frame_name(VALUE self)
  392. {
  393. return rb_str_new2(caca_get_frame_name(_SELF));
  394. }
  395. static VALUE set_frame_name(VALUE self, VALUE name)
  396. {
  397. if(caca_set_frame_name(_SELF, StringValuePtr(name))<0)
  398. rb_raise(rb_eRuntimeError, strerror(errno));
  399. return self;
  400. }
  401. static VALUE set_frame_name2(VALUE self, VALUE name)
  402. {
  403. set_frame_name(self, name);
  404. return self;
  405. }
  406. static VALUE create_frame(VALUE self, VALUE id)
  407. {
  408. if(caca_create_frame(_SELF, NUM2INT(id))<0) {
  409. rb_raise(rb_eRuntimeError, strerror(errno));
  410. }
  411. return self;
  412. }
  413. static VALUE free_frame(VALUE self, VALUE id)
  414. {
  415. if(caca_free_frame(_SELF, NUM2INT(id))<0) {
  416. rb_raise(rb_eArgError, strerror(errno));
  417. }
  418. return self;
  419. }
  420. /****/
  421. static VALUE render_canvas(VALUE self, VALUE font, VALUE width, VALUE height, VALUE pitch)
  422. {
  423. void *buf;
  424. caca_font_t *f;
  425. VALUE b;
  426. if(CLASS_OF(font) != cFont)
  427. {
  428. rb_raise(rb_eArgError, "First argument is not a Caca::Font");
  429. }
  430. buf = malloc(width*height*4);
  431. if(buf == NULL)
  432. {
  433. rb_raise(rb_eNoMemError, "Out of memory");
  434. }
  435. f = DATA_PTR(font);
  436. caca_render_canvas(_SELF, f, buf, NUM2UINT(width), NUM2UINT(height), NUM2UINT(pitch));
  437. b = rb_str_new(buf, width*height*4);
  438. free(buf);
  439. return b;
  440. }
  441. static VALUE import_from_memory(VALUE self, VALUE data, VALUE format)
  442. {
  443. long int bytes;
  444. bytes = caca_import_canvas_from_memory (_SELF, StringValuePtr(data), RSTRING(StringValue(data))->len, StringValuePtr(format));
  445. if(bytes <= 0)
  446. rb_raise(rb_eRuntimeError, strerror(errno));
  447. return self;
  448. }
  449. static VALUE import_from_file(VALUE self, VALUE filename, VALUE format)
  450. {
  451. long int bytes;
  452. bytes = caca_import_canvas_from_file (_SELF, StringValuePtr(filename), StringValuePtr(format));
  453. if(bytes <= 0)
  454. rb_raise(rb_eRuntimeError, strerror(errno));
  455. return self;
  456. }
  457. static VALUE export_to_memory(VALUE self, VALUE format)
  458. {
  459. size_t bytes;
  460. void *result;
  461. VALUE ret;
  462. result = caca_export_canvas_to_memory (_SELF, StringValuePtr(format), &bytes);
  463. ret = rb_str_new(result, bytes);
  464. free(result);
  465. return ret;
  466. }
  467. get_singleton_double_list(export)
  468. get_singleton_double_list(import)
  469. /****/
  470. void Init_caca_canvas(VALUE mCaca)
  471. {
  472. cCanvas = rb_define_class_under(mCaca, "Canvas", rb_cObject);
  473. rb_define_alloc_func(cCanvas, canvas_alloc);
  474. rb_define_method(cCanvas, "initialize", canvas_initialize, 2);
  475. rb_define_method(cCanvas, "width", get_canvas_width, 0);
  476. rb_define_method(cCanvas, "width=", set_canvas_width, 1);
  477. rb_define_method(cCanvas, "set_width", set_canvas_width2, 1);
  478. rb_define_method(cCanvas, "height", get_canvas_height, 0);
  479. rb_define_method(cCanvas, "height=", set_canvas_height, 1);
  480. rb_define_method(cCanvas, "set_height", set_canvas_height2, 1);
  481. rb_define_method(cCanvas, "set_size", set_canvas_size, 2);
  482. rb_define_method(cCanvas, "gotoxy", gotoxy, 2);
  483. rb_define_method(cCanvas, "wherex", wherex, 0);
  484. rb_define_method(cCanvas, "wherey", wherey, 0);
  485. rb_define_method(cCanvas, "handle_x", get_canvas_handle_x, 0);
  486. rb_define_method(cCanvas, "handle_y", get_canvas_handle_y, 0);
  487. rb_define_method(cCanvas, "set_handle", set_canvas_handle, 2);
  488. rb_define_method(cCanvas, "blit", blit, -1);
  489. rb_define_method(cCanvas, "set_boundaries", set_canvas_boundaries, 4);
  490. rb_define_method(cCanvas, "clear", clear_canvas, 0);
  491. rb_define_method(cCanvas, "put_char", put_char, 3);
  492. rb_define_method(cCanvas, "get_char", get_char, 2);
  493. rb_define_method(cCanvas, "put_str", put_str, 3);
  494. rb_define_method(cCanvas, "printf", cprintf, -1);
  495. rb_define_method(cCanvas, "get_attr", get_attr, 3);
  496. rb_define_method(cCanvas, "attr=", set_attr, 1);
  497. rb_define_method(cCanvas, "set_attr", set_attr2, 1);
  498. rb_define_method(cCanvas, "put_attr", put_attr, 3);
  499. rb_define_method(cCanvas, "set_color_ansi", set_color_ansi, 2);
  500. rb_define_method(cCanvas, "set_color_argb", set_color_argb, 2);
  501. rb_define_method(cCanvas, "invert", invert, 0);
  502. rb_define_method(cCanvas, "flip", flip, 0);
  503. rb_define_method(cCanvas, "flop", flop, 0);
  504. rb_define_method(cCanvas, "rotate_180", rotate_180, 0);
  505. rb_define_method(cCanvas, "rotate_left", rotate_left, 0);
  506. rb_define_method(cCanvas, "rotate_right", rotate_right, 0);
  507. rb_define_method(cCanvas, "stretch_left", stretch_left, 0);
  508. rb_define_method(cCanvas, "stretch_right", stretch_right, 0);
  509. rb_define_method(cCanvas, "draw_line", draw_line, 5);
  510. rb_define_method(cCanvas, "draw_polyline", draw_polyline, 2);
  511. rb_define_method(cCanvas, "draw_thin_line", draw_thin_line, 4);
  512. rb_define_method(cCanvas, "draw_thin_polyline", draw_thin_polyline, 1);
  513. rb_define_method(cCanvas, "draw_circle", draw_circle, 4);
  514. rb_define_method(cCanvas, "draw_ellipse", draw_ellipse, 5);
  515. rb_define_method(cCanvas, "draw_thin_ellipse", draw_thin_ellipse, 4);
  516. rb_define_method(cCanvas, "fill_ellipse", fill_ellipse, 5);
  517. rb_define_method(cCanvas, "draw_box", draw_box, 5);
  518. rb_define_method(cCanvas, "draw_thin_box", draw_thin_box, 4);
  519. rb_define_method(cCanvas, "draw_cp437_box", draw_cp437_box, 4);
  520. rb_define_method(cCanvas, "fill_box", fill_box, 5);
  521. rb_define_method(cCanvas, "draw_triangle", draw_triangle, 7);
  522. rb_define_method(cCanvas, "draw_thin_triangle", draw_thin_triangle, 6);
  523. rb_define_method(cCanvas, "fill_triangle", fill_triangle, 7);
  524. rb_define_method(cCanvas, "dither_bitmap", dither_bitmap, 6);
  525. rb_define_method(cCanvas, "frame_count", get_frame_count, 0);
  526. rb_define_method(cCanvas, "frame=", set_frame, 1);
  527. rb_define_method(cCanvas, "set_frame", set_frame2, 1);
  528. rb_define_method(cCanvas, "frame_name", get_frame_name, 0);
  529. rb_define_method(cCanvas, "frame_name=", set_frame_name, 1);
  530. rb_define_method(cCanvas, "set_frame_name", set_frame_name2, 1);
  531. rb_define_method(cCanvas, "create_frame", create_frame, 1);
  532. rb_define_method(cCanvas, "free_frame", free_frame, 1);
  533. rb_define_method(cCanvas, "render", render_canvas, 4);
  534. rb_define_method(cCanvas, "import_from_memory", import_from_memory, 2);
  535. rb_define_method(cCanvas, "import_from_file", import_from_file, 2);
  536. rb_define_method(cCanvas, "export_to_memory", export_to_memory, 1);
  537. rb_define_singleton_method(cCanvas, "export_list", export_list, 0);
  538. rb_define_singleton_method(cCanvas, "import_list", import_list, 0);
  539. }