Libcucul Ruby API

The classes available for libcucul are :

The character set conversion functions are not available yet in the binding.

$ irb -rcucul
irb(main):001:0> class Object
irb(main):002:1>   def Object.my_instance_methods
irb(main):003:2>     instance_methods.sort - ancestors[1].instance_methods
irb(main):004:2>   end
irb(main):005:1>   def Object.my_methods
irb(main):006:2>     methods.sort - ancestors[1].methods
irb(main):007:2>   end
irb(main):008:1> end

irb(main):009:0> Cucul.constants
=> ["BROWN", "BOLD", "GREEN", "LIGHTMAGENTA", "LIGHTBLUE", "BLINK",
"MAGENTA", "DEFAULT", "TRANSPARENT", "BLUE", "LIGHTRED", "DARKGRAY",
"UNDERLINE", "RED", "WHITE", "BLACK", "LIGHTCYAN", "LIGHTGRAY",
"ITALICS", "CYAN", "YELLOW", "LIGHTGREEN", "Canvas", "Dither", "Font"]

irb(main):010:0> Cucul.my_methods
=> ["version"]

irb(main):011:0> Cucul::Canvas.my_methods
=> ["export_list", "import_list"]

irb(main):012:0> Cucul::Canvas.my_instance_methods
=> ["attr=", "blit", "clear", "create_frame", "cursor_x", "cursor_y",
"dither_bitmap", "draw_box", "draw_circle", "draw_cp437_box", "draw_ellipse",
"draw_line", "draw_polyline", "draw_thin_box", "draw_thin_ellipse",
"draw_thin_line", "draw_thin_polyline", "draw_thin_triangle",
"draw_triangle", "export_memory", "fill_box", "fill_ellipse",
"fill_triangle", "flip", "flop", "frame=", "frame_count", "frame_name",
"frame_name=", "free_frame", "get_attr", "get_char", "gotoxy",
"handle_x", "handle_y", "height", "height=", "import_file",
"import_memory", "invert", "printf", "put_attr", "put_char", "put_str",
"rotate_180", "rotate_left", "rotate_right", "set_attr",
"set_boundaries", "set_color_ansi", "set_color_argb", "set_frame",
"set_frame_name", "set_handle", "set_height", "set_size", "set_width",
"stretch_left", "stretch_right", "width", "width="]

irb(main):013:0> Cucul::Font.my_methods
=> ["list"]

irb(main):014:0> Cucul::Font.my_instance_methods
=> ["blocks", "height", "width"]

irb(main):015:0> Cucul::Dither.my_instance_methods
=> ["algorithm=", "algorithm_list", "antialias=", "antialias_list",
"brightness=", "charset=", "charset_list", "color=", "color_list",
"contrast=", "gamma=", "palette=", "set_algorithm", "set_antialias",
"set_brightness", "set_charset", "set_color", "set_contrast",
"set_gamma", "set_palette"]

Samples

$ ruby -rcucul -e 'c=Cucul::Canvas.new(6, 3).fill_box(0,0,2,2,"#"[0]);
c2=Cucul::Canvas.new(1, 1).put_str(0,0,"x"); c.blit(1,1,c2); puts
c.export_memory("irc")'
###   
#x#   
###  

$ ruby -e 'puts Cucul::Canvas.new(6,3).draw_thin_polyline([[0,0], [0,2],
[5,2],[0,0]]).export_memory("irc")' 
-.    
| `.  
----`-

$ ruby -rcucul -e 'p Cucul::Canvas.export_list'
[["caca", "native libcaca format"], ["ansi", "ANSI"], ["utf8", "UTF-8
with ANSI escape codes"], ["utf8cr", "UTF-8 with ANSI escape codes and
MS-DOS \\r"], ["html", "HTML"], ["html3", "backwards-compatible HTML"],
["irc", "IRC with mIRC colours"], ["ps", "PostScript document"], ["svg",
"SVG vector image"], ["tga", "TGA image"]]

$ ruby -rcucul -e 'p Cucul::Font.list'
["Monospace 9", "Monospace Bold 12"]