diff --git a/cucul/cucul.h b/cucul/cucul.h index ff334f8..6f93dce 100644 --- a/cucul/cucul.h +++ b/cucul/cucul.h @@ -151,6 +151,7 @@ void cucul_blit(cucul_t *, int, int, cucul_t const *, cucul_t const *); * These functions perform horizontal and vertical canvas flipping. * * @{ */ +void cucul_invert(cucul_t *); void cucul_flip(cucul_t *); void cucul_flop(cucul_t *); void cucul_rotate(cucul_t *); diff --git a/cucul/transform.c b/cucul/transform.c index 6f71a7c..2e362e3 100644 --- a/cucul/transform.c +++ b/cucul/transform.c @@ -29,6 +29,25 @@ static uint32_t flipchar(uint32_t ch); static uint32_t flopchar(uint32_t ch); static uint32_t rotatechar(uint32_t ch); +/** \brief Invert a canvas' colours. + * + * This function inverts a canvas' colours (black becomes white, red + * becomes cyan, etc.) without changing the characters in it. + * + * \param qq The canvas to invert. + */ +void cucul_invert(cucul_t *qq) +{ + uint8_t *attr = qq->attr; + unsigned int i; + + for(i = qq->height * qq->width; i--; ) + { + *attr = ~*attr; + attr++; + } +} + /** \brief Flip a canvas horizontally. * * This function flips a canvas horizontally, choosing characters that