source: libcaca/trunk/src/caca.h @ 204

Last change on this file since 204 was 204, checked in by Sam Hocevar, 19 years ago
  • TODO: + A few updates.
  • src/blit.c: + Split blit() into caca_create_bitmap() and caca_draw_bitmap(). + Started removing hardcoded bitmask and pitch values.
  • examples/demo.c: + Do something with mouse clicks.
  • Property svn:keywords set to Id
File size: 4.4 KB
Line 
1/*
2 *   libcaca       ASCII-Art library
3 *   Copyright (c) 2002, 2003 Sam Hocevar <sam@zoy.org>
4 *                 All Rights Reserved
5 *
6 *   $Id: caca.h 204 2003-11-21 14:34:07Z sam $
7 *
8 *   This library is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU Lesser General Public
10 *   License as published by the Free Software Foundation; either
11 *   version 2 of the License, or (at your option) any later version.
12 *
13 *   This library is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 *   Lesser General Public License for more details.
17 *
18 *   You should have received a copy of the GNU Lesser General Public
19 *   License along with this library; if not, write to the Free Software
20 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
21 *   02111-1307  USA
22 */
23
24#ifndef __CACA_H__
25#define __CACA_H__
26
27#ifdef __cplusplus
28extern "C"
29{
30#endif
31
32/*
33 * Colors
34 */
35enum caca_color
36{
37    CACA_COLOR_BLACK = 0,
38    CACA_COLOR_BLUE = 1,
39    CACA_COLOR_GREEN = 2,
40    CACA_COLOR_CYAN = 3,
41    CACA_COLOR_RED = 4,
42    CACA_COLOR_MAGENTA = 5,
43    CACA_COLOR_BROWN = 6,
44    CACA_COLOR_LIGHTGRAY = 7,
45    CACA_COLOR_DARKGRAY = 8,
46    CACA_COLOR_LIGHTBLUE = 9,
47    CACA_COLOR_LIGHTGREEN = 10,
48    CACA_COLOR_LIGHTCYAN = 11,
49    CACA_COLOR_LIGHTRED = 12,
50    CACA_COLOR_LIGHTMAGENTA = 13,
51    CACA_COLOR_YELLOW = 14,
52    CACA_COLOR_WHITE = 15
53};
54
55/*
56 * Dithering modes
57 */
58enum caca_dithering
59{
60    CACA_DITHER_NONE,
61    CACA_DITHER_ORDERED,
62    CACA_DITHER_RANDOM
63};
64
65/*
66 * Events
67 */
68enum caca_event
69{
70    CACA_EVENT_NONE =        0x00000000,
71    CACA_EVENT_KEY_PRESS =   0x01000000,
72    CACA_EVENT_KEY_RELEASE = 0x02000000,
73    CACA_EVENT_MOUSE_CLICK = 0x04000000
74};
75
76/*
77 * Keys
78 */
79enum caca_key
80{
81    CACA_KEY_UP = 273,
82    CACA_KEY_DOWN = 274,
83    CACA_KEY_LEFT = 275,
84    CACA_KEY_RIGHT = 276,
85
86    CACA_KEY_F1 = 282,
87    CACA_KEY_F2 = 283,
88    CACA_KEY_F3 = 284,
89    CACA_KEY_F4 = 285,
90    CACA_KEY_F5 = 286,
91    CACA_KEY_F6 = 287,
92    CACA_KEY_F7 = 288,
93    CACA_KEY_F8 = 289,
94    CACA_KEY_F9 = 290,
95    CACA_KEY_F10 = 291,
96    CACA_KEY_F11 = 292,
97    CACA_KEY_F12 = 293,
98    CACA_KEY_F13 = 294,
99    CACA_KEY_F14 = 295,
100    CACA_KEY_F15 = 296
101};
102
103/*
104 * Internal types
105 */
106struct caca_sprite;
107struct caca_bitmap;
108
109/*
110 * Basic functions
111 */
112int caca_init(void);
113void caca_set_delay(unsigned int);
114void caca_set_dithering(enum caca_dithering);
115unsigned int caca_get_rendertime(void);
116unsigned int caca_get_width(void);
117unsigned int caca_get_height(void);
118const char *caca_get_color_name(unsigned int);
119void caca_refresh(void);
120void caca_end(void);
121
122/*
123 * Events
124 */
125int caca_get_event(void);
126
127/*
128 * Character graphics
129 */
130void caca_set_color(enum caca_color);
131enum caca_color caca_get_color(void);
132void caca_putchar(int, int, char);
133void caca_putstr(int, int, const char *);
134void caca_printf(int, int, const char *, ...);
135void caca_clear(void);
136
137/*
138 * Graphics primitives
139 */
140void caca_draw_line(int, int, int, int, char);
141void caca_draw_polyline(const int[], const int[], int, char);
142void caca_draw_thin_line(int, int, int, int);
143void caca_draw_thin_polyline(const int[], const int[], int);
144
145void caca_draw_circle(int, int, int, char);
146void caca_draw_ellipse(int, int, int, int, char);
147void caca_draw_thin_ellipse(int, int, int, int);
148void caca_fill_ellipse(int, int, int, int, char);
149
150void caca_draw_box(int, int, int, int, char);
151void caca_draw_thin_box(int, int, int, int);
152void caca_fill_box(int, int, int, int, char);
153
154void caca_draw_triangle(int, int, int, int, int, int, char);
155void caca_draw_thin_triangle(int, int, int, int, int, int);
156void caca_fill_triangle(int, int, int, int, int, int, char);
157
158/*
159 * Maths
160 */
161int caca_rand(int, int);
162unsigned int caca_sqrt(unsigned int);
163
164/*
165 * Sprite handling
166 */
167struct caca_sprite * caca_load_sprite(const char *);
168int caca_get_sprite_frames(struct caca_sprite *);
169int caca_get_sprite_width(struct caca_sprite *, int);
170int caca_get_sprite_height(struct caca_sprite *, int);
171int caca_get_sprite_dx(struct caca_sprite *, int);
172int caca_get_sprite_dy(struct caca_sprite *, int);
173void caca_draw_sprite(int, int, struct caca_sprite *, int);
174void caca_free_sprite(struct caca_sprite *);
175
176/*
177 * Bitmap handling
178 */
179struct caca_bitmap *caca_create_bitmap(int, int, int, int, int, int, int);
180void caca_draw_bitmap(int, int, int, int, struct caca_bitmap *, char *);
181void caca_free_bitmap(struct caca_bitmap *);
182
183#ifdef __cplusplus
184}
185#endif
186
187#endif /* __CACA_H__ */
Note: See TracBrowser for help on using the repository browser.