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

NAME

6       libcaca-ruby-api - Libcaca Ruby API
7

Classes

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

Samples

85       $ ruby -rcaca -e 'c=Caca::Canvas.new(6, 3).fill_box(0,0,2,2,"#"[0]);
86       c2=Caca::Canvas.new(1,1).put_str(0,0,"x"); c.blit(1,1,c2); puts
87       c.export_to_memory("irc")'
88       ###
89       #x#
90       ###
91       $ ruby -e 'puts Caca::Canvas.new(6,3).draw_thin_polyline([[0,0], [0,2],
92       [5,2],[0,0]]).export_to_memory("irc")'
93       -.
94       | `.
95       ----`-
96       $ ruby -rcaca -e 'p Caca::Canvas.export_list'
97       [["caca", "native libcaca format"], ["ansi", "ANSI"], ["utf8", "UTF-8
98       withANSI 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       "SVGvector image"], ["tga", "TGA image"]]
102       $ ruby -rcaca -e 'p Caca::Font.list'
103       ["Monospace9", "Monospace Bold 12"]
104       require 'caca'
105       c = Caca::Canvas.new(20,10)
106       c.put_str(2,3, "plop!")
107       c.draw_thin_polyline([[0,0],[0,2], [5,2], [0,0]])
108       d = Caca::Display.new(c)
109       d.title= "Test !"
110       d.refresh
111
112       #Redefine Event::Key#quit? so that q, Q, and Esc become exit keys
113       module Caca
114         class Event::Key
115           def quit?
116             "qQ^[".split('').member?(@ch.chr)
117           end
118         end
119       end
120
121       while((e= d.get_event(Caca::Event, -1)) && ! e.quit?)
122         p e
123         d.refresh
124       end
125Version 0.99.beta20        Sun Sep 24 2023 00:00:00    libcaca-ruby-api(3caca)
Impressum