cucul_set_color() and cucul_set_truecolor() under the new names cucul_set_color_ansi() and cucul_set_color_argb(). * Renamed cucul_get_color_name() into cucul_ansi_to_str().tags/v0.99.beta14
@@ -130,11 +130,10 @@ enum caca_feature | |||
#define caca_get_mouse_y() caca_get_mouse_y(__caca0_dp) | |||
#define caca_set_color(x, y) \ | |||
(__caca0_fg = (x), __caca0_bg = (y), \ | |||
cucul_set_attr(__caca0_cv, cucul_ansi_to_attr(x, y))) | |||
(__caca0_fg = (x), __caca0_bg = (y), cucul_set_color_ansi(__caca0_cv, x, y)) | |||
#define caca_get_fg_color() __caca0_fg | |||
#define caca_get_bg_color() __caca0_bg | |||
#define caca_get_color_name cucul_get_color_name | |||
#define caca_get_color_name cucul_ansi_to_str | |||
#define caca_putchar(x, y, c) cucul_putchar(__caca0_cv, x, y, c) | |||
#define caca_putstr(x, y, s) cucul_putstr(__caca0_cv, x, y, s) | |||
#define caca_printf(x, y, f, z...) cucul_printf(__caca0_cv, x, y, f, ##z) | |||
@@ -512,7 +512,7 @@ static void gl_compute_font(caca_display_t *dp) | |||
/* Allocate a libcucul canvas and print all the glyphs on it */ | |||
cv = cucul_create_canvas(1, b); | |||
cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_WHITE, CUCUL_BLACK)); | |||
cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLACK); | |||
for(b = 0, i = 0; dp->drv.p->blocks[i + 1]; i += 2) | |||
{ | |||
@@ -26,6 +26,39 @@ | |||
#include "cucul.h" | |||
#include "cucul_internals.h" | |||
/** \brief Get the text attribute at the given coordinates. | |||
* | |||
* Get the internal \e libcucul attribute value of the character at the | |||
* given coordinates. The attribute value has 32 significant bits, | |||
* organised as follows from MSB to LSB: | |||
* - 3 bits for the background alpha | |||
* - 4 bits for the background red component | |||
* - 4 bits for the background green component | |||
* - 3 bits for the background blue component | |||
* - 3 bits for the foreground alpha | |||
* - 4 bits for the foreground red component | |||
* - 4 bits for the foreground green component | |||
* - 3 bits for the foreground blue component | |||
* - 4 bits for the bold, italics, underline and blink flags | |||
* | |||
* If the coordinates are outside the canvas boundaries, the current | |||
* attribute is returned. | |||
* | |||
* This function never fails. | |||
* | |||
* \param cv A handle to the libcucul canvas. | |||
* \param x X coordinate. | |||
* \param y Y coordinate. | |||
* \return The requested attribute. | |||
*/ | |||
unsigned long int cucul_get_attr(cucul_canvas_t *cv, int x, int y) | |||
{ | |||
if(x < 0 || x >= (int)cv->width || y < 0 || y >= (int)cv->height) | |||
return (unsigned long int)cv->curattr; | |||
return (unsigned long int)cv->attrs[x + y * cv->width]; | |||
} | |||
/** \brief Set the default character attribute. | |||
* | |||
* Set the default character attribute for drawing. Attributes define | |||
@@ -34,11 +67,12 @@ | |||
* caca_printf() and graphical primitive functions such as caca_draw_line() | |||
* will use this attribute. | |||
* | |||
* The attribute value is a 32-bit integer as returned by cucul_get_attr() | |||
* or created using cucul_ansi_to_attr() and cucul_argb_to_attr(), optionally | |||
* ORed with style values such as CUCUL_UNDERLINE or CUCUL_BLINK. | |||
* | |||
* Only changing the style does not affect the current colour value. | |||
* The value of \e attr is either: | |||
* - a 32-bit integer as returned by cucul_get_attr(), in which case it | |||
* also contains colour information, | |||
* - a combination (bitwise OR) of style values (\e CUCUL_UNDERLINE, | |||
* \e CUCUL_BLINK, \e CUCUL_BOLD and \e CUCUL_ITALICS), in which case | |||
* setting the attribute does not modify the current colour information. | |||
* | |||
* If an error occurs, -1 is returned and \b errno is set accordingly: | |||
* - \c EINVAL The attribute value is out of the 32-bit range. | |||
@@ -65,88 +99,52 @@ int cucul_set_attr(cucul_canvas_t *cv, unsigned long int attr) | |||
return 0; | |||
} | |||
/** \brief Get the text attribute at the given coordinates. | |||
/** \brief Set the default colour pair for text (ANSI version). | |||
* | |||
* Get the internal \e libcucul attribute value of the character at the | |||
* given coordinates. The attribute value has 32 significant bits, | |||
* organised as follows from MSB to LSB: | |||
* - 3 bits for the background alpha | |||
* - 4 bits for the background red component | |||
* - 4 bits for the background green component | |||
* - 3 bits for the background blue component | |||
* - 3 bits for the foreground alpha | |||
* - 4 bits for the foreground red component | |||
* - 4 bits for the foreground green component | |||
* - 3 bits for the foreground blue component | |||
* - 4 bits for the bold, italics, underline and blink flags | |||
* | |||
* If the coordinates are outside the canvas boundaries, the current | |||
* attribute is returned. | |||
* | |||
* This function never fails. | |||
* | |||
* \param cv A handle to the libcucul canvas. | |||
* \param x X coordinate. | |||
* \param y Y coordinate. | |||
* \return The requested attribute. | |||
*/ | |||
unsigned long int cucul_get_attr(cucul_canvas_t *cv, int x, int y) | |||
{ | |||
if(x < 0 || x >= (int)cv->width || y < 0 || y >= (int)cv->height) | |||
return (unsigned long int)cv->curattr; | |||
return (unsigned long int)cv->attrs[x + y * cv->width]; | |||
} | |||
/** \brief Set the default colour pair and text style (ANSI version). | |||
* | |||
* Set the default ANSI colour pair and text style for drawing. String | |||
* functions such as caca_printf() and graphical primitive functions such as | |||
* caca_draw_line() will use these attributes. | |||
* Set the default ANSI colour pair for text drawing. String functions such | |||
* as caca_printf() and graphical primitive functions such as caca_draw_line() | |||
* will use these attributes. | |||
* | |||
* Color values are those defined in cucul.h, such as CUCUL_RED | |||
* or CUCUL_TRANSPARENT. | |||
* | |||
* Style values are those defined in cucul.h, such as CUCUL_UNDERLINE | |||
* or CUCUL_BLINK. The values can be ORed to set several styles at | |||
* the same time. | |||
* | |||
* If an error occurs, 0 is returned and \b errno is set accordingly: | |||
* - \c EINVAL The colour values and/or the style mask are invalid. | |||
* - \c EINVAL At least one of the colour values is invalid. | |||
* | |||
* \param cv A handle to the libcucul canvas. | |||
* \param fg The requested foreground colour. | |||
* \param bg The requested background colour. | |||
* \param style The requested text styles. | |||
* \param fg The requested ANSI foreground colour. | |||
* \param bg The requested ANSI background colour. | |||
* \return 0 in case of success, -1 if an error occurred. | |||
*/ | |||
unsigned long int cucul_ansi_to_attr(unsigned char fg, unsigned char bg) | |||
int cucul_set_color_ansi(cucul_canvas_t *cv, unsigned char fg, unsigned char bg) | |||
{ | |||
uint32_t attr; | |||
if(fg > 0x20 || bg > 0x20) | |||
{ | |||
#if defined(HAVE_ERRNO_H) | |||
errno = EINVAL; | |||
#endif | |||
return 0; | |||
return -1; | |||
} | |||
fg |= 0x40; | |||
bg |= 0x40; | |||
attr = ((uint32_t)(bg | 0x40) << 18) | ((uint32_t)(fg | 0x40) << 4); | |||
cv->curattr = (cv->curattr & 0x0000000f) | attr; | |||
return ((unsigned long int)bg << 18) | ((unsigned long int)fg << 4); | |||
return 0; | |||
} | |||
/* Legacy function for old programs */ | |||
int cucul_set_color(cucul_canvas_t *cv, unsigned char fg, unsigned char bg) | |||
{ | |||
return cucul_set_attr(cv, cucul_ansi_to_attr(fg, bg)); | |||
return cucul_set_color_ansi(cv, fg, bg); | |||
} | |||
/** \brief Set the default colour pair and text style (truecolor version). | |||
/** \brief Set the default colour pair for text (truecolor version). | |||
* | |||
* Set the default colour pair and text style for drawing. String | |||
* functions such as caca_printf() and graphical primitive functions such as | |||
* caca_draw_line() will use these attributes. | |||
* Set the default ARGB colour pair for text drawing. String functions such | |||
* as caca_printf() and graphical primitive functions such as caca_draw_line() | |||
* will use these attributes. | |||
* | |||
* Colors are 16-bit ARGB values, each component being coded on 4 bits. For | |||
* instance, 0xf088 is solid dark cyan (A=15 R=0 G=8 B=8), and 0x8fff is | |||
@@ -156,13 +154,14 @@ int cucul_set_color(cucul_canvas_t *cv, unsigned char fg, unsigned char bg) | |||
* - \c EINVAL At least one of the colour values is invalid. | |||
* | |||
* \param cv A handle to the libcucul canvas. | |||
* \param fg The requested foreground colour. | |||
* \param bg The requested background colour. | |||
* \param style The requested text styles. | |||
* \param fg The requested ARGB foreground colour. | |||
* \param bg The requested ARGB background colour. | |||
* \return 0 in case of success, -1 if an error occurred. | |||
*/ | |||
unsigned long int cucul_argb_to_attr(unsigned int fg, unsigned int bg) | |||
int cucul_set_color_argb(cucul_canvas_t *cv, unsigned int fg, unsigned int bg) | |||
{ | |||
uint32_t attr; | |||
if(fg > 0xffff || bg > 0xffff) | |||
{ | |||
#if defined(HAVE_ERRNO_H) | |||
@@ -180,13 +179,16 @@ unsigned long int cucul_argb_to_attr(unsigned int fg, unsigned int bg) | |||
fg = ((fg >> 1) & 0x7ff) | ((fg >> 13) << 11); | |||
bg = ((bg >> 1) & 0x7ff) | ((bg >> 13) << 11); | |||
return ((unsigned long int)bg << 18) | ((unsigned long int)fg << 4); | |||
attr = ((uint32_t)bg << 18) | ((uint32_t)fg << 4); | |||
cv->curattr = (cv->curattr & 0x0000000f) | attr; | |||
return 0; | |||
} | |||
/* Legacy function for old programs */ | |||
int cucul_set_truecolor(cucul_canvas_t *cv, unsigned int fg, unsigned int bg) | |||
{ | |||
return cucul_set_attr(cv, cucul_argb_to_attr(fg, bg)); | |||
return cucul_set_color_argb(cv, fg, bg); | |||
} | |||
/* | |||
@@ -176,10 +176,10 @@ unsigned int cucul_get_canvas_height(cucul_canvas_t *cv) | |||
return cv->height; | |||
} | |||
/** \brief Translate a colour index into the colour's name. | |||
/** \brief Translate an ANSI colour index into the colour's name. | |||
* | |||
* Translate a cucul_color enum into a human-readable string describing | |||
* the corresponding colour. | |||
* Translate an ANSI colour index such as \e CUCUL_RED or \e CUCUL_WHITE | |||
* into a human-readable string describing the corresponding colour. | |||
* | |||
* This function never fails. | |||
* | |||
@@ -187,7 +187,7 @@ unsigned int cucul_get_canvas_height(cucul_canvas_t *cv) | |||
* \return A static string containing the colour's name, or \c "unknown" if | |||
* the colour is unknown. | |||
*/ | |||
char const *cucul_get_color_name(unsigned int color) | |||
char const *cucul_ansi_to_str(unsigned char color) | |||
{ | |||
static char const *color_names[] = | |||
{ | |||
@@ -209,10 +209,16 @@ char const *cucul_get_color_name(unsigned int color) | |||
"white", | |||
}; | |||
if(color < 0 || color > 15) | |||
if(color > 15) | |||
return "unknown"; | |||
return color_names[color]; | |||
return color_names[(unsigned int)color]; | |||
} | |||
/* Legacy function for old programs */ | |||
char const *cucul_get_color_name(unsigned int color) | |||
{ | |||
return cucul_ansi_to_str(color > 15 ? 15 : color); | |||
} | |||
/** \brief Uninitialise \e libcucul. | |||
@@ -103,11 +103,11 @@ int cucul_free_buffer(cucul_buffer_t *); | |||
* | |||
* @{ */ | |||
#define CUCUL_MAGIC_FULLWIDTH 0x000ffffe /**< Used to indicate that the previous character was a fullwidth glyph. */ | |||
int cucul_set_attr(cucul_canvas_t *, unsigned long int); | |||
unsigned long int cucul_get_attr(cucul_canvas_t *, int, int); | |||
unsigned long int cucul_ansi_to_attr(unsigned char, unsigned char); | |||
unsigned long int cucul_argb_to_attr(unsigned int, unsigned int); | |||
char const *cucul_get_color_name(unsigned int); | |||
int cucul_set_attr(cucul_canvas_t *, unsigned long int); | |||
int cucul_set_color_ansi(cucul_canvas_t *, unsigned char, unsigned char); | |||
int cucul_set_color_argb(cucul_canvas_t *, unsigned int, unsigned int); | |||
char const *cucul_ansi_to_str(unsigned char); | |||
int cucul_putchar(cucul_canvas_t *, int, int, unsigned long int); | |||
unsigned long int cucul_getchar(cucul_canvas_t *, int, int); | |||
int cucul_putstr(cucul_canvas_t *, int, int, char const *); | |||
@@ -248,6 +248,7 @@ int cucul_set_color(cucul_canvas_t *, unsigned char, | |||
unsigned char) CUCUL_DEPRECATED; | |||
int cucul_set_truecolor(cucul_canvas_t *, unsigned int, | |||
unsigned int) CUCUL_DEPRECATED; | |||
char const *cucul_get_color_name(unsigned int) CUCUL_DEPRECATED; | |||
# define CUCUL_COLOR_BLACK CUCUL_BLACK | |||
# define CUCUL_COLOR_BLUE CUCUL_BLUE | |||
# define CUCUL_COLOR_GREEN CUCUL_GREEN | |||
@@ -1042,7 +1042,7 @@ int cucul_dither_bitmap(cucul_canvas_t *cv, int x, int y, int w, int h, | |||
} | |||
/* Now output the character */ | |||
cucul_set_attr(cv, cucul_ansi_to_attr(outfg, outbg)); | |||
cucul_set_color_ansi(cv, outfg, outbg); | |||
cucul_putchar(cv, x, y, outch); | |||
d->increment_dither(); | |||
@@ -202,7 +202,7 @@ static cucul_canvas_t *import_text(void const *data, unsigned int size) | |||
return NULL; | |||
} | |||
cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_DEFAULT, CUCUL_TRANSPARENT)); | |||
cucul_set_color_ansi(cv, CUCUL_DEFAULT, CUCUL_TRANSPARENT); | |||
for(i = 0; i < size; i++) | |||
{ | |||
@@ -384,8 +384,7 @@ static cucul_canvas_t *import_ansi(void const *data, unsigned int size, | |||
break; | |||
case 'K': /* EL - Erase In Line */ | |||
if(width < 80) | |||
cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_DEFAULT, | |||
CUCUL_TRANSPARENT)); | |||
cucul_set_color_ansi(cv, CUCUL_DEFAULT, CUCUL_TRANSPARENT); | |||
cucul_set_canvas_size(cv, width = 80, height); | |||
for(j = x; j < 80; j++) | |||
cucul_putchar(cv, j, y, ' '); | |||
@@ -435,28 +434,25 @@ static cucul_canvas_t *import_ansi(void const *data, unsigned int size, | |||
/* Make sure the canvas is big enough. */ | |||
if((unsigned int)x + wch > width) | |||
{ | |||
cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_DEFAULT, | |||
CUCUL_TRANSPARENT)); | |||
cucul_set_color_ansi(cv, CUCUL_DEFAULT, CUCUL_TRANSPARENT); | |||
cucul_set_canvas_size(cv, width = x + wch, height); | |||
} | |||
if((unsigned int)y >= height) | |||
{ | |||
cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_DEFAULT, | |||
CUCUL_TRANSPARENT)); | |||
cucul_set_color_ansi(cv, CUCUL_DEFAULT, CUCUL_TRANSPARENT); | |||
cucul_set_canvas_size(cv, width, height = y + 1); | |||
} | |||
/* Now paste our character */ | |||
cucul_set_attr(cv, cucul_ansi_to_attr(grcm.efg, grcm.ebg)); | |||
cucul_set_color_ansi(cv, grcm.efg, grcm.ebg); | |||
cucul_putchar(cv, x, y, ch); | |||
x += wch; | |||
} | |||
if((unsigned int)y > height) | |||
{ | |||
cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_DEFAULT, | |||
CUCUL_TRANSPARENT)); | |||
cucul_set_color_ansi(cv, CUCUL_DEFAULT, CUCUL_TRANSPARENT); | |||
cucul_set_canvas_size(cv, width, height = y); | |||
} | |||
@@ -240,7 +240,7 @@ drawfire (void) | |||
paused: | |||
cucul_dither_bitmap(cv, 0, 0, cucul_get_canvas_width(cv), | |||
cucul_get_canvas_height(cv), cucul_dither, bitmap); | |||
cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_WHITE, CUCUL_BLUE)); | |||
cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLUE); | |||
if (sloop < 100) | |||
cucul_putstr(cv, cucul_get_canvas_width(cv) - 30, | |||
cucul_get_canvas_height(cv) - 2, | |||
@@ -161,16 +161,15 @@ paused: | |||
if(next != -1) | |||
{ | |||
fn[next](RENDER, backcv); | |||
cucul_set_attr(mask, cucul_ansi_to_attr(CUCUL_LIGHTGRAY, | |||
CUCUL_BLACK)); | |||
cucul_set_color_ansi(mask, CUCUL_LIGHTGRAY, CUCUL_BLACK); | |||
cucul_clear_canvas(mask); | |||
cucul_set_attr(mask, cucul_ansi_to_attr(CUCUL_WHITE, CUCUL_WHITE)); | |||
cucul_set_color_ansi(mask, CUCUL_WHITE, CUCUL_WHITE); | |||
transition(mask, tmode, | |||
100 * (frame - next_transition) / TRANSITION_FRAMES); | |||
cucul_blit(frontcv, 0, 0, backcv, mask); | |||
} | |||
cucul_set_attr(frontcv, cucul_ansi_to_attr(CUCUL_WHITE, CUCUL_BLUE)); | |||
cucul_set_color_ansi(frontcv, CUCUL_WHITE, CUCUL_BLUE); | |||
if(frame < 100) | |||
cucul_putstr(frontcv, cucul_get_canvas_width(frontcv) - 30, | |||
cucul_get_canvas_height(frontcv) - 2, | |||
@@ -693,10 +692,9 @@ void langton(enum action action, cucul_canvas_t *cv) | |||
uint8_t p = screen[x + width * y]; | |||
if(p & 0x0f) | |||
cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_WHITE, p >> 4)); | |||
cucul_set_color_ansi(cv, CUCUL_WHITE, p >> 4); | |||
else | |||
cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_BLACK, | |||
CUCUL_BLACK)); | |||
cucul_set_color_ansi(cv, CUCUL_BLACK, CUCUL_BLACK); | |||
cucul_putchar(cv, x, y, gradient[p & 0x0f]); | |||
} | |||
} | |||
@@ -760,7 +758,7 @@ void matrix(enum action action, cucul_canvas_t *cv) | |||
w = cucul_get_canvas_width(cv); | |||
h = cucul_get_canvas_height(cv); | |||
cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_BLACK, CUCUL_BLACK)); | |||
cucul_set_color_ansi(cv, CUCUL_BLACK, CUCUL_BLACK); | |||
cucul_clear_canvas(cv); | |||
for(i = 0; i < MAXDROPS && i < (w * h / 32); i++) | |||
@@ -782,7 +780,7 @@ void matrix(enum action action, cucul_canvas_t *cv) | |||
fg = CUCUL_GREEN; | |||
else | |||
fg = CUCUL_DARKGRAY; | |||
cucul_set_attr(cv, cucul_ansi_to_attr(fg, CUCUL_BLACK)); | |||
cucul_set_color_ansi(cv, fg, CUCUL_BLACK); | |||
cucul_putchar(cv, x, y - j, | |||
drop[i].str[(y - j) % drop[i].len]); | |||
@@ -151,7 +151,7 @@ quit: | |||
static int refresh_screen(void) | |||
{ | |||
cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_DEFAULT, CUCUL_DEFAULT)); | |||
cucul_set_color_ansi(cv, CUCUL_DEFAULT, CUCUL_DEFAULT); | |||
cucul_clear_canvas(cv); | |||
cucul_blit(cv, - x, - y, image, NULL); | |||
@@ -304,7 +304,7 @@ int main(int argc, char **argv) | |||
sprintf(buffer, " Loading `%s'... ", list[current]); | |||
buffer[ww] = '\0'; | |||
cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_WHITE, CUCUL_BLUE)); | |||
cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLUE); | |||
cucul_putstr(cv, (ww - strlen(buffer)) / 2, wh / 2, buffer); | |||
caca_refresh_display(dp); | |||
ww = cucul_get_canvas_width(cv); | |||
@@ -324,12 +324,12 @@ int main(int argc, char **argv) | |||
free(buffer); | |||
} | |||
cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_WHITE, CUCUL_BLACK)); | |||
cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLACK); | |||
cucul_clear_canvas(cv); | |||
if(!items) | |||
{ | |||
cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_WHITE, CUCUL_BLUE)); | |||
cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLUE); | |||
cucul_printf(cv, ww / 2 - 5, wh / 2, " No image. "); | |||
} | |||
else if(!im) | |||
@@ -349,7 +349,7 @@ int main(int argc, char **argv) | |||
sprintf(buffer, ERROR_STRING, list[current]); | |||
buffer[ww] = '\0'; | |||
cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_WHITE, CUCUL_BLUE)); | |||
cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLUE); | |||
cucul_putstr(cv, (ww - strlen(buffer)) / 2, wh / 2, buffer); | |||
free(buffer); | |||
} | |||
@@ -379,8 +379,7 @@ int main(int argc, char **argv) | |||
print_status(); | |||
#if 0 /* FIXME */ | |||
cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_LIGHTGRAY, | |||
CUCUL_BLACK)); | |||
cucul_set_color_ansi(cv, CUCUL_LIGHTGRAY, CUCUL_BLACK); | |||
switch(status) | |||
{ | |||
case STATUS_ANTIALIASING: | |||
@@ -419,7 +418,7 @@ int main(int argc, char **argv) | |||
static void print_status(void) | |||
{ | |||
cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_WHITE, CUCUL_BLUE)); | |||
cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLUE); | |||
cucul_draw_line(cv, 0, 0, ww - 1, 0, " "); | |||
cucul_draw_line(cv, 0, wh - 2, ww - 1, wh - 2, "-"); | |||
cucul_putstr(cv, 0, 0, "q:Quit np:Next/Prev +-x:Zoom gG:Gamma " | |||
@@ -429,7 +428,7 @@ static void print_status(void) | |||
cucul_printf(cv, ww - 30, wh - 2, "(gamma: %#.3g)", GAMMA(g)); | |||
cucul_printf(cv, ww - 14, wh - 2, "(zoom: %s%i)", zoom > 0 ? "+" : "", zoom); | |||
cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_LIGHTGRAY, CUCUL_BLACK)); | |||
cucul_set_color_ansi(cv, CUCUL_LIGHTGRAY, CUCUL_BLACK); | |||
cucul_draw_line(cv, 0, wh - 1, ww - 1, wh - 1, " "); | |||
} | |||
@@ -457,7 +456,7 @@ static void print_help(int x, int y) | |||
int i; | |||
cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_WHITE, CUCUL_BLUE)); | |||
cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLUE); | |||
for(i = 0; help[i]; i++) | |||
cucul_putstr(cv, x, y + i, help[i]); | |||
@@ -518,11 +517,9 @@ static void draw_checkers(int x, int y, int w, int h) | |||
for(xn = x > 0 ? x : 0; xn < x + w; xn++) | |||
{ | |||
if((((xn - x) / 5) ^ ((yn - y) / 3)) & 1) | |||
cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_LIGHTGRAY, | |||
CUCUL_DARKGRAY)); | |||
cucul_set_color_ansi(cv, CUCUL_LIGHTGRAY, CUCUL_DARKGRAY); | |||
else | |||
cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_DARKGRAY, | |||
CUCUL_LIGHTGRAY)); | |||
cucul_set_color_ansi(cv, CUCUL_DARKGRAY, CUCUL_LIGHTGRAY); | |||
cucul_putchar(cv, xn, yn, ' '); | |||
} | |||
} | |||
@@ -56,7 +56,7 @@ int main(int argc, char **argv) | |||
lines = cols * i->h * 6 / i->w / 10; | |||
cucul_set_canvas_size(cv, cols, lines); | |||
cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_DEFAULT, CUCUL_TRANSPARENT)); | |||
cucul_set_color_ansi(cv, CUCUL_DEFAULT, CUCUL_TRANSPARENT); | |||
cucul_clear_canvas(cv); | |||
cucul_dither_bitmap(cv, 0, 0, cols, lines, i->dither, i->pixels); | |||
@@ -35,22 +35,22 @@ int main(int argc, char **argv) | |||
if(!dp) | |||
return 1; | |||
cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_LIGHTGRAY, CUCUL_BLACK)); | |||
cucul_set_color_ansi(cv, CUCUL_LIGHTGRAY, CUCUL_BLACK); | |||
cucul_clear_canvas(cv); | |||
for(i = 0; i < 16; i++) | |||
{ | |||
cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_LIGHTGRAY, CUCUL_BLACK)); | |||
cucul_set_color_ansi(cv, CUCUL_LIGHTGRAY, CUCUL_BLACK); | |||
cucul_printf(cv, 3, i + (i >= 8 ? 3 : 2), "'%cv': %i (%s)", | |||
'a' + i, i, cucul_get_color_name(i)); | |||
'a' + i, i, cucul_ansi_to_str(i)); | |||
for(j = 0; j < 16; j++) | |||
{ | |||
cucul_set_attr(cv, cucul_ansi_to_attr(i, j)); | |||
cucul_set_color_ansi(cv, i, j); | |||
cucul_putstr(cv, (j >= 8 ? 40 : 39) + j * 2, i + (i >= 8 ? 3 : 2), | |||
"Aa"); | |||
} | |||
} | |||
cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_LIGHTGRAY, CUCUL_BLACK)); | |||
cucul_set_color_ansi(cv, CUCUL_LIGHTGRAY, CUCUL_BLACK); | |||
cucul_putstr(cv, 3, 20, "This is bold This is blink This is italics This is underline"); | |||
cucul_set_attr(cv, CUCUL_BOLD); | |||
cucul_putstr(cv, 3 + 8, 20, "bold"); | |||
@@ -150,8 +150,7 @@ int main(int argc, char **argv) | |||
if(demo) | |||
{ | |||
cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_LIGHTGRAY, | |||
CUCUL_BLACK)); | |||
cucul_set_color_ansi(cv, CUCUL_LIGHTGRAY, CUCUL_BLACK); | |||
cucul_clear_canvas(cv); | |||
} | |||
} | |||
@@ -172,7 +171,7 @@ int main(int argc, char **argv) | |||
display_menu(); | |||
if(mouse && !demo) | |||
{ | |||
cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_RED, CUCUL_BLACK)); | |||
cucul_set_color_ansi(cv, CUCUL_RED, CUCUL_BLACK); | |||
cucul_putstr(cv, xmouse, ymouse, "."); | |||
cucul_putstr(cv, xmouse, ymouse + 1, "|\\"); | |||
} | |||
@@ -184,8 +183,7 @@ int main(int argc, char **argv) | |||
{ | |||
demo(); | |||
cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_LIGHTGRAY, | |||
CUCUL_BLACK)); | |||
cucul_set_color_ansi(cv, CUCUL_LIGHTGRAY, CUCUL_BLACK); | |||
cucul_draw_thin_box(cv, 1, 1, cucul_get_canvas_width(cv) - 2, | |||
cucul_get_canvas_height(cv) - 2); | |||
cucul_printf(cv, 4, 1, "[%i.%i fps]----", | |||
@@ -210,7 +208,7 @@ static void display_menu(void) | |||
int xo = cucul_get_canvas_width(cv) - 2; | |||
int yo = cucul_get_canvas_height(cv) - 2; | |||
cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_LIGHTGRAY, CUCUL_BLACK)); | |||
cucul_set_color_ansi(cv, CUCUL_LIGHTGRAY, CUCUL_BLACK); | |||
cucul_clear_canvas(cv); | |||
cucul_draw_thin_box(cv, 1, 1, xo, yo); | |||
@@ -252,11 +250,11 @@ static void demo_all(void) | |||
i++; | |||
cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_LIGHTGRAY, CUCUL_BLACK)); | |||
cucul_set_color_ansi(cv, CUCUL_LIGHTGRAY, CUCUL_BLACK); | |||
cucul_clear_canvas(cv); | |||
/* Draw the sun */ | |||
cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_YELLOW, CUCUL_BLACK)); | |||
cucul_set_color_ansi(cv, CUCUL_YELLOW, CUCUL_BLACK); | |||
xo = cucul_get_canvas_width(cv) / 4; | |||
yo = cucul_get_canvas_height(cv) / 4 + 5 * sin(0.03*i); | |||
@@ -268,9 +266,9 @@ static void demo_all(void) | |||
} | |||
j = 15 + sin(0.03*i) * 8; | |||
cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_WHITE, CUCUL_BLACK)); | |||
cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLACK); | |||
cucul_fill_ellipse(cv, xo, yo, j, j / 2, "#"); | |||
cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_YELLOW, CUCUL_BLACK)); | |||
cucul_set_color_ansi(cv, CUCUL_YELLOW, CUCUL_BLACK); | |||
cucul_draw_ellipse(cv, xo, yo, j, j / 2, "#"); | |||
/* Draw the pyramid */ | |||
@@ -286,19 +284,19 @@ static void demo_all(void) | |||
xc = cucul_get_canvas_width(cv) / 4 - sin(0.02*i) * 5; | |||
yc = cucul_get_canvas_height(cv) * 3 / 4 + cos(0.02*i) * 5; | |||
cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_GREEN, CUCUL_BLACK)); | |||
cucul_set_color_ansi(cv, CUCUL_GREEN, CUCUL_BLACK); | |||
cucul_fill_triangle(cv, xo, yo, xb, yb, xa, ya, "%"); | |||
cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_YELLOW, CUCUL_BLACK)); | |||
cucul_set_color_ansi(cv, CUCUL_YELLOW, CUCUL_BLACK); | |||
cucul_draw_thin_triangle(cv, xo, yo, xb, yb, xa, ya); | |||
cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_RED, CUCUL_BLACK)); | |||
cucul_set_color_ansi(cv, CUCUL_RED, CUCUL_BLACK); | |||
cucul_fill_triangle(cv, xa, ya, xb, yb, xc, yc, "#"); | |||
cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_YELLOW, CUCUL_BLACK)); | |||
cucul_set_color_ansi(cv, CUCUL_YELLOW, CUCUL_BLACK); | |||
cucul_draw_thin_triangle(cv, xa, ya, xb, yb, xc, yc); | |||
cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_BLUE, CUCUL_BLACK)); | |||
cucul_set_color_ansi(cv, CUCUL_BLUE, CUCUL_BLACK); | |||
cucul_fill_triangle(cv, xo, yo, xb, yb, xc, yc, "%"); | |||
cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_YELLOW, CUCUL_BLACK)); | |||
cucul_set_color_ansi(cv, CUCUL_YELLOW, CUCUL_BLACK); | |||
cucul_draw_thin_triangle(cv, xo, yo, xb, yb, xc, yc); | |||
/* Draw a background triangle */ | |||
@@ -311,7 +309,7 @@ static void demo_all(void) | |||
xc = cucul_get_canvas_width(cv) / 3; | |||
yc = cucul_get_canvas_height(cv) - 3; | |||
cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_CYAN, CUCUL_BLACK)); | |||
cucul_set_color_ansi(cv, CUCUL_CYAN, CUCUL_BLACK); | |||
cucul_draw_thin_triangle(cv, xa, ya, xb, yb, xc, yc); | |||
xo = cucul_get_canvas_width(cv) / 2 + cos(0.027*i) * cucul_get_canvas_width(cv) / 3; | |||
@@ -330,8 +328,7 @@ static void demo_all(void) | |||
for(j = i - 60; j < i; j++) | |||
{ | |||
int delta = cucul_rand(-5, 6); | |||
cucul_set_attr(cv, cucul_ansi_to_attr(cucul_rand(0, 16), | |||
cucul_rand(0, 16))); | |||
cucul_set_color_ansi(cv, cucul_rand(0, 16), cucul_rand(0, 16)); | |||
cucul_putchar(cv, cucul_get_canvas_width(cv) / 2 | |||
+ cos(0.02*j) * (delta + cucul_get_canvas_width(cv) / 4), | |||
cucul_get_canvas_height(cv) / 2 | |||
@@ -360,8 +357,7 @@ static void demo_dots(void) | |||
for(i = 1000; i--;) | |||
{ | |||
/* Putpixel */ | |||
cucul_set_attr(cv, cucul_ansi_to_attr(cucul_rand(0, 16), | |||
cucul_rand(0, 16))); | |||
cucul_set_color_ansi(cv, cucul_rand(0, 16), cucul_rand(0, 16)); | |||
cucul_putchar(cv, cucul_rand(0, xmax), cucul_rand(0, ymax), | |||
chars[cucul_rand(0, 9)]); | |||
} | |||
@@ -372,16 +368,16 @@ static void demo_color(void) | |||
int i, j; | |||
char buf[BUFSIZ]; | |||
cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_LIGHTGRAY, CUCUL_BLACK)); | |||
cucul_set_color_ansi(cv, CUCUL_LIGHTGRAY, CUCUL_BLACK); | |||
cucul_clear_canvas(cv); | |||
for(i = 0; i < 16; i++) | |||
{ | |||
sprintf(buf, "'%c': %i (%s)", 'a' + i, i, cucul_get_color_name(i)); | |||
cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_LIGHTGRAY, CUCUL_BLACK)); | |||
sprintf(buf, "'%c': %i (%s)", 'a' + i, i, cucul_ansi_to_str(i)); | |||
cucul_set_color_ansi(cv, CUCUL_LIGHTGRAY, CUCUL_BLACK); | |||
cucul_putstr(cv, 4, i + (i >= 8 ? 4 : 3), buf); | |||
for(j = 0; j < 16; j++) | |||
{ | |||
cucul_set_attr(cv, cucul_ansi_to_attr(i, j)); | |||
cucul_set_color_ansi(cv, i, j); | |||
cucul_putstr(cv, (j >= 8 ? 41 : 40) + j * 2, i + (i >= 8 ? 4 : 3), "# "); | |||
} | |||
} | |||
@@ -404,7 +400,7 @@ static void demo_lines(void) | |||
xb = cucul_rand(0, w); yb = cucul_rand(0, h); | |||
} | |||
cucul_set_attr(cv, cucul_ansi_to_attr(cucul_rand(0, 16), CUCUL_BLACK)); | |||
cucul_set_color_ansi(cv, cucul_rand(0, 16), CUCUL_BLACK); | |||
if(outline > 1) | |||
cucul_draw_thin_line(cv, xa, ya, xb, yb); | |||
else | |||
@@ -428,11 +424,10 @@ static void demo_boxes(void) | |||
xb = cucul_rand(0, w); yb = cucul_rand(0, h); | |||
} | |||
cucul_set_attr(cv, cucul_ansi_to_attr(cucul_rand(0, 16), | |||
cucul_rand(0, 16))); | |||
cucul_set_color_ansi(cv, cucul_rand(0, 16), cucul_rand(0, 16)); | |||
cucul_fill_box(cv, xa, ya, xb, yb, "#"); | |||
cucul_set_attr(cv, cucul_ansi_to_attr(cucul_rand(0, 16), CUCUL_BLACK)); | |||
cucul_set_color_ansi(cv, cucul_rand(0, 16), CUCUL_BLACK); | |||
if(outline == 2) | |||
cucul_draw_thin_box(cv, xa, ya, xb, yb); | |||
else if(outline == 1) | |||
@@ -460,11 +455,10 @@ static void demo_ellipses(void) | |||
} while(x - a < 0 || x + a >= w || y - b < 0 || y + b >= h); | |||
} | |||
cucul_set_attr(cv, cucul_ansi_to_attr(cucul_rand(0, 16), | |||
cucul_rand(0, 16))); | |||
cucul_set_color_ansi(cv, cucul_rand(0, 16), cucul_rand(0, 16)); | |||
cucul_fill_ellipse(cv, x, y, a, b, "#"); | |||
cucul_set_attr(cv, cucul_ansi_to_attr(cucul_rand(0, 16), CUCUL_BLACK)); | |||
cucul_set_color_ansi(cv, cucul_rand(0, 16), CUCUL_BLACK); | |||
if(outline == 2) | |||
cucul_draw_thin_ellipse(cv, x, y, a, b); | |||
else if(outline == 1) | |||
@@ -491,11 +485,10 @@ static void demo_triangles(void) | |||
xc = cucul_rand(0, w); yc = cucul_rand(0, h); | |||
} | |||
cucul_set_attr(cv, cucul_ansi_to_attr(cucul_rand(0, 16), | |||
cucul_rand(0, 16))); | |||
cucul_set_color_ansi(cv, cucul_rand(0, 16), cucul_rand(0, 16)); | |||
cucul_fill_triangle(cv, xa, ya, xb, yb, xc, yc, "#"); | |||
cucul_set_attr(cv, cucul_ansi_to_attr(cucul_rand(0, 16), CUCUL_BLACK)); | |||
cucul_set_color_ansi(cv, cucul_rand(0, 16), CUCUL_BLACK); | |||
if(outline == 2) | |||
cucul_draw_thin_triangle(cv, xa, ya, xb, yb, xc, yc); | |||
else if(outline == 1) | |||
@@ -116,7 +116,7 @@ int main(int argc, char *argv[]) | |||
ch = density[distb * 2 * 13 / (dista + distb)]; | |||
else | |||
ch = density[dista * 2 * 13 / (dista + distb)]; | |||
cucul_set_attr(cv, cucul_ansi_to_attr(points[nearb], points[neara])); | |||
cucul_set_color_ansi(cv, points[nearb], points[neara]); | |||
cucul_putchar(cv, x * cucul_get_canvas_width(cv) / 100, | |||
(100 - y) * cucul_get_canvas_height(cv) / 100, ch); | |||
@@ -41,7 +41,7 @@ int main(int argc, char **argv) | |||
h = cucul_get_canvas_height(cv) - 1; | |||
cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_WHITE, CUCUL_BLUE)); | |||
cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLUE); | |||
cucul_draw_line(cv, 0, 0, cucul_get_canvas_width(cv) - 1, 0, " "); | |||
cucul_draw_line(cv, 0, h, cucul_get_canvas_width(cv) - 1, h, " "); | |||
@@ -83,11 +83,11 @@ int main(int argc, char **argv) | |||
} | |||
while(ret); | |||
cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_LIGHTGRAY, CUCUL_BLACK)); | |||
cucul_set_color_ansi(cv, CUCUL_LIGHTGRAY, CUCUL_BLACK); | |||
cucul_clear_canvas(cv); | |||
/* Print current event */ | |||
cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_WHITE, CUCUL_BLUE)); | |||
cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLUE); | |||
cucul_draw_line(cv, 0, 0, cucul_get_canvas_width(cv) - 1, 0, " "); | |||
print_event(0, 0, events); | |||
@@ -95,7 +95,7 @@ int main(int argc, char **argv) | |||
cucul_printf(cv, 0, h, "type \"quit\" to exit: %s", quit_string[quit]); | |||
/* Print previous events */ | |||
cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_WHITE, CUCUL_BLACK)); | |||
cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLACK); | |||
for(i = 1; i < h && events[i].type; i++) | |||
print_event(0, i, events + i); | |||
@@ -115,10 +115,10 @@ int main(int argc, char *argv[]) | |||
cucul_get_canvas_height(cv), dither, pixels); | |||
cucul_free_dither(dither); | |||
cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_WHITE, CUCUL_BLACK)); | |||
cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLACK); | |||
cucul_draw_thin_box(cv, 0, 0, WIDTH - 1, HEIGHT - 1); | |||
cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_BLACK, CUCUL_WHITE)); | |||
cucul_set_color_ansi(cv, CUCUL_BLACK, CUCUL_WHITE); | |||
cucul_fill_ellipse(cv, WIDTH / 2, HEIGHT / 2, | |||
WIDTH / 4, HEIGHT / 4, " "); | |||
cucul_putstr(cv, WIDTH / 2 - 5, HEIGHT / 2 - 5, "(\") \\o/ <&>"); | |||
@@ -134,14 +134,14 @@ int main(int argc, char *argv[]) | |||
cucul_putstr(cv, WIDTH / 2 - 1, HEIGHT / 2 + 3, "Italics"); | |||
cucul_set_attr(cv, CUCUL_UNDERLINE); | |||
cucul_putstr(cv, WIDTH / 2 + 8, HEIGHT / 2 + 3, "Underline"); | |||
cucul_set_attr(cv, 0); | |||
cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_WHITE, CUCUL_LIGHTBLUE)); | |||
cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_LIGHTBLUE); | |||
cucul_putstr(cv, WIDTH / 2 - 7, HEIGHT / 2, " LIBCACA "); | |||
for(x = 0; x < 16; x++) | |||
{ | |||
cucul_set_attr(cv, cucul_argb_to_attr(0xff00 | x, | |||
0xf00f | (x << 4))); | |||
cucul_set_color_argb(cv, 0xff00 | x, 0xf00f | (x << 4)); | |||
cucul_putstr(cv, WIDTH / 2 - 7 + x, HEIGHT / 2 + 5, "#"); | |||
} | |||
} | |||
@@ -45,11 +45,11 @@ int main(int argc, char *argv[]) | |||
cv = cucul_create_canvas(8, 2); | |||
/* Draw stuff on our canvas */ | |||
cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_WHITE, CUCUL_BLACK)); | |||
cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLACK); | |||
cucul_putstr(cv, 0, 0, "ABcde"); | |||
cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_LIGHTRED, CUCUL_BLACK)); | |||
cucul_set_color_ansi(cv, CUCUL_LIGHTRED, CUCUL_BLACK); | |||
cucul_putstr(cv, 5, 0, "\\o/"); | |||
cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_WHITE, CUCUL_BLUE)); | |||
cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLUE); | |||
cucul_putstr(cv, 0, 1, "&$âøÿØ?!"); | |||
/* Load a libcucul internal font */ | |||
@@ -58,7 +58,7 @@ int main(int argc, char *argv[]) | |||
/* Create a canvas */ | |||
cv = cucul_create_canvas(WIDTH, (glyphs + WIDTH - 1) / WIDTH); | |||
cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_BLACK, CUCUL_WHITE)); | |||
cucul_set_color_ansi(cv, CUCUL_BLACK, CUCUL_WHITE); | |||
/* Put all glyphs on the canvas */ | |||
x = y = 0; | |||
@@ -48,9 +48,9 @@ int main(int argc, char *argv[]) | |||
for(frame = 0; frame < 16; frame++) | |||
{ | |||
cucul_set_canvas_frame(cv, frame); | |||
cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_WHITE, frame)); | |||
cucul_set_color_ansi(cv, CUCUL_WHITE, frame); | |||
cucul_fill_box(cv, 0, 0, 40, 15, ":"); | |||
cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_WHITE, CUCUL_BLUE)); | |||
cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLUE); | |||
cucul_putstr(cv, frame * 5 / 2, frame, "カカ"); | |||
} | |||
@@ -60,7 +60,7 @@ int main(int argc, char *argv[]) | |||
fprintf(stderr, "canvas shrinked, size is %ix%i\n", | |||
cucul_get_canvas_width(cv), cucul_get_canvas_height(cv)); | |||
cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_DEFAULT, CUCUL_TRANSPARENT)); | |||
cucul_set_color_ansi(cv, CUCUL_DEFAULT, CUCUL_TRANSPARENT); | |||
dp = caca_create_display(cv); | |||
caca_set_display_time(dp, 50000); | |||
@@ -42,9 +42,9 @@ int main(int argc, char *argv[]) | |||
/* Line of x's */ | |||
for(i = 0; i < 10; i++) | |||
{ | |||
cucul_set_attr(caca, cucul_ansi_to_attr(CUCUL_WHITE, CUCUL_BLUE)); | |||
cucul_set_color_ansi(caca, CUCUL_WHITE, CUCUL_BLUE); | |||
cucul_putstr(caca, 0, i, CACA); | |||
cucul_set_attr(caca, cucul_ansi_to_attr(CUCUL_WHITE, CUCUL_RED)); | |||
cucul_set_color_ansi(caca, CUCUL_WHITE, CUCUL_RED); | |||
cucul_putchar(caca, i - 2, i, 'x'); | |||
} | |||
@@ -53,20 +53,20 @@ int main(int argc, char *argv[]) | |||
/* Line of ホ's */ | |||
for(i = 0; i < 10; i++) | |||
{ | |||
cucul_set_attr(caca, cucul_ansi_to_attr(CUCUL_WHITE, CUCUL_BLUE)); | |||
cucul_set_color_ansi(caca, CUCUL_WHITE, CUCUL_BLUE); | |||
cucul_putstr(caca, 0, i, CACA); | |||
cucul_set_attr(caca, cucul_ansi_to_attr(CUCUL_WHITE, CUCUL_GREEN)); | |||
cucul_set_color_ansi(caca, CUCUL_WHITE, CUCUL_GREEN); | |||
cucul_putstr(caca, i - 2, i, "ホ"); | |||
} | |||
cucul_blit(cv, 15, 1, caca, NULL); | |||
/* Line of canvas */ | |||
cucul_set_attr(line, cucul_ansi_to_attr(CUCUL_WHITE, CUCUL_MAGENTA)); | |||
cucul_set_color_ansi(line, CUCUL_WHITE, CUCUL_MAGENTA); | |||
cucul_putstr(line, 0, 0, "ほ"); | |||
for(i = 0; i < 10; i++) | |||
{ | |||
cucul_set_attr(caca, cucul_ansi_to_attr(CUCUL_WHITE, CUCUL_BLUE)); | |||
cucul_set_color_ansi(caca, CUCUL_WHITE, CUCUL_BLUE); | |||
cucul_putstr(caca, 0, i, CACA); | |||
cucul_blit(caca, i - 2, i, line, NULL); | |||
} | |||
@@ -86,9 +86,9 @@ int main(int argc, char *argv[]) | |||
cucul_get_canvas_height(cw), right, buffer); | |||
/* Draw something on the mask */ | |||
cucul_set_attr(mask, cucul_ansi_to_attr(CUCUL_LIGHTGRAY, CUCUL_BLACK)); | |||
cucul_set_color_ansi(mask, CUCUL_LIGHTGRAY, CUCUL_BLACK); | |||
cucul_clear_canvas(mask); | |||
cucul_set_attr(mask, cucul_ansi_to_attr(CUCUL_WHITE, CUCUL_WHITE)); | |||
cucul_set_color_ansi(mask, CUCUL_WHITE, CUCUL_WHITE); | |||
cucul_fill_ellipse(mask, (1.0 + sin(0.05 * (float)x)) | |||
* 0.5 * cucul_get_canvas_width(mask), | |||
(1.0 + cos(0.05 * (float)x)) | |||
@@ -99,7 +99,7 @@ int main(int argc, char *argv[]) | |||
/* Blit the spare canvas onto the first one */ | |||
cucul_blit(cv, 0, 0, cw, mask); | |||
cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_WHITE, CUCUL_BLUE)); | |||
cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLUE); | |||
cucul_printf(cv, 2, 1, | |||
"gamma=%g - use arrows to change, Esc to quit", gam); | |||
@@ -43,7 +43,7 @@ int main(int argc, char *argv[]) | |||
cv = cucul_create_canvas(0, 0); | |||
dp = caca_create_display(cv); | |||
cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_WHITE, CUCUL_BLUE)); | |||
cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLUE); | |||
cucul_putstr(cv, 1, 1, "Text entries - press tab to cycle"); | |||
for(i = 0; i < TEXT_ENTRIES; i++) | |||
@@ -61,8 +61,7 @@ int main(int argc, char *argv[]) | |||
{ | |||
unsigned int j, start, size; | |||
cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_BLACK, | |||
CUCUL_LIGHTGRAY)); | |||
cucul_set_color_ansi(cv, CUCUL_BLACK, CUCUL_LIGHTGRAY); | |||
cucul_fill_box(cv, 2, 3 * i + 4, 2 + BUFFER_SIZE, 3 * i + 4, " "); | |||
start = 0; | |||
@@ -76,7 +75,7 @@ int main(int argc, char *argv[]) | |||
} | |||
/* Put the cursor on the active textentry */ | |||
cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_LIGHTRED, CUCUL_LIGHTRED)); | |||
cucul_set_color_ansi(cv, CUCUL_LIGHTRED, CUCUL_LIGHTRED); | |||
cucul_putchar(cv, 2 + entries[e].cursor, 3 * e + 4, ' '); | |||
caca_refresh_display(dp); | |||
@@ -102,7 +102,7 @@ int main(int argc, char **argv) | |||
} | |||
cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_LIGHTGRAY, CUCUL_BLACK)); | |||
cucul_set_color_ansi(cv, CUCUL_LIGHTGRAY, CUCUL_BLACK); | |||
cucul_clear_canvas(cv); | |||
cucul_draw_thin_box(cv, 0, 0, cucul_get_canvas_width(cv) - 1, | |||
@@ -125,9 +125,9 @@ int main(int argc, char **argv) | |||
ya = -1 - cucul_get_sprite_dy(sprite, frame); | |||
xb = xa + 1 + cucul_get_sprite_width(sprite, frame); | |||
yb = ya + 1 + cucul_get_sprite_height(sprite, frame); | |||
cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_BLACK, CUCUL_BLACK)); | |||
cucul_set_color_ansi(cv, CUCUL_BLACK, CUCUL_BLACK); | |||
cucul_fill_box(cv, 57 + xa, 10 + ya, 57 + xb, 10 + yb, " "); | |||
cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_LIGHTGRAY, CUCUL_BLACK)); | |||
cucul_set_color_ansi(cv, CUCUL_LIGHTGRAY, CUCUL_BLACK); | |||
cucul_draw_thin_box(cv, 57 + xa, 10 + ya, 57 + xb, 10 + yb); | |||
cucul_draw_sprite(cv, 57, 10, sprite, frame); | |||
@@ -58,26 +58,26 @@ int main(int argc, char *argv[]) | |||
flop = cucul_create_canvas(70, 6); | |||
rotate = cucul_create_canvas(70, 6); | |||
cucul_set_attr(normal, cucul_ansi_to_attr(CUCUL_LIGHTMAGENTA, CUCUL_BLACK)); | |||
cucul_set_color_ansi(normal, CUCUL_LIGHTMAGENTA, CUCUL_BLACK); | |||
for(i = 0; pig[i]; i++) | |||
cucul_putstr(normal, 55, i, pig[i]); | |||
cucul_set_attr(normal, cucul_ansi_to_attr(CUCUL_LIGHTGREEN, CUCUL_BLACK)); | |||
cucul_set_color_ansi(normal, CUCUL_LIGHTGREEN, CUCUL_BLACK); | |||
for(i = 0; duck[i]; i++) | |||
cucul_putstr(normal, 30, 1 + i, duck[i]); | |||
cucul_set_attr(normal, cucul_ansi_to_attr(CUCUL_LIGHTCYAN, CUCUL_BLACK)); | |||
cucul_set_color_ansi(normal, CUCUL_LIGHTCYAN, CUCUL_BLACK); | |||
cucul_putstr(normal, 1, 1, "hahaha mais vieux porc immonde !! [⽼ ⾗]"); | |||
cucul_set_attr(normal, cucul_ansi_to_attr(CUCUL_LIGHTRED, CUCUL_BLACK)); | |||
cucul_set_color_ansi(normal, CUCUL_LIGHTRED, CUCUL_BLACK); | |||
cucul_putchar(normal, 38, 1, '|'); | |||
cucul_set_attr(normal, cucul_ansi_to_attr(CUCUL_YELLOW, CUCUL_BLACK)); | |||
cucul_set_color_ansi(normal, CUCUL_YELLOW, CUCUL_BLACK); | |||
cucul_putstr(normal, 4, 2, "\\o\\ \\o| _o/ \\o_ |o/ /o/"); | |||
cucul_set_attr(normal, cucul_ansi_to_attr(CUCUL_WHITE, CUCUL_LIGHTRED)); | |||
cucul_set_color_ansi(normal, CUCUL_WHITE, CUCUL_LIGHTRED); | |||
cucul_putstr(normal, 7, 3, "▙▘▌▙▘▞▖▞▖▌ ▞▖▌ ▌▌"); | |||
cucul_putstr(normal, 7, 4, "▛▖▌▛▖▚▘▚▘▚▖▚▘▚▖▖▖"); | |||
cucul_set_attr(normal, cucul_ansi_to_attr(CUCUL_BLACK, CUCUL_LIGHTRED)); | |||
cucul_set_color_ansi(normal, CUCUL_BLACK, CUCUL_LIGHTRED); | |||
cucul_putstr(normal, 4, 3, "▓▒░"); | |||
cucul_putstr(normal, 4, 4, "▓▒░"); | |||
cucul_putstr(normal, 24, 3, "░▒▓"); | |||
@@ -94,7 +94,7 @@ int main(int argc, char *argv[]) | |||
cucul_rotate(rotate); | |||
/* Blit the transformed canvas onto the main canvas */ | |||
cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_WHITE, CUCUL_BLUE)); | |||
cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLUE); | |||
cucul_putstr(cv, 0, 0, "normal"); | |||
cucul_blit(cv, 10, 0, normal, NULL); | |||
cucul_putstr(cv, 0, 6, "flip"); | |||
@@ -40,11 +40,11 @@ int main(int argc, char *argv[]) | |||
uint16_t bgcolor = 0xff00 | (y << 4) | x; | |||
uint16_t fgcolor = 0xf000 | ((15 - y) << 4) | ((15 - x) << 8); | |||
cucul_set_attr(cv, cucul_argb_to_attr(fgcolor, bgcolor)); | |||
cucul_set_color_argb(cv, fgcolor, bgcolor); | |||
cucul_putstr(cv, x * 2, y, "CA"); | |||
} | |||
cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_WHITE, CUCUL_LIGHTBLUE)); | |||
cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_LIGHTBLUE); | |||
cucul_putstr(cv, 2, 1, " truecolor libcaca "); | |||
caca_refresh_display(dp); | |||
@@ -24,9 +24,6 @@ | |||
#include "cucul.h" | |||
#include "caca.h" | |||
#define ATTR_WHITE_ON_BLUE cucul_ansi_to_attr(CUCUL_WHITE, CUCUL_BLUE) | |||
#define ATTR_DEFAULT cucul_ansi_to_attr(CUCUL_DEFAULT, CUCUL_TRANSPARENT) | |||
int main(int argc, char *argv[]) | |||
{ | |||
cucul_canvas_t *cv; | |||
@@ -35,52 +32,52 @@ int main(int argc, char *argv[]) | |||
cv = cucul_create_canvas(0, 0); | |||
dp = caca_create_display(cv); | |||
cucul_set_attr(cv, ATTR_WHITE_ON_BLUE); | |||
cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLUE); | |||
cucul_putstr(cv, 1, 1, "Basic Unicode support"); | |||
cucul_set_attr(cv, ATTR_DEFAULT); | |||
cucul_set_color_ansi(cv, CUCUL_DEFAULT, CUCUL_TRANSPARENT); | |||
cucul_putstr(cv, 1, 2, "This is ASCII: | abc DEF 123 !@# |"); | |||
cucul_putstr(cv, 1, 3, "This is Unicode: | äßç δεφ ☺♥♀ ╞╬╗ |"); | |||
cucul_putstr(cv, 1, 4, "And this is, too: | ἀβϛ ΔЗҒ ᚴᛒᛯ ♩♔✈ |"); | |||
cucul_putstr(cv, 1, 5, "If the three lines do not have the same length, there is a bug somewhere."); | |||
cucul_set_attr(cv, ATTR_WHITE_ON_BLUE); | |||
cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLUE); | |||
cucul_putstr(cv, 1, 7, "Gradient glyphs"); | |||
cucul_set_attr(cv, ATTR_DEFAULT); | |||
cucul_set_color_ansi(cv, CUCUL_DEFAULT, CUCUL_TRANSPARENT); | |||
cucul_putstr(cv, 31, 8, " 0%"); | |||
cucul_putstr(cv, 31, 9, " 25%"); | |||
cucul_putstr(cv, 31, 10, " 50%"); | |||
cucul_putstr(cv, 31, 11, " 75%"); | |||
cucul_putstr(cv, 31, 12, "100%"); | |||
cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_LIGHTRED, CUCUL_LIGHTGREEN)); | |||
cucul_set_color_ansi(cv, CUCUL_LIGHTRED, CUCUL_LIGHTGREEN); | |||
cucul_putstr(cv, 1, 8, " "); | |||
cucul_putstr(cv, 1, 9, "░░░░░░░░░░░░░░░░░░░░░░░░░░░░░"); | |||
cucul_putstr(cv, 1, 10, "▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒"); | |||
cucul_putstr(cv, 1, 11, "▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓"); | |||
cucul_putstr(cv, 1, 12, "█████████████████████████████"); | |||
cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_LIGHTGREEN, CUCUL_LIGHTRED)); | |||
cucul_set_color_ansi(cv, CUCUL_LIGHTGREEN, CUCUL_LIGHTRED); | |||
cucul_putstr(cv, 36, 8, "█████████████████████████████"); | |||
cucul_putstr(cv, 36, 9, "▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓"); | |||
cucul_putstr(cv, 36, 10, "▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒"); | |||
cucul_putstr(cv, 36, 11, "░░░░░░░░░░░░░░░░░░░░░░░░░░░░░"); | |||
cucul_putstr(cv, 36, 12, " "); | |||
cucul_set_attr(cv, ATTR_WHITE_ON_BLUE); | |||
cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLUE); | |||
cucul_putstr(cv, 1, 14, "Double width characters"); | |||
cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_LIGHTRED, CUCUL_TRANSPARENT)); | |||
cucul_set_color_ansi(cv, CUCUL_LIGHTRED, CUCUL_TRANSPARENT); | |||
cucul_putstr(cv, 1, 15, "| ドラゴン ボーレ |"); | |||
cucul_set_attr(cv, ATTR_DEFAULT); | |||
cucul_set_color_ansi(cv, CUCUL_DEFAULT, CUCUL_TRANSPARENT); | |||
cucul_putstr(cv, 1, 16, "| ()()()() ()()() |"); | |||
cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_YELLOW, CUCUL_TRANSPARENT)); | |||
cucul_set_color_ansi(cv, CUCUL_YELLOW, CUCUL_TRANSPARENT); | |||
cucul_putstr(cv, 1, 17, "| ドラゴン"); | |||
cucul_putstr(cv, 12, 17, "ボーレ |"); | |||
cucul_set_attr(cv, ATTR_DEFAULT); | |||
cucul_set_color_ansi(cv, CUCUL_DEFAULT, CUCUL_TRANSPARENT); | |||
cucul_putstr(cv, 1, 18, "If the three lines do not have the same length, there is a bug somewhere."); | |||
cucul_putstr(cv, 1, 20, "CP437 glyphs: ☺ ☻ ♥ ♦ ♣ ♠ • ◘ ○ ◙ ♂ ♀ ♪ ♫ ☼ ► ◄ ↕ ‼ ¶ § ▬ ↨ ↑ ↓ → ← ∟ ↔ ▲ ▼"); | |||