cf_sub_un8¶
Category: graphics
GitHub: cute_color.h
Returns the 8-bit unsigned subtraction of two input 8-bit numbers, intended for implementing 8-bit color blend operations.
uint8_t cf_sub_un8(int a, int b) { int t = a - b; if (t < 0) t = 0; return (uint8_t)(t | (t >> 8)); }
| Parameters | Description |
|---|---|
a |
An 8-bit value promoted to an int upon calling. |
b |
An 8-bit value promoted to an int upon calling. |
Remarks¶
This is a helper-function intended for advanced users. The core calculation is done with full integers to help avoid intermediate overflows on 8-bit values.