color: formatting code using astyle

Origin commit data
------------------
Branch: ni/coolstream
Commit: 6eaac512fb
Author: vanhofen <vanhofen@gmx.de>
Date: 2021-11-19 (Fri, 19 Nov 2021)

Origin message was:
------------------
- color: formatting code using astyle

------------------
No further description and justification available within origin commit message!

------------------
This commit was generated by Migit
This commit is contained in:
vanhofen
2021-11-19 21:51:01 +01:00
parent 61700d8d8c
commit 7e25b366e1
3 changed files with 114 additions and 90 deletions

View File

@@ -55,8 +55,10 @@ int convertSetupColor2RGB(const unsigned char r, const unsigned char g, const un
int convertSetupAlpha2Alpha(unsigned char alpha) int convertSetupAlpha2Alpha(unsigned char alpha)
{ {
if(alpha == 0) return 0xFF; if (alpha == 0)
else if(alpha >= 100) return 0; return 0xFF;
else if (alpha >= 100)
return 0;
int a = 100 - alpha; int a = 100 - alpha;
int ret = a * 0xFF / 100; int ret = a * 0xFF / 100;
return ret; return ret;
@@ -110,8 +112,10 @@ fb_pixel_t changeBrightnessRGBRel(fb_pixel_t color, int br, bool transp)
{ {
int br_ = (int)getBrightnessRGB(color); int br_ = (int)getBrightnessRGB(color);
br_ += br; br_ += br;
if (br_ < 0) br_ = 0; if (br_ < 0)
if (br_ > 255) br_ = 255; br_ = 0;
if (br_ > 255)
br_ = 255;
return changeBrightnessRGB(color, (uint8_t)br_, transp); return changeBrightnessRGB(color, (uint8_t)br_, transp);
} }
@@ -152,17 +156,21 @@ void Hsv2Rgb(HsvColor *hsv, RgbColor *rgb)
float f_H = hsv->h; float f_H = hsv->h;
float f_S = hsv->s; float f_S = hsv->s;
float f_V = hsv->v; float f_V = hsv->v;
if (fabsf(f_S) < FLT_EPSILON) { if (fabsf(f_S) < FLT_EPSILON)
{
rgb->r = (uint8_t)(f_V * 255); rgb->r = (uint8_t)(f_V * 255);
rgb->g = (uint8_t)(f_V * 255); rgb->g = (uint8_t)(f_V * 255);
rgb->b = (uint8_t)(f_V * 255); rgb->b = (uint8_t)(f_V * 255);
} else { }
else
{
float f_R; float f_R;
float f_G; float f_G;
float f_B; float f_B;
float hh = f_H; float hh = f_H;
if (hh >= 360) hh = 0; if (hh >= 360)
hh = 0;
hh /= 60; hh /= 60;
int i = (int)hh; int i = (int)hh;
float ff = hh - (float)i; float ff = hh - (float)i;
@@ -170,7 +178,8 @@ void Hsv2Rgb(HsvColor *hsv, RgbColor *rgb)
float q = f_V * (1 - (f_S * ff)); float q = f_V * (1 - (f_S * ff));
float t = f_V * (1 - (f_S * (1 - ff))); float t = f_V * (1 - (f_S * (1 - ff)));
switch (i) { switch (i)
{
case 0: case 0:
f_R = f_V; f_G = t; f_B = p; f_R = f_V; f_G = t; f_B = p;
break; break;
@@ -211,10 +220,13 @@ void Rgb2Hsv(RgbColor *rgb, HsvColor *hsv)
float f_H = 0; float f_H = 0;
float f_S = 0; float f_S = 0;
if (fabsf(delta) < FLT_EPSILON) { //gray if (fabsf(delta) < FLT_EPSILON) //gray
{
f_S = 0; f_S = 0;
f_H = 0; f_H = 0;
} else { }
else
{
f_S = (delta / max); f_S = (delta / max);
if (f_R >= max) if (f_R >= max)
f_H = (f_G - f_B) / delta; f_H = (f_G - f_B) / delta;

View File

@@ -53,6 +53,7 @@
#define COL_BACKGROUND 255 #define COL_BACKGROUND 255
#ifdef FB_USE_PALETTE #ifdef FB_USE_PALETTE
#define COL_SHADOW_PLUS_0 (COL_SHADOW + 0) #define COL_SHADOW_PLUS_0 (COL_SHADOW + 0)
#define COL_INFOBAR_PLUS_0 (COL_INFOBAR + 0) #define COL_INFOBAR_PLUS_0 (COL_INFOBAR + 0)
#define COL_INFOBAR_PLUS_1 (COL_INFOBAR + 1) #define COL_INFOBAR_PLUS_1 (COL_INFOBAR + 1)
@@ -77,7 +78,9 @@
#define COL_MENUFOOT_PLUS_0 (COL_MENUFOOT + 0) #define COL_MENUFOOT_PLUS_0 (COL_MENUFOOT + 0)
#define COL_BACKGROUND_PLUS_0 (COL_BACKGROUND + 0) #define COL_BACKGROUND_PLUS_0 (COL_BACKGROUND + 0)
#define COL_PROGRESSBAR_PASSIVE_PLUS_0 (COL_PROGRESSBAR + 0) #define COL_PROGRESSBAR_PASSIVE_PLUS_0 (COL_PROGRESSBAR + 0)
#else #else
#define COL_SHADOW_PLUS_0 (CFrameBuffer::getInstance()->realcolor[(COL_SHADOW + 0)]) #define COL_SHADOW_PLUS_0 (CFrameBuffer::getInstance()->realcolor[(COL_SHADOW + 0)])
#define COL_INFOBAR_PLUS_0 (CFrameBuffer::getInstance()->realcolor[(COL_INFOBAR + 0)]) #define COL_INFOBAR_PLUS_0 (CFrameBuffer::getInstance()->realcolor[(COL_INFOBAR + 0)])
#define COL_INFOBAR_PLUS_1 (CFrameBuffer::getInstance()->realcolor[(COL_INFOBAR + 1)]) #define COL_INFOBAR_PLUS_1 (CFrameBuffer::getInstance()->realcolor[(COL_INFOBAR + 1)])
@@ -121,7 +124,8 @@
#define COL_MENUCONTENTINACTIVE_TEXT (CFrameBuffer::getInstance()->realcolor[(COL_NEUTRINO_TEXT + 14)]) #define COL_MENUCONTENTINACTIVE_TEXT (CFrameBuffer::getInstance()->realcolor[(COL_NEUTRINO_TEXT + 14)])
#define COL_INFOCLOCK_TEXT (CFrameBuffer::getInstance()->realcolor[(COL_NEUTRINO_TEXT + 15)]) #define COL_INFOCLOCK_TEXT (CFrameBuffer::getInstance()->realcolor[(COL_NEUTRINO_TEXT + 15)])
#define COL_PROGRESSBAR_ACTIVE_PLUS_0 (CFrameBuffer::getInstance()->realcolor[(COL_NEUTRINO_TEXT + 16)]) #define COL_PROGRESSBAR_ACTIVE_PLUS_0 (CFrameBuffer::getInstance()->realcolor[(COL_NEUTRINO_TEXT + 16)])
#endif
#endif // FB_USE_PALETTE
// some wrappers to get more readability // some wrappers to get more readability
#define COL_FRAME COL_MENUCONTENT_PLUS_1 //NI #define COL_FRAME COL_MENUCONTENT_PLUS_1 //NI
@@ -146,13 +150,15 @@ int convertSetupAlpha2Alpha(unsigned char alpha);
void fadeColor(unsigned char &r, unsigned char &g, unsigned char &b, int fade, bool protect = true); void fadeColor(unsigned char &r, unsigned char &g, unsigned char &b, int fade, bool protect = true);
typedef struct { typedef struct
{
uint8_t r; uint8_t r;
uint8_t g; uint8_t g;
uint8_t b; uint8_t b;
} RgbColor; } RgbColor;
typedef struct { typedef struct
{
float h; float h;
float s; float s;
float v; float v;
@@ -172,7 +178,8 @@ void Rgb2Hsv(RgbColor *rgb, HsvColor *hsv);
void getItemColors(fb_pixel_t &t, fb_pixel_t &b, bool selected = false, bool marked = false, bool toggle_background = false, bool toggle_enlighten = false); void getItemColors(fb_pixel_t &t, fb_pixel_t &b, bool selected = false, bool marked = false, bool toggle_background = false, bool toggle_enlighten = false);
typedef struct { typedef struct
{
uint8_t min; uint8_t min;
uint8_t max; uint8_t max;
} col_range_t; } col_range_t;

View File

@@ -2,7 +2,9 @@
#define __color_custom__ #define __color_custom__
#define COLOR_CUSTOM 0x0 #define COLOR_CUSTOM 0x0
#ifdef FB_USE_PALETTE #ifdef FB_USE_PALETTE
/* /*
#define COL_WHITE (COLOR_CUSTOM + 0) #define COL_WHITE (COLOR_CUSTOM + 0)
#define COL_RED (COLOR_CUSTOM + 1) #define COL_RED (COLOR_CUSTOM + 1)
@@ -25,7 +27,9 @@
#define COL_LIGHT_BLUE 0x0F #define COL_LIGHT_BLUE 0x0F
#define COL_WHITE 0x10 #define COL_WHITE 0x10
#define COL_BLACK 0x11 #define COL_BLACK 0x11
#else #else
#define COL_DARK_RED0 0x02 #define COL_DARK_RED0 0x02
#define COL_DARK_GREEN0 0x03 #define COL_DARK_GREEN0 0x03
#define COL_OLIVE0 0x04 #define COL_OLIVE0 0x04
@@ -55,7 +59,8 @@
#define COL_LIGHT_BLUE (CFrameBuffer::getInstance()->realcolor[0x0F]) #define COL_LIGHT_BLUE (CFrameBuffer::getInstance()->realcolor[0x0F])
#define COL_WHITE (CFrameBuffer::getInstance()->realcolor[0x10]) #define COL_WHITE (CFrameBuffer::getInstance()->realcolor[0x10])
#define COL_BLACK (CFrameBuffer::getInstance()->realcolor[0x11]) #define COL_BLACK (CFrameBuffer::getInstance()->realcolor[0x11])
#endif
#endif // FB_USE_PALETTE
#define COL_RANDOM (getRandomColor()) #define COL_RANDOM (getRandomColor())