Changeset 1092


Ignore:
Timestamp:
Sep 23, 2006, 3:28:49 AM (14 years ago)
Author:
Sam Hocevar
Message:
  • Implemented cucul_get_color().
Location:
libcaca/trunk/cucul
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/cucul/colour.c

    r924 r1092  
    109109}
    110110
     111/** \brief Get the colour pair at the given coordinates.
     112 *
     113 *  This function gets the internal \e libcucul colour pair value of the
     114 *  character at the given coordinates. The colour pair value has 32
     115 *  significant bits: the lower 16 are for the foreground colour, the higher
     116 *  16 are for the background.
     117 *
     118 *  If the coordinates are outside the canvas boundaries, the current colour
     119 *  pair is returned.
     120 *
     121 *  This function never fails.
     122 *
     123 *  \param cv A handle to the libcucul canvas.
     124 *  \param x X coordinate.
     125 *  \param y Y coordinate.
     126 *  \param ch The requested colour pair value.
     127 *  \return The character always returns 0.
     128 */
     129unsigned long int cucul_get_color(cucul_canvas_t *cv, int x, int y)
     130{
     131    if(x < 0 || x >= (int)cv->width || y < 0 || y >= (int)cv->height)
     132        return ((uint32_t)cv->bgcolor << 16) | (uint32_t)cv->fgcolor;
     133
     134    return (unsigned long int)cv->attr[x + y * cv->width];
     135}
     136
     137
    111138/*
    112139 * XXX: the following functions are local
  • libcaca/trunk/cucul/cucul.h

    r1079 r1092  
    100100int cucul_set_color(cucul_canvas_t *, unsigned char, unsigned char);
    101101int cucul_set_truecolor(cucul_canvas_t *, unsigned int, unsigned int);
     102unsigned long int cucul_get_color(cucul_canvas_t *, int, int);
    102103char const *cucul_get_color_name(unsigned int);
    103104int cucul_putchar(cucul_canvas_t *, int, int, unsigned long int);
Note: See TracChangeset for help on using the changeset viewer.