Changeset 2822 for libcaca/trunk/ruby/ruby-caca.dox
- Timestamp:
- Sep 27, 2008, 4:11:36 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcaca/trunk/ruby/ruby-caca.dox
r2093 r2822 1 /* 1 /*$Id$ */ /** \page libcaca-ruby-api Libcaca Ruby API 2 2 3 The 3 Theclasses available for libcaca are : 4 4 5 \li \b Caca::Display 6 \li \b Caca::Event 7 \li \b Caca::Event::Key 8 \li \b Caca::Event::Key::Press 9 \li \b Caca::Event::Key::Release 10 \li \b Caca::Event::Mouse 11 \li \b Caca::Event::Mouse::Press 12 \li \b Caca::Event::Mouse::Release 13 \li \b Caca::Event::Mouse::Motion 14 \li \b Caca::Event::Resize 15 \li \b Caca::Event::Quit 5 \li\b Caca::Canvas : functions that have a caca_canvas_t* as first argument 6 \li\b Caca::Dither : functions that have a caca_dither_t* as first argument 7 \li\b Caca::Font : functions that have a caca_font_t* as first argument 8 (The constructor can currently only accept the name of a builtin font) 9 \li\b Caca::Display 10 \li\b Caca::Event 11 \li\b Caca::Event::Key 12 \li\b Caca::Event::Key::Press 13 \li\b Caca::Event::Key::Release 14 \li\b Caca::Event::Mouse 15 \li\b Caca::Event::Mouse::Press 16 \li\b Caca::Event::Mouse::Release 17 \li\b Caca::Event::Mouse::Motion 18 \li\b Caca::Event::Resize 19 \li\b Caca::Event::Quit 20 21 Thecharacter set conversion functions are not available yet in the binding. 16 22 17 23 \code 18 $ 19 irb(main):001:0> 20 irb(main):002:1> 21 irb(main):003:2> 22 irb(main):004:2> 23 irb(main):005:1> 24 irb(main):006:2> 25 irb(main):007:2> 26 irb(main):008:1> 24 $irb -rcaca 25 irb(main):001:0>class Object 26 irb(main):002:1>def Object.my_instance_methods 27 irb(main):003:2>instance_methods.sort - ancestors[1].instance_methods 28 irb(main):004:2>end 29 irb(main):005:1>def Object.my_methods 30 irb(main):006:2>methods.sort - ancestors[1].methods 31 irb(main):007:2>end 32 irb(main):008:1>end 27 33 \endcode 28 34 29 35 \code 30 irb(main):009:0> Caca.my_methods 31 => ["version"] 36 irb(main):009:0>Caca.constants 37 =>["BROWN", "BOLD", "GREEN", "LIGHTMAGENTA", "LIGHTBLUE", "BLINK", 38 "MAGENTA","DEFAULT", "TRANSPARENT", "BLUE", "LIGHTRED", "DARKGRAY", 39 "UNDERLINE","RED", "WHITE", "BLACK", "LIGHTCYAN", "LIGHTGRAY", 40 "ITALICS","CYAN", "YELLOW", "LIGHTGREEN", "Canvas", "Dither", "Font"] 32 41 \endcode 33 42 34 43 \code 35 irb(main):010:0> Caca::Display.my_instance_methods 36 => ["canvas", "get_event", "height", "mouse=", "mouse_x", "mouse_y", "refresh", 37 "set_mouse", "set_time", "set_title", "time", "time=", "title=", "width"] 44 irb(main):010:0>Caca.my_methods 45 =>["version"] 38 46 \endcode 39 47 40 48 \code 41 irb(main):011:0> Caca::Event.constants42 => ["Key", "Quit", "TYPE", "Mouse", "Resize"]49 irb(main):011:0>Caca::Canvas.my_methods 50 =>["export_list", "import_list"] 43 51 \endcode 44 52 45 53 \code 46 irb(main):012:0> Caca::Event.my_instance_methods 47 => ["quit?"] 54 irb(main):012:0>Caca::Canvas.my_instance_methods 55 =>["attr=", "blit", "clear", "create_frame", "cursor_x", "cursor_y", 56 "dither_bitmap","draw_box", "draw_circle", "draw_cp437_box", "draw_ellipse", 57 "draw_line","draw_polyline", "draw_thin_box", "draw_thin_ellipse", 58 "draw_thin_line","draw_thin_polyline", "draw_thin_triangle", 59 "draw_triangle","export_memory", "fill_box", "fill_ellipse", 60 "fill_triangle","flip", "flop", "frame=", "frame_count", "frame_name", 61 "frame_name=","free_frame", "get_attr", "get_char", "gotoxy", 62 "handle_x","handle_y", "height", "height=", "import_file", 63 "import_memory","invert", "printf", "put_attr", "put_char", "put_str", 64 "rotate_180","rotate_left", "rotate_right", "set_attr", 65 "set_boundaries","set_color_ansi", "set_color_argb", "set_frame", 66 "set_frame_name","set_handle", "set_height", "set_size", "set_width", 67 "stretch_left","stretch_right", "width", "width="] 48 68 \endcode 49 69 50 70 \code 51 irb(main):013:0> Caca::Event::Key.my_instance_methods52 => ["ch", "utf32", "utf8"]71 irb(main):013:0>Caca::Font.my_methods 72 =>["list"] 53 73 \endcode 54 74 55 75 \code 56 irb(main):014:0> Caca::Event::Mouse.my_instance_methods57 => ["button", "x", "y"]76 irb(main):014:0>Caca::Font.my_instance_methods 77 =>["blocks", "height", "width"] 58 78 \endcode 59 79 60 80 \code 61 irb(main):015:0> Caca::Event::Resize.my_instance_methods 62 => ["w", "h"] 81 irb(main):015:0>Caca::Dither.my_instance_methods 82 =>["algorithm=", "algorithm_list", "antialias=", "antialias_list", 83 "brightness=","charset=", "charset_list", "color=", "color_list", 84 "contrast=","gamma=", "palette=", "set_algorithm", "set_antialias", 85 "set_brightness","set_charset", "set_color", "set_contrast", 86 "set_gamma","set_palette"] 63 87 \endcode 64 88 65 \section Samples 89 \code 90 irb(main):010:0>Caca::Display.my_instance_methods 91 =>["canvas", "get_event", "height", "mouse=", "mouse_x", "mouse_y", "refresh", 92 "set_mouse","set_time", "set_title", "time", "time=", "title=", "width"] 93 \endcode 66 94 67 95 \code 68 require 'caca' 69 c = Cucul::Canvas.new(20,10) 70 c.put_str(2, 3, "plop!") 71 c.draw_thin_polyline([[0,0], [0,2], [5,2], [0,0]]) 72 d = Caca::Display.new(c) 73 d.title = "Test !" 96 irb(main):011:0>Caca::Event.constants 97 =>["Key", "Quit", "TYPE", "Mouse", "Resize"] 98 \endcode 99 100 \code 101 irb(main):012:0>Caca::Event.my_instance_methods 102 =>["quit?"] 103 \endcode 104 105 \code 106 irb(main):013:0>Caca::Event::Key.my_instance_methods 107 =>["ch", "utf32", "utf8"] 108 \endcode 109 110 \code 111 irb(main):014:0>Caca::Event::Mouse.my_instance_methods 112 =>["button", "x", "y"] 113 \endcode 114 115 \code 116 irb(main):015:0>Caca::Event::Resize.my_instance_methods 117 =>["w", "h"] 118 \endcode 119 120 \sectionSamples 121 122 \code 123 $ruby -rcaca -e 'c=Caca::Canvas.new(6, 3).fill_box(0,0,2,2,"#"[0]); 124 c2=Caca::Canvas.new(1,1).put_str(0,0,"x"); c.blit(1,1,c2); puts 125 c.export_memory("irc")' 126 ### 127 #x# 128 ### 129 \endcode 130 131 \code 132 $ruby -e 'puts Caca::Canvas.new(6,3).draw_thin_polyline([[0,0], [0,2], 133 [5,2],[0,0]]).export_memory("irc")' 134 -. 135 |`. 136 ----`- 137 \endcode 138 139 \code 140 $ruby -rcaca -e 'p Caca::Canvas.export_list' 141 [["caca","native libcaca format"], ["ansi", "ANSI"], ["utf8", "UTF-8 142 withANSI escape codes"], ["utf8cr", "UTF-8 with ANSI escape codes and 143 MS-DOS\\r"], ["html", "HTML"], ["html3", "backwards-compatible HTML"], 144 ["irc","IRC with mIRC colours"], ["ps", "PostScript document"], ["svg", 145 "SVGvector image"], ["tga", "TGA image"]] 146 \endcode 147 148 \code 149 $ruby -rcaca -e 'p Caca::Font.list' 150 ["Monospace9", "Monospace Bold 12"] 151 \endcode 152 153 \code 154 require'caca' 155 c= Caca::Canvas.new(20,10) 156 c.put_str(2,3, "plop!") 157 c.draw_thin_polyline([[0,0],[0,2], [5,2], [0,0]]) 158 d= Caca::Display.new(c) 159 d.title= "Test !" 74 160 d.refresh 75 161 76 # 77 module 78 79 80 81 82 162 #Redefine Event::Key#quit? so that q, Q, and Esc become exit keys 163 moduleCaca 164 class Event::Key 165 def quit? 166 "qQ^[".split('').member?(@ch.chr) 167 end 168 end 83 169 end 84 170 85 while((e 86 87 171 while((e= d.get_event(Caca::Event, -1)) && ! e.quit?) 172 p e 173 d.refresh 88 174 end 89 175 \endcode
Note: See TracChangeset
for help on using the changeset viewer.