Parcourir la source

* Implemented cucul_get_color().

tags/v0.99.beta14
Sam Hocevar sam il y a 18 ans
Parent
révision
81760312af
2 fichiers modifiés avec 28 ajouts et 0 suppressions
  1. +27
    -0
      cucul/colour.c
  2. +1
    -0
      cucul/cucul.h

+ 27
- 0
cucul/colour.c Voir le fichier

@@ -108,6 +108,33 @@ int cucul_set_truecolor(cucul_canvas_t *cv, unsigned int fg, unsigned int bg)
return 0;
}

/** \brief Get the colour pair at the given coordinates.
*
* This function gets the internal \e libcucul colour pair value of the
* character at the given coordinates. The colour pair value has 32
* significant bits: the lower 16 are for the foreground colour, the higher
* 16 are for the background.
*
* If the coordinates are outside the canvas boundaries, the current colour
* pair is returned.
*
* This function never fails.
*
* \param cv A handle to the libcucul canvas.
* \param x X coordinate.
* \param y Y coordinate.
* \param ch The requested colour pair value.
* \return The character always returns 0.
*/
unsigned long int cucul_get_color(cucul_canvas_t *cv, int x, int y)
{
if(x < 0 || x >= (int)cv->width || y < 0 || y >= (int)cv->height)
return ((uint32_t)cv->bgcolor << 16) | (uint32_t)cv->fgcolor;

return (unsigned long int)cv->attr[x + y * cv->width];
}


/*
* XXX: the following functions are local
*/


+ 1
- 0
cucul/cucul.h Voir le fichier

@@ -99,6 +99,7 @@ int cucul_free_buffer(cucul_buffer_t *);
* @{ */
int cucul_set_color(cucul_canvas_t *, unsigned char, unsigned char);
int cucul_set_truecolor(cucul_canvas_t *, unsigned int, unsigned int);
unsigned long int cucul_get_color(cucul_canvas_t *, int, int);
char const *cucul_get_color_name(unsigned int);
int cucul_putchar(cucul_canvas_t *, int, int, unsigned long int);
unsigned long int cucul_getchar(cucul_canvas_t *, int, int);


Chargement…
Annuler
Enregistrer