1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179
|
/** \page libcaca-ruby-api Libcaca Ruby API
\section classes Classes
The classes available for libcaca are :
\li\b Caca::Canvas : functions that have a caca_canvas_t* as first argument
\li\b Caca::Dither : functions that have a caca_dither_t* as first argument
\li\b Caca::Font : functions that have a caca_font_t* as first argument
(The constructor can currently only accept the name of a builtin font)
\li\b Caca::Display
\li\b Caca::Event
\li\b Caca::Event::Key
\li\b Caca::Event::Key::Press
\li\b Caca::Event::Key::Release
\li\b Caca::Event::Mouse
\li\b Caca::Event::Mouse::Press
\li\b Caca::Event::Mouse::Release
\li\b Caca::Event::Mouse::Motion
\li\b Caca::Event::Resize
\li\b Caca::Event::Quit
The character set conversion functions are not available yet in the binding.
\code
$ irb -rcaca
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
\endcode
\code
irb(main):009:0> Caca.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"]
\endcode
\code
irb(main):010:0> Caca.my_methods
=> ["version"]
\endcode
\code
irb(main):011:0> Caca::Canvas.my_methods
=> ["export_list", "import_list"]
\endcode
\code
irb(main):012:0> Caca::Canvas.my_instance_methods
=> ["attr=", "blit", "clear", "create_frame",
"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_to_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_from_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", "wherex", "wherey", "width", "width="]
\endcode
\code
irb(main):013:0> Caca::Font.my_methods
=> ["list"]
\endcode
\code
irb(main):014:0> Caca::Font.my_instance_methods
=> ["blocks", "height", "width"]
\endcode
\code
irb(main):015:0> Caca::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"]
\endcode
\code
irb(main):010:0> Caca::Display.my_instance_methods
=> ["canvas", "get_event", "height", "mouse=", "mouse_x", "mouse_y", "refresh",
"set_mouse", "set_time", "set_title", "time", "time=", "title=", "width"]
\endcode
\code
irb(main):011:0> Caca::Event.constants
=> ["Key", "Quit", "TYPE", "Mouse", "Resize"]
\endcode
\code
irb(main):012:0> Caca::Event.my_instance_methods
=> ["quit?"]
\endcode
\code
irb(main):013:0> Caca::Event::Key.my_instance_methods
=> ["ch", "utf32", "utf8"]
\endcode
\code
irb(main):014:0> Caca::Event::Mouse.my_instance_methods
=> ["button", "x", "y"]
\endcode
\code
irb(main):015:0> Caca::Event::Resize.my_instance_methods
=> ["w", "h"]
\endcode
\section Samples
\code
$ ruby -rcaca -e 'c=Caca::Canvas.new(6, 3).fill_box(0,0,2,2,"#"[0]);
c2=Caca::Canvas.new(1,1).put_str(0,0,"x"); c.blit(1,1,c2); puts
c.export_to_memory("irc")'
###
#x#
###
\endcode
\code
$ ruby -e 'puts Caca::Canvas.new(6,3).draw_thin_polyline([[0,0], [0,2],
[5,2],[0,0]]).export_to_memory("irc")'
-.
| `.
----`-
\endcode
\code
$ ruby -rcaca -e 'p Caca::Canvas.export_list'
[["caca", "native libcaca format"], ["ansi", "ANSI"], ["utf8", "UTF-8
withANSI 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",
"SVGvector image"], ["tga", "TGA image"]]
\endcode
\code
$ ruby -rcaca -e 'p Caca::Font.list'
["Monospace9", "Monospace Bold 12"]
\endcode
\code
require 'caca'
c = Caca::Canvas.new(20,10)
c.put_str(2,3, "plop!")
c.draw_thin_polyline([[0,0],[0,2], [5,2], [0,0]])
d = Caca::Display.new(c)
d.title= "Test !"
d.refresh
#Redefine Event::Key#quit? so that q, Q, and Esc become exit keys
module Caca
class Event::Key
def quit?
"qQ^[".split('').member?(@ch.chr)
end
end
end
while((e= d.get_event(Caca::Event, -1)) && ! e.quit?)
p e
d.refresh
end
\endcode
*/
|