source: libcaca/trunk/ruby/ruby-cucul.dox @ 2048

Last change on this file since 2048 was 2048, checked in by Pascal Terjan, 12 years ago
  • Little improvements in ruby doc + Made the doc a little more easy to read + Added an example on a nice way to have q, Q and Esc to cause exit
File size: 3.4 KB
RevLine 
[2033]1/* $Id$ */ /** \page libcucul-ruby-api Libcucul Ruby API
2The classes available for libcucul are :
3
4\li \b Cucul::Canvas : functions that have a cucul_canvas_t* as first argument
5
6\li \b Cucul::Dither : functions that have a cucul_dither_t* as first argument
7
8\li \b Cucul::Font : functions that have a cucul_font_t* as first argument
9 (The constructor can currently only accept the name of a builtin font)
10
11The character set conversion functions are not available yet in the binding.
12
13\code
14$ irb -rcucul
[2048]15irb(main):001:0> class Object
16irb(main):002:1>   def Object.my_instance_methods
17irb(main):003:2>     instance_methods.sort - ancestors[1].instance_methods
18irb(main):004:2>   end
19irb(main):005:1>   def Object.my_methods
20irb(main):006:2>     methods.sort - ancestors[1].methods
21irb(main):007:2>   end
22irb(main):008:1> end
23
24irb(main):009:0> Cucul.constants
[2033]25=> ["BROWN", "BOLD", "GREEN", "LIGHTMAGENTA", "LIGHTBLUE", "BLINK",
26"MAGENTA", "DEFAULT", "TRANSPARENT", "BLUE", "LIGHTRED", "DARKGRAY",
27"UNDERLINE", "RED", "WHITE", "BLACK", "LIGHTCYAN", "LIGHTGRAY",
28"ITALICS", "CYAN", "YELLOW", "LIGHTGREEN", "Canvas", "Dither", "Font"]
29\endcode
30
31\code
[2048]32irb(main):010:0> Cucul::Canvas.my_methods
[2033]33=> ["export_list", "import_list"]
34\endcode
35
36\code
[2048]37irb(main):003:0> Cucul::Canvas.my_instance_methods
[2033]38=> ["attr=", "blit", "clear", "create_frame", "cursor_x", "cursor_y",
39"dither_bitmap", "draw_box", "draw_circle", "draw_cp437_box", "draw_ellipse",
40"draw_line", "draw_polyline", "draw_thin_box", "draw_thin_ellipse",
41"draw_thin_line", "draw_thin_polyline", "draw_thin_triangle",
42"draw_triangle", "export_memory", "fill_box", "fill_ellipse",
43"fill_triangle", "flip", "flop", "frame=", "frame_count", "frame_name",
44"frame_name=", "free_frame", "get_attr", "get_char", "gotoxy",
45"handle_x", "handle_y", "height", "height=", "import_file",
46"import_memory", "invert", "printf", "put_attr", "put_char", "put_str",
47"rotate_180", "rotate_left", "rotate_right", "set_attr",
48"set_boundaries", "set_color_ansi", "set_color_argb", "set_frame",
49"set_frame_name", "set_handle", "set_height", "set_size", "set_width",
50"stretch_left", "stretch_right", "width", "width="]
51\endcode
52
53\code
[2048]54irb(main):004:0> Cucul::Font.my_methods
[2033]55=> ["list"]
56\endcode
57
58\code
[2048]59irb(main):005:0> Cucul::Font.my_instance_methods
[2033]60=> ["blocks", "height", "width"]
61\endcode
62
63\code
[2048]64irb(main):006:0> Cucul::Dither.my_instance_methods
[2033]65=> ["algorithm=", "algorithm_list", "antialias=", "antialias_list",
66"brightness=", "charset=", "charset_list", "color=", "color_list",
67"contrast=", "gamma=", "palette=", "set_algorithm", "set_antialias",
68"set_brightness", "set_charset", "set_color", "set_contrast",
69"set_gamma", "set_palette"]
70\endcode
71
72\section Samples
73
74\code
75$ ruby -rcucul -e 'c=Cucul::Canvas.new(6, 3).fill_box(0,0,2,2,"#"[0]);
76c2=Cucul::Canvas.new(1, 1).put_str(0,0,"x"); c.blit(1,1,c2); puts
77c.export_memory("irc")'
78###   
79#x#   
80### 
81\endcode
82
83\code
84$ ruby -e 'puts Cucul::Canvas.new(6,3).draw_thin_polyline([[0,0], [0,2],
85[5,2],[0,0]]).export_memory("irc")'
86-.   
87| `. 
88----`-
89\endcode
90
91\code
92$ ruby -rcucul -e 'p Cucul::Canvas.export_list'
93[["caca", "native libcaca format"], ["ansi", "ANSI"], ["utf8", "UTF-8
94with ANSI escape codes"], ["utf8cr", "UTF-8 with ANSI escape codes and
95MS-DOS \\r"], ["html", "HTML"], ["html3", "backwards-compatible HTML"],
96["irc", "IRC with mIRC colours"], ["ps", "PostScript document"], ["svg",
97"SVG vector image"], ["tga", "TGA image"]]
98\endcode
99
100\code
101$ ruby -rcucul -e 'p Cucul::Font.list'
102["Monospace 9", "Monospace Bold 12"]
103\endcode
104
105*/
Note: See TracBrowser for help on using the repository browser.