[Bf-blender-cvs] [57573df0d3] blender2.8: Add GetThemeColorBlendShade3ubv function

Luca Rood noreply at git.blender.org
Thu Feb 2 00:08:50 CET 2017


Commit: 57573df0d3c45629080996704fa8d32b458dcfa5
Author: Luca Rood
Date:   Wed Feb 1 20:40:49 2017 -0200
Branches: blender2.8
https://developer.blender.org/rB57573df0d3c45629080996704fa8d32b458dcfa5

Add GetThemeColorBlendShade3ubv function

Differential Revision: https://developer.blender.org/D2484

Used by part of T49043

===================================================================

M	source/blender/editors/include/UI_resources.h
M	source/blender/editors/interface/resources.c

===================================================================

diff --git a/source/blender/editors/include/UI_resources.h b/source/blender/editors/include/UI_resources.h
index b7a5217a86..dbd3d7d993 100644
--- a/source/blender/editors/include/UI_resources.h
+++ b/source/blender/editors/include/UI_resources.h
@@ -348,6 +348,9 @@ void    UI_GetThemeColorBlend3ubv(int colorid1, int colorid2, float fac, unsigne
 void    UI_GetThemeColorShade3fv(int colorid, int offset, float col[3]);
 void    UI_GetThemeColorShade3ubv(int colorid, int offset, unsigned char col[3]);
 
+// get three color values, range 0-255, complete with shading offset for the RGB components and blending
+void	UI_GetThemeColorBlendShade3ubv(int colorid1, int colorid2, float fac, int offset, unsigned char col[3]);
+
 // get four color values, scaled to 0.0-1.0 range
 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
diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c
index 999556025d..38df7620ed 100644
--- a/source/blender/editors/interface/resources.c
+++ b/source/blender/editors/interface/resources.c
@@ -1491,6 +1491,23 @@ void UI_GetThemeColorShade3ubv(int colorid, int offset, unsigned char col[3])
 	col[2] = b;
 }
 
+void UI_GetThemeColorBlendShade3ubv(int colorid1, int colorid2, float fac, int offset, unsigned char col[3])
+{
+	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);
+	col[0] = offset + floorf((1.0f - fac) * cp1[0] + fac * cp2[0]);
+	col[1] = offset + floorf((1.0f - fac) * cp1[1] + fac * cp2[1]);
+	col[2] = offset + floorf((1.0f - fac) * cp1[2] + fac * cp2[2]);
+
+	CLAMP(col[0], 0, 255);
+	CLAMP(col[1], 0, 255);
+	CLAMP(col[2], 0, 255);
+}
+
 void UI_GetThemeColorShadeAlpha4fv(int colorid, int coloffset, int alphaoffset, float col[4])
 {
 	int r, g, b, a;




More information about the Bf-blender-cvs mailing list