add comments for ncpixel functions

This commit is contained in:
joseLuís 2020-08-11 16:59:39 +02:00
parent dbec390fac
commit 7abda11404

View File

@ -2361,6 +2361,8 @@ API int ncblit_bgrx(const void* data, int linesize,
// The ncpixel API facilitates direct management of the pixels within an
// ncvisual (ncvisuals keep a backing store of 32-bit RGBA pixels, and render
// them down to terminal graphics in ncvisual_render()).
// Extract the 8-bit alpha component from a pixel
static inline uint32_t
ncpixel(int r, int g, int b){
if(r < 0) r = 0;
@ -2372,26 +2374,31 @@ ncpixel(int r, int g, int b){
return 0xff000000ul | r | (b << 8u) | (g << 16u);
}
// Extract the 8-bit alpha component from a pixel
static inline unsigned
ncpixel_a(uint32_t pixel){
return (pixel & 0xff0000fful) >> 24u;
}
// Extract the 8 bit red component from a pixel
static inline unsigned
ncpixel_r(uint32_t pixel){
return (pixel & 0x000000fful);
}
// Extract the 8 bit green component from a pixel
static inline int
ncpixel_g(uint32_t pixel){
return (pixel & 0x00ff0000ul) >> 16u;
}
// Extract the 8 bit blue component from a pixel
static inline int
ncpixel_b(uint32_t pixel){
return (pixel & 0x0000ff00ul) >> 8u;
}
// Set the 8-bit alpha component of a pixel
static inline int
ncpixel_set_a(uint32_t* pixel, int a){
if(a > 255 || a < 0){
@ -2401,6 +2408,7 @@ ncpixel_set_a(uint32_t* pixel, int a){
return 0;
}
// Set the 8-bit red component of a pixel
static inline int
ncpixel_set_r(uint32_t* pixel, int r){
if(r > 255 || r < 0){
@ -2410,6 +2418,7 @@ ncpixel_set_r(uint32_t* pixel, int r){
return 0;
}
// Set the 8-bit green component of a pixel
static inline int
ncpixel_set_g(uint32_t* pixel, int g){
if(g > 255 || g < 0){
@ -2419,6 +2428,7 @@ ncpixel_set_g(uint32_t* pixel, int g){
return 0;
}
// Set the 8-bit blue component of a pixel
static inline int
ncpixel_set_b(uint32_t* pixel, int b){
if(b > 255 || b < 0){