Logo Search packages:      
Sourcecode: libcaca version File versions  Download package

void caca_draw_thin_box ( int  x1,
int  y1,
int  x2,
int  y2 
)

Draw a thin box on the screen.

Parameters:
x1 X coordinate of the upper-left corner of the box.
y1 Y coordinate of the upper-left corner of the box.
x2 X coordinate of the lower-right corner of the box.
y2 Y coordinate of the lower-right corner of the box.
Returns:
void

Definition at line 64 of file box.c.

References caca_putchar().

{
    int x, y, xmax, ymax;

    if(x1 > x2)
    {
        int tmp = x1;
        x1 = x2; x2 = tmp;
    }

    if(y1 > y2)
    {
        int tmp = y1;
        y1 = y2; y2 = tmp;
    }

    xmax = _caca_width - 1;
    ymax = _caca_height - 1;

    if(x2 < 0 || y2 < 0 || x1 > xmax || y1 > ymax)
        return;

    /* Draw edges */
    if(y1 >= 0)
        for(x = x1 < 0 ? 1 : x1 + 1; x < x2 && x < xmax; x++)
            caca_putchar(x, y1, '-');

    if(y2 <= ymax)
        for(x = x1 < 0 ? 1 : x1 + 1; x < x2 && x < xmax; x++)
            caca_putchar(x, y2, '-');

    if(x1 >= 0)
        for(y = y1 < 0 ? 1 : y1 + 1; y < y2 && y < ymax; y++)
            caca_putchar(x1, y, '|');

    if(x2 <= xmax)
        for(y = y1 < 0 ? 1 : y1 + 1; y < y2 && y < ymax; y++)
            caca_putchar(x2, y, '|');

    /* Draw corners */
    if(x1 >= 0 && y1 >= 0)
        caca_putchar(x1, y1, ',');

    if(x1 >= 0 && y2 <= ymax)
        caca_putchar(x1, y2, '`');

    if(x2 <= xmax && y1 >= 0)
        caca_putchar(x2, y1, '.');

    if(x2 <= xmax && y2 <= ymax)
        caca_putchar(x2, y2, '\'');
}


Generated by  Doxygen 1.6.0   Back to index