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.

README 2.6 KiB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. This a Ruby binding for libcucul, libcaca will be added later.
  2. There is no real documentation but "methods" on any object should help you :)
  3. The only object available for now is Cucul::Canvas (meaning that only
  4. functions that have a cucul_canvas_t* as first argument except
  5. cucul_dither_bitmap are available).
  6. I tried to follow Ruby spirit meaning that :
  7. - most of the Cucul::Canvas methods return self
  8. - the methods set_foo with only an argument are also available as foo=
  9. (returning the value instead of self)
  10. - the methods originally named get_foo are available only as foo
  11. What is currently available is :
  12. $ irb -rcucul
  13. irb(main):001:0> Cucul.constants
  14. => ["BROWN", "BOLD", "GREEN", "LIGHTMAGENTA", "LIGHTBLUE", "BLINK",
  15. "MAGENTA", "DEFAULT", "TRANSPARENT", "BLUE", "LIGHTRED", "DARKGRAY",
  16. "UNDERLINE", "RED", "WHITE", "BLACK", "LIGHTCYAN", "LIGHTGRAY",
  17. "ITALICS", "CYAN", "YELLOW", "LIGHTGREEN", "Canvas"]
  18. irb(main):002:0> Cucul::Canvas.methods.sort -
  19. Cucul::Canvas.ancestors[1].methods
  20. => ["export_list", "import_list"]
  21. irb(main):003:0> Cucul::Canvas.instance_methods.sort -
  22. Cucul::Canvas.ancestors[1].instance_methods
  23. => ["attr=", "blit", "clear", "create_frame", "cursor_x", "cursor_y",
  24. "draw_box", "draw_circle", "draw_cp437_box", "draw_ellipse",
  25. "draw_line", "draw_polyline", "draw_thin_box", "draw_thin_ellipse",
  26. "draw_thin_line", "draw_thin_polyline", "draw_thin_triangle",
  27. "draw_triangle", "export_memory", "fill_box", "fill_ellipse",
  28. "fill_triangle", "flip", "flop", "frame=", "frame_count", "frame_name",
  29. "frame_name=", "free_frame", "get_attr", "get_char", "gotoxy",
  30. "handle_x", "handle_y", "height", "height=", "import_file",
  31. "import_memory", "invert", "printf", "put_attr", "put_char", "put_str",
  32. "rotate_180", "rotate_left", "rotate_right", "set_attr",
  33. "set_boundaries", "set_color_ansi", "set_color_argb", "set_frame",
  34. "set_frame_name", "set_handle", "set_height", "set_size", "set_width",
  35. "stretch_left", "stretch_right", "width", "width="]
  36. And here are sample uses :
  37. $ ruby -rcucul -e 'c=Cucul::Canvas.new(6, 3).fill_box(0,0,2,2,"#"[0]);
  38. c2=Cucul::Canvas.new(1, 1).put_str(0,0,"x"); c.blit(1,1,c2); puts
  39. c.export_memory("irc")'
  40. ###
  41. #x#
  42. ###
  43. $ ruby -e 'puts Cucul::Canvas.new(6,3).draw_thin_polyline([[0,0], [2,0],
  44. [5,2],[0,0]]).export_memory("irc")'
  45. -.
  46. | `.
  47. ----`-
  48. $ ruby -rcucul -e 'p Cucul::Canvas.export_list'
  49. [["caca", "native libcaca format"], ["ansi", "ANSI"], ["utf8", "UTF-8
  50. with ANSI escape codes"], ["utf8cr", "UTF-8 with ANSI escape codes and
  51. MS-DOS \\r"], ["html", "HTML"], ["html3", "backwards-compatible HTML"],
  52. ["irc", "IRC with mIRC colours"], ["ps", "PostScript document"], ["svg",
  53. "SVG vector image"], ["tga", "TGA image"]]