|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217 |
- /*
- * libcucul Unicode canvas library
- * Copyright (c) 2002-2006 Sam Hocevar <sam@zoy.org>
- * All Rights Reserved
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the Do What The Fuck You Want To
- * Public License, Version 2, as published by Sam Hocevar. See
- * http://sam.zoy.org/wtfpl/COPYING for more details.
- */
-
- /** \file cucul.h
- * \version \$Id$
- * \author Sam Hocevar <sam@zoy.org>
- * \brief The \e libcucul public header.
- *
- * This header contains the public types and functions that applications
- * using \e libcucul may use.
- */
-
- #ifndef __CUCUL_H__
- #define __CUCUL_H__
-
- #ifdef __cplusplus
- extern "C"
- {
- #endif
-
- /** \brief Colour definitions.
- *
- * Colours that can be used with caca_set_color().
- */
- enum cucul_color
- {
- CUCUL_COLOR_BLACK = 0, /**< The colour index for black. */
- CUCUL_COLOR_BLUE = 1, /**< The colour index for blue. */
- CUCUL_COLOR_GREEN = 2, /**< The colour index for green. */
- CUCUL_COLOR_CYAN = 3, /**< The colour index for cyan. */
- CUCUL_COLOR_RED = 4, /**< The colour index for red. */
- CUCUL_COLOR_MAGENTA = 5, /**< The colour index for magenta. */
- CUCUL_COLOR_BROWN = 6, /**< The colour index for brown. */
- CUCUL_COLOR_LIGHTGRAY = 7, /**< The colour index for light gray. */
- CUCUL_COLOR_DARKGRAY = 8, /**< The colour index for dark gray. */
- CUCUL_COLOR_LIGHTBLUE = 9, /**< The colour index for blue. */
- CUCUL_COLOR_LIGHTGREEN = 10, /**< The colour index for light green. */
- CUCUL_COLOR_LIGHTCYAN = 11, /**< The colour index for light cyan. */
- CUCUL_COLOR_LIGHTRED = 12, /**< The colour index for light red. */
- CUCUL_COLOR_LIGHTMAGENTA = 13, /**< The colour index for light magenta. */
- CUCUL_COLOR_YELLOW = 14, /**< The colour index for yellow. */
- CUCUL_COLOR_WHITE = 15 /**< The colour index for white. */
- };
-
- /** \brief Internal features.
- *
- * Internal libcaca features such as the rendering method or the dithering
- * mode.
- */
- enum cucul_feature
- {
- CUCUL_BACKGROUND = 0x10, /**< Properties of background characters. */
- CUCUL_BACKGROUND_BLACK = 0x11, /**< Draw only black backgrounds. */
- CUCUL_BACKGROUND_SOLID = 0x12, /**< Draw coloured solid backgorunds. */
- #define CUCUL_BACKGROUND_MIN 0x11 /**< First background property */
- #define CUCUL_BACKGROUND_MAX 0x12 /**< Last background property */
-
- CUCUL_ANTIALIASING = 0x20, /**< Antialiasing features. */
- CUCUL_ANTIALIASING_NONE = 0x21, /**< No antialiasing. */
- CUCUL_ANTIALIASING_PREFILTER = 0x22, /**< Prefilter antialiasing. */
- #define CUCUL_ANTIALIASING_MIN 0x21 /**< First antialiasing feature. */
- #define CUCUL_ANTIALIASING_MAX 0x22 /**< Last antialiasing feature. */
-
- CUCUL_DITHERING = 0x30, /**< Dithering methods */
- CUCUL_DITHERING_NONE = 0x31, /**< No dithering. */
- CUCUL_DITHERING_ORDERED2 = 0x32, /**< Ordered 2x2 Bayer dithering. */
- CUCUL_DITHERING_ORDERED4 = 0x33, /**< Ordered 4x4 Bayer dithering. */
- CUCUL_DITHERING_ORDERED8 = 0x34, /**< Ordered 8x8 Bayer dithering. */
- CUCUL_DITHERING_RANDOM = 0x35, /**< Random dithering. */
- CUCUL_DITHERING_FSTEIN = 0x36, /**< Floyd-Steinberg dithering. */
- #define CUCUL_DITHERING_MIN 0x31 /**< First dithering feature. */
- #define CUCUL_DITHERING_MAX 0x36 /**< Last dithering feature. */
-
- CUCUL_FEATURE_UNKNOWN = 0xffff /**< Unknown feature. */
- };
-
- /*
- * Backwards compatibility macros
- */
- #if !defined(_DOXYGEN_SKIP_ME)
- #define caca_dithering cucul_feature
- #define caca_set_dithering caca_set_feature
- #define caca_get_dithering_name caca_get_feature_name
- #define CACA_DITHER_NONE CUCUL_DITHERING_NONE
- #define CACA_DITHER_ORDERED CUCUL_DITHERING_ORDERED8
- #define CACA_DITHER_RANDOM CUCUL_DITHERING_RANDOM
- #endif
-
- typedef struct cucul_context cucul_t;
-
- /** \defgroup basic Basic functions
- *
- * These functions provide the basic \e libcaca routines for library
- * initialisation, system information retrieval and configuration.
- *
- * @{ */
- cucul_t * cucul_init(void);
- void cucul_set_size(cucul_t *, unsigned int, unsigned int);
- unsigned int cucul_get_width(cucul_t *);
- unsigned int cucul_get_height(cucul_t *);
- enum cucul_feature cucul_get_feature(cucul_t *, enum cucul_feature);
- void cucul_set_feature(cucul_t *, enum cucul_feature);
- char const *cucul_get_feature_name(enum cucul_feature);
- void cucul_end(cucul_t *);
- /* @} */
-
- /** \defgroup char Character printing
- *
- * These functions provide low-level character printing routines.
- *
- * @{ */
- void cucul_set_color(cucul_t *, enum cucul_color, enum cucul_color);
- enum cucul_color cucul_get_fg_color(cucul_t *);
- enum cucul_color cucul_get_bg_color(cucul_t *);
- char const *cucul_get_color_name(enum cucul_color);
- void cucul_putchar(cucul_t *, int, int, char);
- void cucul_putstr(cucul_t *, int, int, char const *);
- void cucul_printf(cucul_t *, int, int, char const *, ...);
- void cucul_get_screen(cucul_t *, char *);
- void cucul_clear(cucul_t *);
- /* @} */
-
- /** \defgroup prim Primitives drawing
- *
- * These functions provide routines for primitive drawing, such as lines,
- * boxes, triangles and ellipses.
- *
- * @{ */
- void cucul_draw_line(cucul_t *, int, int, int, int, char);
- void cucul_draw_polyline(cucul_t *, int const x[], int const y[], int, char);
- void cucul_draw_thin_line(cucul_t *, int, int, int, int);
- void cucul_draw_thin_polyline(cucul_t *, int const x[], int const y[], int);
-
- void cucul_draw_circle(cucul_t *, int, int, int, char);
- void cucul_draw_ellipse(cucul_t *, int, int, int, int, char);
- void cucul_draw_thin_ellipse(cucul_t *, int, int, int, int);
- void cucul_fill_ellipse(cucul_t *, int, int, int, int, char);
-
- void cucul_draw_box(cucul_t *, int, int, int, int, char);
- void cucul_draw_thin_box(cucul_t *, int, int, int, int);
- void cucul_fill_box(cucul_t *, int, int, int, int, char);
-
- void cucul_draw_triangle(cucul_t *, int, int, int, int, int, int, char);
- void cucul_draw_thin_triangle(cucul_t *, int, int, int, int, int, int);
- void cucul_fill_triangle(cucul_t *, int, int, int, int, int, int, char);
- /* @} */
-
- /** \defgroup math Mathematical functions
- *
- * These functions provide a few useful math-related routines.
- *
- * @{ */
- int cucul_rand(int, int);
- unsigned int cucul_sqrt(unsigned int);
- float cucul_powf(float x, float y);
- /* @} */
-
- /** \defgroup sprite Sprite handling
- *
- * These functions provide high level routines for sprite loading, animation
- * and rendering.
- *
- * @{ */
- struct cucul_sprite;
- struct cucul_sprite * cucul_load_sprite(cucul_t *, char const *);
- int cucul_get_sprite_frames(cucul_t *, struct cucul_sprite const *);
- int cucul_get_sprite_width(cucul_t *, struct cucul_sprite const *, int);
- int cucul_get_sprite_height(cucul_t *, struct cucul_sprite const *, int);
- int cucul_get_sprite_dx(cucul_t *, struct cucul_sprite const *, int);
- int cucul_get_sprite_dy(cucul_t *, struct cucul_sprite const *, int);
- void cucul_draw_sprite(cucul_t *, int, int, struct cucul_sprite const *, int);void cucul_free_sprite(cucul_t *, struct cucul_sprite *);
- /* @} */
-
- /** \defgroup bitmap Bitmap handling
- *
- * These functions provide high level routines for bitmap allocation and
- * rendering.
- *
- * @{ */
- struct cucul_bitmap;
- struct cucul_bitmap *cucul_create_bitmap(cucul_t *, unsigned int, unsigned int,
- unsigned int, unsigned int,
- unsigned int, unsigned int,
- unsigned int, unsigned int);
- void cucul_set_bitmap_palette(cucul_t *, struct cucul_bitmap *,
- unsigned int r[], unsigned int g[],
- unsigned int b[], unsigned int a[]);
- void cucul_set_bitmap_gamma(cucul_t *, struct cucul_bitmap *, float);
- void cucul_draw_bitmap(cucul_t *, int, int, int, int, struct cucul_bitmap const *, void *);
- void cucul_free_bitmap(cucul_t *, struct cucul_bitmap *);
- /* @} */
-
- /** \defgroup exporter Exporters to various formats
- *
- * These functions exports current image to various text formats
- * Returned buffer will be freed() each you'll call the exporter function.
- *
- * @{ */
- char* cucul_get_html(cucul_t *, int *size);
- char* cucul_get_html3(cucul_t *, int *size);
- char* cucul_get_irc(cucul_t *, int *size);
- char* cucul_get_ansi(cucul_t *, int trailing, int *size);
- /* @} */
-
- #ifdef __cplusplus
- }
- #endif
-
- #endif /* __CUCUL_H__ */
|