Mercurial > molko
changeset 563:4e6d3b00f514
core: doxygenize color
author | David Demelier <markand@malikania.fr> |
---|---|
date | Wed, 08 Mar 2023 19:57:23 +0100 |
parents | 07e3989609fd |
children | e91f37da2992 |
files | libmlk-core/mlk/core/color.h |
diffstat | 1 files changed, 59 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/libmlk-core/mlk/core/color.h Wed Mar 08 21:06:00 2023 +0100 +++ b/libmlk-core/mlk/core/color.h Wed Mar 08 19:57:23 2023 +0100 @@ -19,11 +19,70 @@ #ifndef MLK_CORE_COLOR_H #define MLK_CORE_COLOR_H +/** + * \file color.h + * \brief Basic color routines + * + * This modules provides conversion from RGBA and hexadecimal colors. + * + * Every function that requires a color will take an `unsigned long` as + * argument whic is expressed as `0xRRGGBBAA`. Sometimes it's however handy to + * get an individual color component to adjust its value and this can be done + * using the convenient macro provided by this module. + * + * Example + * + * ```c + * unsigned long color = 0xaabbccdd; + * unsigned int r = MLK_COLOR_R(color); // 0xaa + * unsigned int g = MLK_COLOR_G(color); // 0xbb + * unsigned int b = MLK_COLOR_B(color); // 0xcc + * unsigned int a = MLK_COLOR_A(color); // 0xdd + * ``` + */ + +/** + * Obtain the red component of the color c. + * + * \param c the color + * \return the red component + */ #define MLK_COLOR_R(c) ((c >> 24) & 0xff) + +/** + * Obtain the green component of the color c. + * + * \param c the color + * \return the green component + */ #define MLK_COLOR_G(c) ((c >> 16) & 0xff) + +/** + * Obtain the blue component of the color c. + * + * \param c the color + * \return the green component + */ #define MLK_COLOR_B(c) ((c >> 8) & 0xff) + +/** + * Obtain the alpha component of the color c. + * + * \param c the color + * \return the alpha component + */ #define MLK_COLOR_A(c) ((c) & 0xff) +/** + * Create a hexadecimal color from individual red, green, blue and alpha color + * components. + * + * \param r the red component + * \param g the green component + * \param b the blue component + * \param a the alpha component + * \return the hexadecimal color + */ #define MLK_COLOR_HEX(r, g, b, a) \ (((r << 24) & 0xff000000) | \ ((g << 16) & 0x00ff0000) | \