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

Last change on this file since 238 was 238, checked in by Sam Hocevar, 18 years ago
  • src/bitmap.c: + Fixed an endianness issue in the byte reader. + Decreased precision in RGB and HSV values to avoid overflows. + New dithering method: 2x2 ordered. + New renderer, with background colour awareness.
  • configure.ac: + Check for <endian.h>.
  • examples/demo.c examples/view.c: + Fixed an endianness issue in cacaview. + Adapted code to the additional dithering method.
  • Property svn:keywords set to Id
File size: 6.1 KB
Line 
1/*
2 *   libcaca       ASCII-Art library
3 *   Copyright (c) 2002, 2003 Sam Hocevar <sam@zoy.org>
4 *                 All Rights Reserved
5 *
6 *   This library is free software; you can redistribute it and/or
7 *   modify it under the terms of the GNU Lesser General Public
8 *   License as published by the Free Software Foundation; either
9 *   version 2 of the License, or (at your option) any later version.
10 *
11 *   This library is distributed in the hope that it will be useful,
12 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
13 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 *   Lesser General Public License for more details.
15 *
16 *   You should have received a copy of the GNU Lesser General Public
17 *   License along with this library; if not, write to the Free Software
18 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19 *   02111-1307  USA
20 */
21
22/**  \file caca.h
23 *   \version \$Id: caca.h 238 2003-11-30 15:01:55Z sam $
24 *   \author Sam Hocevar <sam@zoy.org>
25 *   \brief The \e libcaca public header.
26 *
27 *   This header contains the public types and functions that applications
28 *   using \e libcaca may use.
29 */
30
31/**  \mainpage libcaca developer documentation
32 *
33 *   \section intro Introduction
34 *
35 *   \e libcaca is a graphics library that outputs text instead of pixels,
36 *   so that it can work on older video cards or text terminals. It is not
37 *   unlike the famous AAlib library. libcaca needs a terminal to work,
38 *   thus it should work on all Unix systems (including Mac OS X) using
39 *   either the slang library or the ncurses library, on DOS using the conio
40 *   library, and on Windows systems using either slang or ncurses (through
41 *   Cygwin emulation) or conio.
42 *
43 *   \e libcaca is free software, released under the GNU Lesser General
44 *   Public License. This ensures that \e libcaca will always remain free
45 *   software.
46 *
47 *   \section api The libcaca API
48 *
49 *   The complete \e libcaca programming interface is available from the
50 *   caca.h file.
51 */
52
53#ifndef __CACA_H__
54#define __CACA_H__
55
56#ifdef __cplusplus
57extern "C"
58{
59#endif
60
61/**
62 * The colour definitions to be used with caca_set_color().
63 */
64enum caca_color
65{
66    CACA_COLOR_BLACK = 0,
67    CACA_COLOR_BLUE = 1,
68    CACA_COLOR_GREEN = 2,
69    CACA_COLOR_CYAN = 3,
70    CACA_COLOR_RED = 4,
71    CACA_COLOR_MAGENTA = 5,
72    CACA_COLOR_BROWN = 6,
73    CACA_COLOR_LIGHTGRAY = 7,
74    CACA_COLOR_DARKGRAY = 8,
75    CACA_COLOR_LIGHTBLUE = 9,
76    CACA_COLOR_LIGHTGREEN = 10,
77    CACA_COLOR_LIGHTCYAN = 11,
78    CACA_COLOR_LIGHTRED = 12,
79    CACA_COLOR_LIGHTMAGENTA = 13,
80    CACA_COLOR_YELLOW = 14,
81    CACA_COLOR_WHITE = 15
82};
83
84const char *caca_get_color_name(enum caca_color);
85
86/**
87 * The dithering modes to be used with caca_set_dithering().
88 */
89enum caca_dithering
90{
91    CACA_DITHERING_NONE = 0,
92    CACA_DITHERING_ORDERED2 = 1,
93    CACA_DITHERING_ORDERED4 = 2,
94    CACA_DITHERING_ORDERED8 = 3,
95    CACA_DITHERING_RANDOM = 4
96};
97
98const char *caca_get_dithering_name(enum caca_dithering);
99
100/* Backwards compatibility */
101#define CACA_DITHER_NONE    CACA_DITHERING_NONE
102#define CACA_DITHER_ORDERED CACA_DITHERING_ORDERED8
103#define CACA_DITHER_RANDOM  CACA_DITHERING_RANDOM
104
105/**
106 * The event types returned by caca_get_event().
107 */
108enum caca_event
109{
110    CACA_EVENT_NONE =        0x00000000,
111    CACA_EVENT_KEY_PRESS =   0x01000000,
112    CACA_EVENT_KEY_RELEASE = 0x02000000,
113    CACA_EVENT_MOUSE_CLICK = 0x04000000
114};
115
116/**
117 * The special key values returned by caca_get_event().
118 */
119enum caca_key
120{
121    CACA_KEY_UP = 273,
122    CACA_KEY_DOWN = 274,
123    CACA_KEY_LEFT = 275,
124    CACA_KEY_RIGHT = 276,
125
126    CACA_KEY_F1 = 282,
127    CACA_KEY_F2 = 283,
128    CACA_KEY_F3 = 284,
129    CACA_KEY_F4 = 285,
130    CACA_KEY_F5 = 286,
131    CACA_KEY_F6 = 287,
132    CACA_KEY_F7 = 288,
133    CACA_KEY_F8 = 289,
134    CACA_KEY_F9 = 290,
135    CACA_KEY_F10 = 291,
136    CACA_KEY_F11 = 292,
137    CACA_KEY_F12 = 293,
138    CACA_KEY_F13 = 294,
139    CACA_KEY_F14 = 295,
140    CACA_KEY_F15 = 296
141};
142
143/*
144 * Basic functions
145 */
146int caca_init(void);
147void caca_set_delay(unsigned int);
148void caca_set_dithering(enum caca_dithering);
149unsigned int caca_get_rendertime(void);
150unsigned int caca_get_width(void);
151unsigned int caca_get_height(void);
152void caca_refresh(void);
153void caca_end(void);
154
155/*
156 * Events
157 */
158unsigned int caca_get_event(void);
159
160/*
161 * Character graphics
162 */
163void caca_set_color(enum caca_color, enum caca_color);
164enum caca_color caca_get_fg_color(void);
165enum caca_color caca_get_bg_color(void);
166void caca_putchar(int, int, char);
167void caca_putstr(int, int, const char *);
168void caca_printf(int, int, const char *, ...);
169void caca_clear(void);
170
171/*
172 * Graphics primitives
173 */
174void caca_draw_line(int, int, int, int, char);
175void caca_draw_polyline(const int[], const int[], int, char);
176void caca_draw_thin_line(int, int, int, int);
177void caca_draw_thin_polyline(const int[], const int[], int);
178
179void caca_draw_circle(int, int, int, char);
180void caca_draw_ellipse(int, int, int, int, char);
181void caca_draw_thin_ellipse(int, int, int, int);
182void caca_fill_ellipse(int, int, int, int, char);
183
184void caca_draw_box(int, int, int, int, char);
185void caca_draw_thin_box(int, int, int, int);
186void caca_fill_box(int, int, int, int, char);
187
188void caca_draw_triangle(int, int, int, int, int, int, char);
189void caca_draw_thin_triangle(int, int, int, int, int, int);
190void caca_fill_triangle(int, int, int, int, int, int, char);
191
192/*
193 * Maths
194 */
195int caca_rand(int, int);
196unsigned int caca_sqrt(unsigned int);
197
198/*
199 * Sprite handling
200 */
201struct caca_sprite;
202struct caca_sprite * caca_load_sprite(const char *);
203int caca_get_sprite_frames(struct caca_sprite *);
204int caca_get_sprite_width(struct caca_sprite *, int);
205int caca_get_sprite_height(struct caca_sprite *, int);
206int caca_get_sprite_dx(struct caca_sprite *, int);
207int caca_get_sprite_dy(struct caca_sprite *, int);
208void caca_draw_sprite(int, int, struct caca_sprite *, int);
209void caca_free_sprite(struct caca_sprite *);
210
211/*
212 * Bitmap handling
213 */
214struct caca_bitmap;
215struct caca_bitmap *caca_create_bitmap(int, int, int, int, int, int, int);
216void caca_set_bitmap_palette(struct caca_bitmap *, int[], int[], int[]);
217void caca_draw_bitmap(int, int, int, int, struct caca_bitmap *, char *);
218void caca_free_bitmap(struct caca_bitmap *);
219
220#ifdef __cplusplus
221}
222#endif
223
224#endif /* __CACA_H__ */
Note: See TracBrowser for help on using the repository browser.