* Changed the line, box, ellipsis etc. prototypes so that they use an UTF-8 string instead of a single character as their last argument.tags/v0.99.beta14
@@ -33,15 +33,16 @@ | |||
* \param y1 Y coordinate of the upper-left corner of the box. | |||
* \param x2 X coordinate of the lower-right corner of the box. | |||
* \param y2 Y coordinate of the lower-right corner of the box. | |||
* \param c Character to draw the box outline with. | |||
* \param str UTF-8 string containing the character to use to draw the box. | |||
* \return void | |||
*/ | |||
void cucul_draw_box(cucul_t *qq, int x1, int y1, int x2, int y2, char c) | |||
void cucul_draw_box(cucul_t *qq, int x1, int y1, int x2, int y2, | |||
char const *str) | |||
{ | |||
cucul_draw_line(qq, x1, y1, x1, y2, c); | |||
cucul_draw_line(qq, x1, y2, x2, y2, c); | |||
cucul_draw_line(qq, x2, y2, x2, y1, c); | |||
cucul_draw_line(qq, x2, y1, x1, y1, c); | |||
cucul_draw_line(qq, x1, y1, x1, y2, str); | |||
cucul_draw_line(qq, x1, y2, x2, y2, str); | |||
cucul_draw_line(qq, x2, y2, x2, y1, str); | |||
cucul_draw_line(qq, x2, y1, x1, y1, str); | |||
} | |||
/** | |||
@@ -78,32 +79,32 @@ void cucul_draw_thin_box(cucul_t *qq, int x1, int y1, int x2, int y2) | |||
/* Draw edges */ | |||
if(y1 >= 0) | |||
for(x = x1 < 0 ? 1 : x1 + 1; x < x2 && x < xmax; x++) | |||
cucul_putchar(qq, x, y1, '-'); | |||
_cucul_putchar32(qq, x, y1, (uint32_t)'-'); | |||
if(y2 <= ymax) | |||
for(x = x1 < 0 ? 1 : x1 + 1; x < x2 && x < xmax; x++) | |||
cucul_putchar(qq, x, y2, '-'); | |||
_cucul_putchar32(qq, x, y2, (uint32_t)'-'); | |||
if(x1 >= 0) | |||
for(y = y1 < 0 ? 1 : y1 + 1; y < y2 && y < ymax; y++) | |||
cucul_putchar(qq, x1, y, '|'); | |||
_cucul_putchar32(qq, x1, y, (uint32_t)'|'); | |||
if(x2 <= xmax) | |||
for(y = y1 < 0 ? 1 : y1 + 1; y < y2 && y < ymax; y++) | |||
cucul_putchar(qq, x2, y, '|'); | |||
_cucul_putchar32(qq, x2, y, (uint32_t)'|'); | |||
/* Draw corners */ | |||
if(x1 >= 0 && y1 >= 0) | |||
cucul_putchar(qq, x1, y1, ','); | |||
_cucul_putchar32(qq, x1, y1, (uint32_t)','); | |||
if(x1 >= 0 && y2 <= ymax) | |||
cucul_putchar(qq, x1, y2, '`'); | |||
_cucul_putchar32(qq, x1, y2, (uint32_t)'`'); | |||
if(x2 <= xmax && y1 >= 0) | |||
cucul_putchar(qq, x2, y1, '.'); | |||
_cucul_putchar32(qq, x2, y1, (uint32_t)'.'); | |||
if(x2 <= xmax && y2 <= ymax) | |||
cucul_putchar(qq, x2, y2, '\''); | |||
_cucul_putchar32(qq, x2, y2, (uint32_t)'\''); | |||
} | |||
/** | |||
@@ -113,12 +114,14 @@ void cucul_draw_thin_box(cucul_t *qq, int x1, int y1, int x2, int y2) | |||
* \param y1 Y coordinate of the upper-left corner of the box. | |||
* \param x2 X coordinate of the lower-right corner of the box. | |||
* \param y2 Y coordinate of the lower-right corner of the box. | |||
* \param c Character to fill the box with. | |||
* \param str UTF-8 string containing the character to fill the box with. | |||
* \return void | |||
*/ | |||
void cucul_fill_box(cucul_t *qq, int x1, int y1, int x2, int y2, char c) | |||
void cucul_fill_box(cucul_t *qq, int x1, int y1, int x2, int y2, | |||
char const *str) | |||
{ | |||
int x, y, xmax, ymax; | |||
uint32_t c; | |||
if(x1 > x2) | |||
{ | |||
@@ -143,8 +146,10 @@ void cucul_fill_box(cucul_t *qq, int x1, int y1, int x2, int y2, char c) | |||
if(x2 > xmax) x2 = xmax; | |||
if(y2 > ymax) y2 = ymax; | |||
c = _cucul_utf8_to_utf32(str); | |||
for(y = y1; y <= y2; y++) | |||
for(x = x1; x <= x2; x++) | |||
cucul_putchar(qq, x, y, c); | |||
_cucul_putchar32(qq, x, y, c); | |||
} | |||
@@ -108,33 +108,6 @@ void cucul_putchar(cucul_t *qq, int x, int y, char c) | |||
qq->attr[x + y * qq->width] = (qq->bgcolor << 4) | qq->fgcolor; | |||
} | |||
/** \brief Print a Unicode character. | |||
* | |||
* FIXME: do we really want this function? | |||
* | |||
* This function prints a Unicode character (native-endian, 32 bits UCS-4, | |||
* also known as UTF-32) at the given coordinates, using the default | |||
* foreground and background values. If the coordinates are outside the | |||
* screen boundaries, nothing is printed. If the character is an invalid | |||
* Unicode character, it is replaced with a space. | |||
* | |||
* \param x X coordinate. | |||
* \param y Y coordinate. | |||
* \param c The character to print. | |||
*/ | |||
void cucul_putchar32(cucul_t *qq, int x, int y, unsigned long int c) | |||
{ | |||
if(x < 0 || x >= (int)qq->width || | |||
y < 0 || y >= (int)qq->height) | |||
return; | |||
if(c < 0x20 || c > 0x7f) | |||
c = 0x20; | |||
qq->chars[x + y * qq->width] = c; | |||
qq->attr[x + y * qq->width] = (qq->bgcolor << 4) | qq->fgcolor; | |||
} | |||
/** \brief Print a string. | |||
* | |||
* This function prints an UTF-8 string at the given coordinates, using the | |||
@@ -313,3 +286,17 @@ void cucul_blit(cucul_t *dst, int x, int y, | |||
} | |||
} | |||
/* | |||
* XXX: The following functions are not exported | |||
*/ | |||
void _cucul_putchar32(cucul_t *qq, int x, int y, uint32_t c) | |||
{ | |||
if(x < 0 || x >= (int)qq->width || | |||
y < 0 || y >= (int)qq->height) | |||
return; | |||
qq->chars[x + y * qq->width] = c; | |||
qq->attr[x + y * qq->width] = (qq->bgcolor << 4) | qq->fgcolor; | |||
} | |||
@@ -27,7 +27,7 @@ | |||
#include "cucul.h" | |||
#include "cucul_internals.h" | |||
static void ellipsepoints(cucul_t *, int, int, int, int, char); | |||
static void ellipsepoints(cucul_t *, int, int, int, int, uint32_t); | |||
/** | |||
* \brief Draw a circle on the screen using the given character. | |||
@@ -38,9 +38,10 @@ static void ellipsepoints(cucul_t *, int, int, int, int, char); | |||
* \param c Character to draw the circle outline with. | |||
* \return void | |||
*/ | |||
void cucul_draw_circle(cucul_t *qq, int x, int y, int r, char c) | |||
void cucul_draw_circle(cucul_t *qq, int x, int y, int r, char const *str) | |||
{ | |||
int test, dx, dy; | |||
uint32_t c = _cucul_utf8_to_utf32(str); | |||
/* Optimized Bresenham. Kick ass. */ | |||
for(test = 0, dx = 0, dy = r ; dx <= dy ; dx++) | |||
@@ -62,7 +63,8 @@ void cucul_draw_circle(cucul_t *qq, int x, int y, int r, char c) | |||
* \param c Character to fill the ellipse with. | |||
* \return void | |||
*/ | |||
void cucul_fill_ellipse(cucul_t *qq, int xo, int yo, int a, int b, char c) | |||
void cucul_fill_ellipse(cucul_t *qq, int xo, int yo, int a, int b, | |||
char const *str) | |||
{ | |||
int d2; | |||
int x = 0; | |||
@@ -78,15 +80,15 @@ void cucul_fill_ellipse(cucul_t *qq, int xo, int yo, int a, int b, char c) | |||
else | |||
{ | |||
d1 += b*b*(2*x*1) + a*a*(-2*y+2); | |||
cucul_draw_line(qq, xo - x, yo - y, xo + x, yo - y, c); | |||
cucul_draw_line(qq, xo - x, yo + y, xo + x, yo + y, c); | |||
cucul_draw_line(qq, xo - x, yo - y, xo + x, yo - y, str); | |||
cucul_draw_line(qq, xo - x, yo + y, xo + x, yo + y, str); | |||
y--; | |||
} | |||
x++; | |||
} | |||
cucul_draw_line(qq, xo - x, yo - y, xo + x, yo - y, c); | |||
cucul_draw_line(qq, xo - x, yo + y, xo + x, yo + y, c); | |||
cucul_draw_line(qq, xo - x, yo - y, xo + x, yo - y, str); | |||
cucul_draw_line(qq, xo - x, yo + y, xo + x, yo + y, str); | |||
d2 = b*b*(x+0.5)*(x+0.5) + a*a*(y-1)*(y-1) - a*a*b*b; | |||
while(y > 0) | |||
@@ -102,8 +104,8 @@ void cucul_fill_ellipse(cucul_t *qq, int xo, int yo, int a, int b, char c) | |||
} | |||
y--; | |||
cucul_draw_line(qq, xo - x, yo - y, xo + x, yo - y, c); | |||
cucul_draw_line(qq, xo - x, yo + y, xo + x, yo + y, c); | |||
cucul_draw_line(qq, xo - x, yo - y, xo + x, yo - y, str); | |||
cucul_draw_line(qq, xo - x, yo + y, xo + x, yo + y, str); | |||
} | |||
} | |||
@@ -117,12 +119,14 @@ void cucul_fill_ellipse(cucul_t *qq, int xo, int yo, int a, int b, char c) | |||
* \param c Character to draw the ellipse outline with. | |||
* \return void | |||
*/ | |||
void cucul_draw_ellipse(cucul_t *qq, int xo, int yo, int a, int b, char c) | |||
void cucul_draw_ellipse(cucul_t *qq, int xo, int yo, int a, int b, | |||
char const *str) | |||
{ | |||
int d2; | |||
int x = 0; | |||
int y = b; | |||
int d1 = b*b - (a*a*b) + (a*a/4); | |||
uint32_t c = _cucul_utf8_to_utf32(str); | |||
ellipsepoints(qq, xo, yo, x, y, c); | |||
@@ -211,7 +215,7 @@ void cucul_draw_thin_ellipse(cucul_t *qq, int xo, int yo, int a, int b) | |||
} | |||
} | |||
static void ellipsepoints(cucul_t *qq, int xo, int yo, int x, int y, char c) | |||
static void ellipsepoints(cucul_t *qq, int xo, int yo, int x, int y, uint32_t c) | |||
{ | |||
uint8_t b = 0; | |||
@@ -225,15 +229,15 @@ static void ellipsepoints(cucul_t *qq, int xo, int yo, int x, int y, char c) | |||
b |= 0x8; | |||
if((b & (0x1|0x4)) == (0x1|0x4)) | |||
cucul_putchar(qq, xo + x, yo + y, c); | |||
_cucul_putchar32(qq, xo + x, yo + y, c); | |||
if((b & (0x2|0x4)) == (0x2|0x4)) | |||
cucul_putchar(qq, xo - x, yo + y, c); | |||
_cucul_putchar32(qq, xo - x, yo + y, c); | |||
if((b & (0x1|0x8)) == (0x1|0x8)) | |||
cucul_putchar(qq, xo + x, yo - y, c); | |||
_cucul_putchar32(qq, xo + x, yo - y, c); | |||
if((b & (0x2|0x8)) == (0x2|0x8)) | |||
cucul_putchar(qq, xo - x, yo - y, c); | |||
_cucul_putchar32(qq, xo - x, yo - y, c); | |||
} | |||
@@ -162,23 +162,23 @@ void cucul_rotate(cucul_t *); | |||
* 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_line(cucul_t *, int, int, int, int, char const *); | |||
void cucul_draw_polyline(cucul_t *, int const x[], int const y[], int, char const *); | |||
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_circle(cucul_t *, int, int, int, char const *); | |||
void cucul_draw_ellipse(cucul_t *, int, int, int, int, char const *); | |||
void cucul_draw_thin_ellipse(cucul_t *, int, int, int, int); | |||
void cucul_fill_ellipse(cucul_t *, int, int, int, int, char); | |||
void cucul_fill_ellipse(cucul_t *, int, int, int, int, char const *); | |||
void cucul_draw_box(cucul_t *, int, int, int, int, char); | |||
void cucul_draw_box(cucul_t *, int, int, int, int, char const *); | |||
void cucul_draw_thin_box(cucul_t *, int, int, int, int); | |||
void cucul_fill_box(cucul_t *, int, int, int, int, char); | |||
void cucul_fill_box(cucul_t *, int, int, int, int, char const *); | |||
void cucul_draw_triangle(cucul_t *, int, int, int, int, int, int, char); | |||
void cucul_draw_triangle(cucul_t *, int, int, int, int, int, int, char const *); | |||
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); | |||
void cucul_fill_triangle(cucul_t *, int, int, int, int, int, int, char const *); | |||
/* @} */ | |||
/** \defgroup math Mathematical functions | |||
@@ -49,10 +49,13 @@ struct cucul_context | |||
unsigned int refcount; | |||
}; | |||
/* Initialisation functions */ | |||
/* Bitmap functions */ | |||
extern int _cucul_init_bitmap(void); | |||
extern int _cucul_end_bitmap(void); | |||
/* Canvas functions */ | |||
extern void _cucul_set_size(cucul_t *, unsigned int, unsigned int); | |||
extern void _cucul_putchar32(cucul_t *qq, int x, int y, uint32_t c); | |||
/* Charset functions */ | |||
extern unsigned int _cucul_strlen_utf8(char const *); | |||
@@ -32,7 +32,7 @@ struct line | |||
{ | |||
int x1, y1; | |||
int x2, y2; | |||
char c; | |||
uint32_t c; | |||
void (*draw) (cucul_t *, struct line*); | |||
}; | |||
#endif | |||
@@ -49,17 +49,18 @@ static void draw_thin_line(cucul_t*, struct line*); | |||
* \param y1 Y coordinate of the first point. | |||
* \param x2 X coordinate of the second point. | |||
* \param y2 Y coordinate of the second point. | |||
* \param c Character to draw the line with. | |||
* \param str UTF-8 string containing the character to use to draw the line. | |||
* \return void | |||
*/ | |||
void cucul_draw_line(cucul_t *qq, int x1, int y1, int x2, int y2, char c) | |||
void cucul_draw_line(cucul_t *qq, int x1, int y1, int x2, int y2, | |||
char const *str) | |||
{ | |||
struct line s; | |||
s.x1 = x1; | |||
s.y1 = y1; | |||
s.x2 = x2; | |||
s.y2 = y2; | |||
s.c = c; | |||
s.c = _cucul_utf8_to_utf32(str); | |||
s.draw = draw_solid_line; | |||
clip_line(qq, &s); | |||
} | |||
@@ -73,14 +74,15 @@ void cucul_draw_line(cucul_t *qq, int x1, int y1, int x2, int y2, char c) | |||
* \param x Array of X coordinates. Must have \p n + 1 elements. | |||
* \param y Array of Y coordinates. Must have \p n + 1 elements. | |||
* \param n Number of lines to draw. | |||
* \param c Character to draw the lines with. | |||
* \param str UTF-8 string containing the character to use to draw the lines. | |||
* \return void | |||
*/ | |||
void cucul_draw_polyline(cucul_t *qq, int const x[], int const y[], int n, char c) | |||
void cucul_draw_polyline(cucul_t *qq, int const x[], int const y[], int n, | |||
char const *str) | |||
{ | |||
int i; | |||
struct line s; | |||
s.c = c; | |||
s.c = _cucul_utf8_to_utf32(str); | |||
s.draw = draw_solid_line; | |||
for(i = 0; i < n; i++) | |||
@@ -254,7 +256,7 @@ static void draw_solid_line(cucul_t *qq, struct line* s) | |||
for(; dx>=0; dx--) | |||
{ | |||
cucul_putchar(qq, x1, y1, s->c); | |||
_cucul_putchar32(qq, x1, y1, s->c); | |||
if(delta > 0) | |||
{ | |||
x1 += xinc; | |||
@@ -276,7 +278,7 @@ static void draw_solid_line(cucul_t *qq, struct line* s) | |||
for(; dy >= 0; dy--) | |||
{ | |||
cucul_putchar(qq, x1, y1, s->c); | |||
_cucul_putchar32(qq, x1, y1, s->c); | |||
if(delta > 0) | |||
{ | |||
x1 += xinc; | |||
@@ -301,25 +303,21 @@ static void draw_solid_line(cucul_t *qq, struct line* s) | |||
*/ | |||
static void draw_thin_line(cucul_t *qq, struct line* s) | |||
{ | |||
char *charmapx, *charmapy; | |||
uint32_t charmapx[2], charmapy[2]; | |||
int x1, y1, x2, y2; | |||
int dx, dy; | |||
int yinc; | |||
if(s->x2 >= s->x1) | |||
{ | |||
if(s->y1 > s->y2) | |||
charmapx = ",'"; | |||
else | |||
charmapx = "`."; | |||
charmapx[0] = (s->y1 > s->y2) ? (uint32_t)',' : (uint32_t)'`'; | |||
charmapx[1] = (s->y1 > s->y2) ? (uint32_t)'\'' : (uint32_t)'.'; | |||
x1 = s->x1; y1 = s->y1; x2 = s->x2; y2 = s->y2; | |||
} | |||
else | |||
{ | |||
if(s->y1 > s->y2) | |||
charmapx = "`."; | |||
else | |||
charmapx = ",'"; | |||
charmapx[0] = (s->y1 > s->y2) ? (uint32_t)'`' : (uint32_t)'.'; | |||
charmapx[1] = (s->y1 > s->y2) ? (uint32_t)',' : (uint32_t)'\''; | |||
x2 = s->x1; y2 = s->y1; x1 = s->x2; y1 = s->y2; | |||
} | |||
@@ -328,13 +326,15 @@ static void draw_thin_line(cucul_t *qq, struct line* s) | |||
if(y1 > y2) | |||
{ | |||
charmapy = ",'"; | |||
charmapy[0] = (uint32_t)','; | |||
charmapy[1] = (uint32_t)'\''; | |||
yinc = -1; | |||
} | |||
else | |||
{ | |||
yinc = 1; | |||
charmapy = "`."; | |||
charmapy[0] = (uint32_t)'`'; | |||
charmapy[1] = (uint32_t)'.'; | |||
} | |||
if(dx >= dy) | |||
@@ -348,7 +348,7 @@ static void draw_thin_line(cucul_t *qq, struct line* s) | |||
{ | |||
if(delta > 0) | |||
{ | |||
cucul_putchar(qq, x1, y1, charmapy[1]); | |||
_cucul_putchar32(qq, x1, y1, charmapy[1]); | |||
x1++; | |||
y1 += yinc; | |||
delta += dpru; | |||
@@ -357,9 +357,9 @@ static void draw_thin_line(cucul_t *qq, struct line* s) | |||
else | |||
{ | |||
if(prev) | |||
cucul_putchar(qq, x1, y1, charmapy[0]); | |||
_cucul_putchar32(qq, x1, y1, charmapy[0]); | |||
else | |||
cucul_putchar(qq, x1, y1, '-'); | |||
_cucul_putchar32(qq, x1, y1, (uint32_t)'-'); | |||
x1++; | |||
delta += dpr; | |||
prev = 0; | |||
@@ -376,15 +376,15 @@ static void draw_thin_line(cucul_t *qq, struct line* s) | |||
{ | |||
if(delta > 0) | |||
{ | |||
cucul_putchar(qq, x1, y1, charmapx[0]); | |||
cucul_putchar(qq, x1 + 1, y1, charmapx[1]); | |||
_cucul_putchar32(qq, x1, y1, charmapx[0]); | |||
_cucul_putchar32(qq, x1 + 1, y1, charmapx[1]); | |||
x1++; | |||
y1 += yinc; | |||
delta += dpru; | |||
} | |||
else | |||
{ | |||
cucul_putchar(qq, x1, y1, '|'); | |||
_cucul_putchar32(qq, x1, y1, (uint32_t)'|'); | |||
y1 += yinc; | |||
delta += dpr; | |||
} | |||
@@ -38,11 +38,12 @@ | |||
* \param c Character to draw the triangle outline with. | |||
* \return void | |||
*/ | |||
void cucul_draw_triangle(cucul_t *qq, int x1, int y1, int x2, int y2, int x3, int y3, char c) | |||
void cucul_draw_triangle(cucul_t *qq, int x1, int y1, int x2, int y2, | |||
int x3, int y3, char const *str) | |||
{ | |||
cucul_draw_line(qq, x1, y1, x2, y2, c); | |||
cucul_draw_line(qq, x2, y2, x3, y3, c); | |||
cucul_draw_line(qq, x3, y3, x1, y1, c); | |||
cucul_draw_line(qq, x1, y1, x2, y2, str); | |||
cucul_draw_line(qq, x2, y2, x3, y3, str); | |||
cucul_draw_line(qq, x3, y3, x1, y1, str); | |||
} | |||
/** | |||
@@ -56,7 +57,8 @@ void cucul_draw_triangle(cucul_t *qq, int x1, int y1, int x2, int y2, int x3, in | |||
* \param y3 Y coordinate of the third point. | |||
* \return void | |||
*/ | |||
void cucul_draw_thin_triangle(cucul_t *qq, int x1, int y1, int x2, int y2, int x3, int y3) | |||
void cucul_draw_thin_triangle(cucul_t *qq, int x1, int y1, int x2, int y2, | |||
int x3, int y3) | |||
{ | |||
cucul_draw_thin_line(qq, x1, y1, x2, y2); | |||
cucul_draw_thin_line(qq, x2, y2, x3, y3); | |||
@@ -75,20 +77,22 @@ void cucul_draw_thin_triangle(cucul_t *qq, int x1, int y1, int x2, int y2, int x | |||
* \param c Character to fill the triangle with. | |||
* \return void | |||
*/ | |||
void cucul_fill_triangle(cucul_t *qq, int x1, int y1, int x2, int y2, int x3, int y3, char c) | |||
void cucul_fill_triangle(cucul_t *qq, int x1, int y1, int x2, int y2, | |||
int x3, int y3, char const *str) | |||
{ | |||
int x, y, xa, xb, xmax, ymax; | |||
uint32_t c; | |||
/* Bubble-sort y1 <= y2 <= y3 */ | |||
if(y1 > y2) | |||
{ | |||
cucul_fill_triangle(qq, x2, y2, x1, y1, x3, y3, c); | |||
cucul_fill_triangle(qq, x2, y2, x1, y1, x3, y3, str); | |||
return; | |||
} | |||
if(y2 > y3) | |||
{ | |||
cucul_fill_triangle(qq, x1, y1, x3, y3, x2, y2, c); | |||
cucul_fill_triangle(qq, x1, y1, x3, y3, x2, y2, str); | |||
return; | |||
} | |||
@@ -100,6 +104,8 @@ void cucul_fill_triangle(cucul_t *qq, int x1, int y1, int x2, int y2, int x3, in | |||
xmax = qq->width - 1; | |||
ymax = qq->height - 1; | |||
c = _cucul_utf8_to_utf32(str); | |||
/* Rasterize our triangle */ | |||
for(y = y1 < 0 ? 0 : y1; y <= y3 && y <= ymax; y++) | |||
{ | |||
@@ -130,7 +136,7 @@ void cucul_fill_triangle(cucul_t *qq, int x1, int y1, int x2, int y2, int x3, in | |||
if(xb > xmax) xb = xmax; | |||
for(x = xa; x <= xb; x++) | |||
cucul_putchar(qq, x, y, c); | |||
_cucul_putchar32(qq, x, y, c); | |||
} | |||
} | |||
@@ -429,8 +429,8 @@ int main(int argc, char **argv) | |||
static void print_status(void) | |||
{ | |||
cucul_set_color(qq, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLUE); | |||
cucul_draw_line(qq, 0, 0, ww - 1, 0, ' '); | |||
cucul_draw_line(qq, 0, wh - 2, ww - 1, wh - 2, '-'); | |||
cucul_draw_line(qq, 0, 0, ww - 1, 0, " "); | |||
cucul_draw_line(qq, 0, wh - 2, ww - 1, wh - 2, "-"); | |||
cucul_putstr(qq, 0, 0, "q:Quit np:Next/Prev +-x:Zoom gG:Gamma " | |||
"hjkl:Move d:Dither a:Antialias"); | |||
cucul_putstr(qq, ww - strlen("?:Help"), 0, "?:Help"); | |||
@@ -439,7 +439,7 @@ static void print_status(void) | |||
cucul_printf(qq, ww - 14, wh - 2, "(zoom: %s%i)", zoom > 0 ? "+" : "", zoom); | |||
cucul_set_color(qq, CUCUL_COLOR_LIGHTGRAY, CUCUL_COLOR_BLACK); | |||
cucul_draw_line(qq, 0, wh - 1, ww - 1, wh - 1, ' '); | |||
cucul_draw_line(qq, 0, wh - 1, ww - 1, wh - 1, " "); | |||
} | |||
static void print_help(int x, int y) | |||
@@ -241,9 +241,9 @@ static void demo_all(void) | |||
j = 15 + sin(0.03*i) * 8; | |||
cucul_set_color(qq, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLACK); | |||
cucul_fill_ellipse(qq, xo, yo, j, j / 2, '#'); | |||
cucul_fill_ellipse(qq, xo, yo, j, j / 2, "#"); | |||
cucul_set_color(qq, CUCUL_COLOR_YELLOW, CUCUL_COLOR_BLACK); | |||
cucul_draw_ellipse(qq, xo, yo, j, j / 2, '#'); | |||
cucul_draw_ellipse(qq, xo, yo, j, j / 2, "#"); | |||
/* Draw the pyramid */ | |||
xo = cucul_get_width(qq) * 5 / 8; | |||
@@ -259,17 +259,17 @@ static void demo_all(void) | |||
yc = cucul_get_height(qq) * 3 / 4 + cos(0.02*i) * 5; | |||
cucul_set_color(qq, CUCUL_COLOR_GREEN, CUCUL_COLOR_BLACK); | |||
cucul_fill_triangle(qq, xo, yo, xb, yb, xa, ya, '%'); | |||
cucul_fill_triangle(qq, xo, yo, xb, yb, xa, ya, "%"); | |||
cucul_set_color(qq, CUCUL_COLOR_YELLOW, CUCUL_COLOR_BLACK); | |||
cucul_draw_thin_triangle(qq, xo, yo, xb, yb, xa, ya); | |||
cucul_set_color(qq, CUCUL_COLOR_RED, CUCUL_COLOR_BLACK); | |||
cucul_fill_triangle(qq, xa, ya, xb, yb, xc, yc, '#'); | |||
cucul_fill_triangle(qq, xa, ya, xb, yb, xc, yc, "#"); | |||
cucul_set_color(qq, CUCUL_COLOR_YELLOW, CUCUL_COLOR_BLACK); | |||
cucul_draw_thin_triangle(qq, xa, ya, xb, yb, xc, yc); | |||
cucul_set_color(qq, CUCUL_COLOR_BLUE, CUCUL_COLOR_BLACK); | |||
cucul_fill_triangle(qq, xo, yo, xb, yb, xc, yc, '%'); | |||
cucul_fill_triangle(qq, xo, yo, xb, yb, xc, yc, "%"); | |||
cucul_set_color(qq, CUCUL_COLOR_YELLOW, CUCUL_COLOR_BLACK); | |||
cucul_draw_thin_triangle(qq, xo, yo, xb, yb, xc, yc); | |||
@@ -373,7 +373,7 @@ static void demo_lines(void) | |||
if(outline > 1) | |||
cucul_draw_thin_line(qq, xa, ya, xb, yb); | |||
else | |||
cucul_draw_line(qq, xa, ya, xb, yb, '#'); | |||
cucul_draw_line(qq, xa, ya, xb, yb, "#"); | |||
} | |||
static void demo_boxes(void) | |||
@@ -394,13 +394,13 @@ static void demo_boxes(void) | |||
} | |||
cucul_set_color(qq, cucul_rand(0, 15), cucul_rand(0, 15)); | |||
cucul_fill_box(qq, xa, ya, xb, yb, '#'); | |||
cucul_fill_box(qq, xa, ya, xb, yb, "#"); | |||
cucul_set_color(qq, cucul_rand(0, 15), CUCUL_COLOR_BLACK); | |||
if(outline == 2) | |||
cucul_draw_thin_box(qq, xa, ya, xb, yb); | |||
else if(outline == 1) | |||
cucul_draw_box(qq, xa, ya, xb, yb, '#'); | |||
cucul_draw_box(qq, xa, ya, xb, yb, "#"); | |||
} | |||
static void demo_ellipses(void) | |||
@@ -425,13 +425,13 @@ static void demo_ellipses(void) | |||
} | |||
cucul_set_color(qq, cucul_rand(0, 15), cucul_rand(0, 15)); | |||
cucul_fill_ellipse(qq, x, y, a, b, '#'); | |||
cucul_fill_ellipse(qq, x, y, a, b, "#"); | |||
cucul_set_color(qq, cucul_rand(0, 15), CUCUL_COLOR_BLACK); | |||
if(outline == 2) | |||
cucul_draw_thin_ellipse(qq, x, y, a, b); | |||
else if(outline == 1) | |||
cucul_draw_ellipse(qq, x, y, a, b, '#'); | |||
cucul_draw_ellipse(qq, x, y, a, b, "#"); | |||
} | |||
static void demo_triangles(void) | |||
@@ -455,13 +455,13 @@ static void demo_triangles(void) | |||
} | |||
cucul_set_color(qq, cucul_rand(0, 15), cucul_rand(0, 15)); | |||
cucul_fill_triangle(qq, xa, ya, xb, yb, xc, yc, '#'); | |||
cucul_fill_triangle(qq, xa, ya, xb, yb, xc, yc, "#"); | |||
cucul_set_color(qq, cucul_rand(0, 15), CUCUL_COLOR_BLACK); | |||
if(outline == 2) | |||
cucul_draw_thin_triangle(qq, xa, ya, xb, yb, xc, yc); | |||
else if(outline == 1) | |||
cucul_draw_triangle(qq, xa, ya, xb, yb, xc, yc, '#'); | |||
cucul_draw_triangle(qq, xa, ya, xb, yb, xc, yc, "#"); | |||
} | |||
static void demo_sprites(void) | |||
@@ -40,9 +40,9 @@ int main(int argc, char **argv) | |||
h = cucul_get_height(qq) - 1; | |||
cucul_set_color(qq, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLUE); | |||
cucul_draw_line(qq, 0, 0, cucul_get_width(qq) - 1, 0, ' '); | |||
cucul_draw_line(qq, 0, 0, cucul_get_width(qq) - 1, 0, " "); | |||
cucul_draw_line(qq, 0, h, cucul_get_width(qq) - 1, h, ' '); | |||
cucul_draw_line(qq, 0, h, cucul_get_width(qq) - 1, h, " "); | |||
cucul_putstr(qq, 0, h, "type \"quit\" to exit"); | |||
caca_display(kk); | |||
@@ -84,10 +84,10 @@ int main(int argc, char **argv) | |||
/* Print current event */ | |||
cucul_set_color(qq, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLUE); | |||
cucul_draw_line(qq, 0, 0, cucul_get_width(qq) - 1, 0, ' '); | |||
cucul_draw_line(qq, 0, 0, cucul_get_width(qq) - 1, 0, " "); | |||
print_event(0, 0, events[0]); | |||
cucul_draw_line(qq, 0, h, cucul_get_width(qq) - 1, h, ' '); | |||
cucul_draw_line(qq, 0, h, cucul_get_width(qq) - 1, h, " "); | |||
cucul_printf(qq, 0, h, "type \"quit\" to exit: %s", quit_string[quit]); | |||
/* Print previous events */ | |||
@@ -91,7 +91,7 @@ int main(int argc, char *argv[]) | |||
cucul_draw_thin_box(qq, 0, 0, WIDTH - 1, HEIGHT - 1); | |||
cucul_set_color(qq, CUCUL_COLOR_BLACK, CUCUL_COLOR_WHITE); | |||
cucul_fill_ellipse(qq, WIDTH / 2, HEIGHT / 2, WIDTH / 4, HEIGHT / 4, ' '); | |||
cucul_fill_ellipse(qq, WIDTH / 2, HEIGHT / 2, WIDTH / 4, HEIGHT / 4, " "); | |||
cucul_putstr(qq, WIDTH / 2 - 5, HEIGHT / 2 - 2, "(\") \\o/ <&>"); | |||
cucul_putstr(qq, WIDTH / 2 - 7, HEIGHT / 2 + 2, "äβç ░▒▓█▓▒░ ΔЗҒ"); | |||
@@ -100,7 +100,7 @@ int main(int argc, char **argv) | |||
xb = xa + 1 + cucul_get_sprite_width(qq, sprite, frame); | |||
yb = ya + 1 + cucul_get_sprite_height(qq, sprite, frame); | |||
cucul_set_color(qq, CUCUL_COLOR_BLACK, CUCUL_COLOR_BLACK); | |||
cucul_fill_box(qq, 57 + xa, 10 + ya, 57 + xb, 10 + yb, ' '); | |||
cucul_fill_box(qq, 57 + xa, 10 + ya, 57 + xb, 10 + yb, " "); | |||
cucul_set_color(qq, CUCUL_COLOR_LIGHTGRAY, CUCUL_COLOR_BLACK); | |||
cucul_draw_thin_box(qq, 57 + xa, 10 + ya, 57 + xb, 10 + yb); | |||
cucul_draw_sprite(qq, 57, 10, sprite, frame); | |||