source: libcaca/trunk/ruby/README @ 1983

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