1libcaca-ruby-api(3caca)             libcaca            libcaca-ruby-api(3caca)
2
3
4

NAME

6       libcaca-ruby-api - Libcaca Ruby API
7
8

Classes

10       The classes available for libcaca are :
11
12       · Caca::Canvas : functions that have a caca_canvas_t* as first argument
13       · Caca::Dither : functions that have a caca_dither_t* as first argument
14       · Caca::Font : functions that have a caca_font_t* as first argument
15         (The constructor can currently only accept the name of a builtin
16         font)
17       · Caca::Display
18       · Caca::Event
19       · Caca::Event::Key
20       · Caca::Event::Key::Press
21       · Caca::Event::Key::Release
22       · Caca::Event::Mouse
23       · Caca::Event::Mouse::Press
24       · Caca::Event::Mouse::Release
25       · Caca::Event::Mouse::Motion
26       · Caca::Event::Resize
27       · Caca::Event::Quit
28       The character set conversion functions are not available yet in the
29       binding.
30       $ irb -rcaca
31       irb(main):001:0> class Object
32       irb(main):002:1> def Object.my_instance_methods
33       irb(main):003:2> instance_methods.sort - ancestors[1].instance_methods
34       irb(main):004:2> end
35       irb(main):005:1> def Object.my_methods
36       irb(main):006:2> methods.sort - ancestors[1].methods
37       irb(main):007:2> end
38       irb(main):008:1> end
39       irb(main):009:0> Caca.constants
40       => ["BROWN", "BOLD", "GREEN", "LIGHTMAGENTA", "LIGHTBLUE", "BLINK",
41       "MAGENTA", "DEFAULT", "TRANSPARENT", "BLUE", "LIGHTRED", "DARKGRAY",
42       "UNDERLINE", "RED", "WHITE", "BLACK", "LIGHTCYAN", "LIGHTGRAY",
43       "ITALICS", "CYAN", "YELLOW", "LIGHTGREEN", "Canvas", "Dither", "Font"]
44       irb(main):010:0> Caca.my_methods
45       => ["version"]
46       irb(main):011:0> Caca::Canvas.my_methods
47       => ["export_list", "import_list"]
48       irb(main):012:0> Caca::Canvas.my_instance_methods
49       => ["attr=", "blit", "clear", "create_frame",
50       "dither_bitmap", "draw_box", "draw_circle", "draw_cp437_box", "draw_ellipse",
51       "draw_line", "draw_polyline", "draw_thin_box", "draw_thin_ellipse",
52       "draw_thin_line", "draw_thin_polyline", "draw_thin_triangle",
53       "draw_triangle", "export_to_memory", "fill_box", "fill_ellipse",
54       "fill_triangle", "flip", "flop", "frame=", "frame_count", "frame_name",
55       "frame_name=", "free_frame", "get_attr", "get_char", "gotoxy",
56       "handle_x", "handle_y", "height", "height=", "import_file",
57       "import_from_memory", "invert", "printf", "put_attr", "put_char", "put_str",
58       "rotate_180", "rotate_left", "rotate_right", "set_attr",
59       "set_boundaries", "set_color_ansi", "set_color_argb", "set_frame",
60       "set_frame_name", "set_handle", "set_height", "set_size", "set_width",
61       "stretch_left", "stretch_right", "wherex", "wherey", "width", "width="]
62       irb(main):013:0> Caca::Font.my_methods
63       => ["list"]
64       irb(main):014:0> Caca::Font.my_instance_methods
65       => ["blocks", "height", "width"]
66       irb(main):015:0> Caca::Dither.my_instance_methods
67       => ["algorithm=", "algorithm_list", "antialias=", "antialias_list",
68       "brightness=", "charset=", "charset_list", "color=", "color_list",
69       "contrast=", "gamma=", "palette=", "set_algorithm", "set_antialias",
70       "set_brightness", "set_charset", "set_color", "set_contrast",
71       "set_gamma", "set_palette"]
72       irb(main):010:0> Caca::Display.my_instance_methods
73       => ["canvas", "get_event", "height", "mouse=", "mouse_x", "mouse_y", "refresh",
74       "set_mouse", "set_time", "set_title", "time", "time=", "title=", "width"]
75       irb(main):011:0> Caca::Event.constants
76       => ["Key", "Quit", "TYPE", "Mouse", "Resize"]
77       irb(main):012:0> Caca::Event.my_instance_methods
78       => ["quit?"]
79       irb(main):013:0> Caca::Event::Key.my_instance_methods
80       => ["ch", "utf32", "utf8"]
81       irb(main):014:0> Caca::Event::Mouse.my_instance_methods
82       => ["button", "x", "y"]
83       irb(main):015:0> Caca::Event::Resize.my_instance_methods
84       => ["w", "h"]

Samples

86       $ ruby -rcaca -e 'c=Caca::Canvas.new(6, 3).fill_box(0,0,2,2,"#"[0]);
87       c2=Caca::Canvas.new(1,1).put_str(0,0,"x"); c.blit(1,1,c2); puts
88       c.export_to_memory("irc")'
89       ###
90       #x#
91       ###
92       $ ruby -e 'puts Caca::Canvas.new(6,3).draw_thin_polyline([[0,0], [0,2],
93       [5,2],[0,0]]).export_to_memory("irc")'
94       -.
95       | `.
96       ----`-
97       $ ruby -rcaca -e 'p Caca::Canvas.export_list'
98       [["caca", "native libcaca format"], ["ansi", "ANSI"], ["utf8", "UTF-8
99       withANSI escape codes"], ["utf8cr", "UTF-8 with ANSI escape codes and
100       MS-DOS\r"], ["html", "HTML"], ["html3", "backwards-compatible HTML"],
101       ["irc", "IRC with mIRC colours"], ["ps", "PostScript document"], ["svg",
102       "SVGvector image"], ["tga", "TGA image"]]
103       $ ruby -rcaca -e 'p Caca::Font.list'
104       ["Monospace9", "Monospace Bold 12"]
105       require 'caca'
106       c = Caca::Canvas.new(20,10)
107       c.put_str(2,3, "plop!")
108       c.draw_thin_polyline([[0,0],[0,2], [5,2], [0,0]])
109       d = Caca::Display.new(c)
110       d.title= "Test !"
111       d.refresh
112
113       #Redefine Event::Key#quit? so that q, Q, and Esc become exit keys
114       module Caca
115         class Event::Key
116           def quit?
117             "qQ^[".split('').member?(@ch.chr)
118           end
119         end
120       end
121
122       while((e= d.get_event(Caca::Event, -1)) && ! e.quit?)
123         p e
124         d.refresh
125       end
126Version 0.99.beta19             Thu Jul 25 2019        libcaca-ruby-api(3caca)
Impressum