source: libcaca/trunk/ruby/README @ 2009

Last change on this file since 2009 was 2009, checked in by Pascal Terjan, 12 years ago
  • Finish Cucul::Dither
File size: 3.7 KB
Line 
1/* $Id$ */ /** \page libcaca-ruby Libcaca ruby bindings
2
3This a Ruby binding for libcucul, libcaca will be added later.
4
5There is no real documentation but "methods" on any object should help you :)
6
7The objects available are :
8
9- Cucul::Canvas (functions that have a cucul_canvas_t* as first argument)
10
11- Cucul::Dither (functions that have a cucul_dither_t* as first argument)
12
13- Cucul::Font (functions that have a cucul_font_t* as first argument)
14 * The constructor can currently only accept the name of a builtin font
15
16The character set conversion functions are not available yet in the binding.
17
18I tried to follow Ruby spirit meaning that :
19- most of the methods return self
20- the methods set_foo with only an argument are also available as foo=
21(returning the value instead of self)
22- the methods originally named get_foo are available only as foo
23
24What is currently available is :
25
26\code
27$ irb -rcucul
28irb(main):001:0> Cucul.constants
29=> ["BROWN", "BOLD", "GREEN", "LIGHTMAGENTA", "LIGHTBLUE", "BLINK",
30"MAGENTA", "DEFAULT", "TRANSPARENT", "BLUE", "LIGHTRED", "DARKGRAY",
31"UNDERLINE", "RED", "WHITE", "BLACK", "LIGHTCYAN", "LIGHTGRAY",
32"ITALICS", "CYAN", "YELLOW", "LIGHTGREEN", "Canvas", "Dither", "Font"]
33\endcode
34
35\code
36irb(main):002:0> Cucul::Canvas.methods.sort -
37Cucul::Canvas.ancestors[1].methods
38=> ["export_list", "import_list"]
39\endcode
40
41\code
42irb(main):003:0> Cucul::Canvas.instance_methods.sort -
43Cucul::Canvas.ancestors[1].instance_methods
44=> ["attr=", "blit", "clear", "create_frame", "cursor_x", "cursor_y",
45"draw_box", "draw_circle", "draw_cp437_box", "draw_ellipse",
46"draw_line", "draw_polyline", "draw_thin_box", "draw_thin_ellipse",
47"draw_thin_line", "draw_thin_polyline", "draw_thin_triangle",
48"draw_triangle", "export_memory", "fill_box", "fill_ellipse",
49"fill_triangle", "flip", "flop", "frame=", "frame_count", "frame_name",
50"frame_name=", "free_frame", "get_attr", "get_char", "gotoxy",
51"handle_x", "handle_y", "height", "height=", "import_file",
52"import_memory", "invert", "printf", "put_attr", "put_char", "put_str",
53"rotate_180", "rotate_left", "rotate_right", "set_attr",
54"set_boundaries", "set_color_ansi", "set_color_argb", "set_frame",
55"set_frame_name", "set_handle", "set_height", "set_size", "set_width",
56"stretch_left", "stretch_right", "width", "width="]
57\endcode
58
59\code
60irb(main):004:0> Cucul::Font.methods.sort -
61Cucul::Font.ancestors[1].methods
62=> ["list"]
63\endcode
64
65\code
66irb(main):005:0> Cucul::Font.instance_methods.sort -
67Cucul::Font.ancestors[1].instance_methods
68=> ["blocks", "height", "width"]
69\endcode
70
71\code
72irb(main):006:0> Cucul::Dither.instance_methods.sort -
73Cucul::Dither.ancestors[1].instance_methods
74=> ["algorithm=", "algorithm_list", "antialias=", "antialias_list",
75"brightness=", "charset=", "charset_list", "color=", "color_list",
76"contrast=", "gamma=", "palette=", "set_algorithm", "set_antialias",
77"set_brightness", "set_charset", "set_color", "set_contrast",
78"set_gamma", "set_palette"]
79\endcode
80
81And here are sample uses :
82
83\code
84$ ruby -rcucul -e 'c=Cucul::Canvas.new(6, 3).fill_box(0,0,2,2,"#"[0]);
85c2=Cucul::Canvas.new(1, 1).put_str(0,0,"x"); c.blit(1,1,c2); puts
86c.export_memory("irc")'
87###   
88#x#   
89### 
90\endcode
91
92\code
93$ ruby -e 'puts Cucul::Canvas.new(6,3).draw_thin_polyline([[0,0], [2,0],
94[5,2],[0,0]]).export_memory("irc")'
95-.   
96| `. 
97----`-
98\endcode
99
100\code
101$ ruby -rcucul -e 'p Cucul::Canvas.export_list'
102[["caca", "native libcaca format"], ["ansi", "ANSI"], ["utf8", "UTF-8
103with ANSI escape codes"], ["utf8cr", "UTF-8 with ANSI escape codes and
104MS-DOS \\r"], ["html", "HTML"], ["html3", "backwards-compatible HTML"],
105["irc", "IRC with mIRC colours"], ["ps", "PostScript document"], ["svg",
106"SVG vector image"], ["tga", "TGA image"]]
107\endcode
108
109\code
110$ ruby -rcucul -e 'p Cucul::Font.list'
111["Monospace 9", "Monospace Bold 12"]
112\endcode
113
114*/
Note: See TracBrowser for help on using the repository browser.