more theme color functions: UI_GetThemeColorBlendShade4fv, immUniformThemeColorBlendShade

This commit is contained in:
Dalai Felinto
2016-10-13 20:06:44 +00:00
parent 945f8e3f93
commit 05cf74622f
4 changed files with 36 additions and 1 deletions

View File

@@ -353,6 +353,8 @@ void UI_GetThemeColor4fv(int colorid, float col[4]);
// get four color values, range 0.0-1.0, complete with shading offset for the RGB components
void UI_GetThemeColorShade4fv(int colorid, int offset, float col[4]);
void UI_GetThemeColorShadeAlpha4fv(int colorid, int coloffset, int alphaoffset, float col[4]);
// get four color values, range 0.0-1.0, complete with shading offset for the RGB components and blending
void UI_GetThemeColorBlendShade4fv(int colorid1, int colorid2, float fac, int offset, float col[4]);
// get the 3 or 4 byte values
void UI_GetThemeColor3ubv(int colorid, unsigned char col[3]);

View File

@@ -1488,6 +1488,31 @@ void UI_GetThemeColorShadeAlpha4fv(int colorid, int coloffset, int alphaoffset,
col[3] = ((float)a) / 255.0f;
}
void UI_GetThemeColorBlendShade4fv(int colorid1, int colorid2, float fac, int offset, float col[4])
{
int r, g, b, a;
const unsigned char *cp1, *cp2;
cp1 = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid1);
cp2 = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid2);
CLAMP(fac, 0.0f, 1.0f);
r = offset + floorf((1.0f - fac) * cp1[0] + fac * cp2[0]);
CLAMP(r, 0, 255);
g = offset + floorf((1.0f - fac) * cp1[1] + fac * cp2[1]);
CLAMP(g, 0, 255);
b = offset + floorf((1.0f - fac) * cp1[2] + fac * cp2[2]);
CLAMP(b, 0, 255);
a = offset + floorf((1.0f - fac) * cp1[3] + fac * cp2[3]);
CLAMP(a, 0, 255);
col[0] = ((float)r) / 255.0f;
col[1] = ((float)g) / 255.0f;
col[2] = ((float)b) / 255.0f;
col[3] = ((float)a) / 255.0f;
}
/* get the color, in char pointer */
void UI_GetThemeColor3ubv(int colorid, unsigned char col[3])
{

View File

@@ -43,3 +43,4 @@ void immBindBuiltinProgram(GPUBuiltinShader shader_id);
*/
void immUniformThemeColor(int colorid);
void immUniformThemeColorShade(int colorid, int offset);
void immUniformThemeColorBlendShade(int colorid1, int colorid2, float fac, int offset);

View File

@@ -50,4 +50,11 @@ void immUniformThemeColorShade(int colorid, int offset)
float color[4];
UI_GetThemeColorShade4fv(colorid, offset, color);
immUniformColor4fv(color);
}
}
void immUniformThemeColorBlendShade(int colorid1, int colorid2, float fac, int offset)
{
float color[4];
UI_GetThemeColorBlendShade4fv(colorid1, colorid2, fac, offset, color);
immUniformColor4fv(color);
}