rework last commit

Origin commit data
------------------
Branch: ni/coolstream
Commit: 6804630061
Author: TangoCash <eric@loxat.de>
Date: 2021-11-04 (Thu, 04 Nov 2021)


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

------------------
This commit was generated by Migit
This commit is contained in:
TangoCash
2021-11-04 19:37:35 +01:00
committed by vanhofen
parent dbdd14aa2f
commit a0878d60bc

View File

@@ -1389,7 +1389,7 @@ static unsigned int nsvg__parseColorRGB(const char* str)
return NSVG_RGB(r, g, b);
if (sscanf(str, "rgb(%u%%, %u%%, %u%%)", &r, &g, &b) == 3) // decimal integer percentage
{
r = (r <= 100) ? ((r*255)/100) : 255; // FLTK: clip percentages >100
r = (r <= 100) ? ((r*255)/100) : 255;
g = (g <= 100) ? ((g*255)/100) : 255;
b = (b <= 100) ? ((b*255)/100) : 255;
return NSVG_RGB(r, g, b);
@@ -1399,26 +1399,25 @@ static unsigned int nsvg__parseColorRGB(const char* str)
static unsigned int nsvg__parseColorRGBA(const char* str)
{
int r = -1, g = -1, b = -1;
float a = -1;
char s1[32]="", s2[32]="", s3[32]="";
sscanf(str + 5, "%d%[%%, \t]%d%[%%, \t]%d%[%%, \t]%f", &r, s1, &g, s2, &b, s3, &a);
if (strchr(s1, '%'))
int r = 0, g = 0, b = 0;
float a = 1.0;
if (sscanf(str, "rgba(%u, %u, %u, %f)", &r, &g, &b, &a) == 4) // decimal integers with alpha
{
r = (r <= 100) ? ((r*255)/100) : 255; // FLTK: clip percentages >100
g = (g <= 100) ? ((g*255)/100) : 255;
b = (b <= 100) ? ((b*255)/100) : 255;
a = (a <= 100) ? ((a*255)/100) : 255;
return NSVG_RGBA(r,g,b,a);
}
else
{
r = (r <= 255) ? r : 255; // FLTK: clip percentages >100
r = (r <= 255) ? r : 255;
g = (g <= 255) ? g : 255;
b = (b <= 255) ? b : 255;
a = (a <= 1.0) ? a*255 : 255;
return NSVG_RGBA(r,g,b,a);
return NSVG_RGBA(r, g, b, a);
}
if (sscanf(str, "rgba(%u%%, %u%%, %u%%, %f)", &r, &g, &b, &a) == 4) // decimal integer percentage with alpha
{
r = (r <= 100) ? ((r*255)/100) : 255;
g = (g <= 100) ? ((g*255)/100) : 255;
b = (b <= 100) ? ((b*255)/100) : 255;
a = (a <= 100) ? ((a*255)/100) : 255;
return NSVG_RGBA(r, g, b, a);
}
return NSVG_RGBA(128, 128, 128, 255);
}
typedef struct NSVGNamedColor