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