1 /** 2 * @file lv_color_op.h 3 * 4 */ 5 6 #ifndef LV_COLOR_OP_H 7 #define LV_COLOR_OP_H 8 9 #ifdef __cplusplus 10 extern "C" { 11 #endif 12 13 /********************* 14 * INCLUDES 15 *********************/ 16 #include "lv_assert.h" 17 #include "lv_math.h" 18 #include "lv_color.h" 19 #include "lv_types.h" 20 21 /********************* 22 * DEFINES 23 *********************/ 24 25 /********************** 26 * TYPEDEFS 27 **********************/ 28 29 struct _lv_color_filter_dsc_t; 30 31 typedef lv_color_t (*lv_color_filter_cb_t)(const struct _lv_color_filter_dsc_t *, lv_color_t, lv_opa_t); 32 33 struct _lv_color_filter_dsc_t { 34 lv_color_filter_cb_t filter_cb; 35 void * user_data; 36 }; 37 38 /********************** 39 * GLOBAL PROTOTYPES 40 **********************/ 41 42 /** 43 * Mix two colors with a given ratio. 44 * @param c1 the first color to mix (usually the foreground) 45 * @param c2 the second color to mix (usually the background) 46 * @param mix The ratio of the colors. 0: full `c2`, 255: full `c1`, 127: half `c1` and half`c2` 47 * @return the mixed color 48 */ 49 lv_color_t LV_ATTRIBUTE_FAST_MEM lv_color_mix(lv_color_t c1, lv_color_t c2, uint8_t mix); 50 51 /** 52 * 53 * @param fg 54 * @param bg 55 * @return 56 * @note Use bg.alpha in the return value 57 * @note Use fg.alpha as mix ratio 58 */ 59 lv_color32_t lv_color_mix32(lv_color32_t fg, lv_color32_t bg); 60 61 /** 62 * Get the brightness of a color 63 * @param c a color 64 * @return brightness in range [0..255] 65 */ 66 uint8_t lv_color_brightness(lv_color_t c); 67 68 void lv_color_filter_dsc_init(lv_color_filter_dsc_t * dsc, lv_color_filter_cb_t cb); 69 70 /********************** 71 * PREDEFINED COLORS 72 **********************/ 73 74 /********************** 75 * MACROS 76 **********************/ 77 78 #ifdef __cplusplus 79 } /*extern "C"*/ 80 #endif 81 82 #endif /*LV_COLOR_H*/ 83