You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

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