source: libcaca/trunk/ruby/README @ 1997

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