[Bf-blender-cvs] [80b49c15217] blender2.8: UI utils: add helper to get float3 blended color from theme.

Bastien Montagne noreply at git.blender.org
Wed Apr 26 12:00:30 CEST 2017


Commit: 80b49c15217f0f1b37bd195ccec5c59f54d167ab
Author: Bastien Montagne
Date:   Wed Apr 26 11:59:13 2017 +0200
Branches: blender2.8
https://developer.blender.org/rB80b49c15217f0f1b37bd195ccec5c59f54d167ab

UI utils: add helper to get float3 blended color from theme.

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

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 2fc76ae9563..d13d1329721 100644
--- a/source/blender/editors/include/UI_resources.h
+++ b/source/blender/editors/include/UI_resources.h
@@ -344,6 +344,7 @@ int     UI_GetThemeValueType(int colorid, int spacetype);
 // get three color values, scaled to 0.0-1.0 range
 void    UI_GetThemeColor3fv(int colorid, float col[3]);
 void    UI_GetThemeColorBlend3ubv(int colorid1, int colorid2, float fac, unsigned char col[3]);
+void    UI_GetThemeColorBlend3f(int colorid1, int colorid2, float fac, float r_col[3]);
 // get the color, range 0.0-1.0, complete with shading offset
 void    UI_GetThemeColorShade3fv(int colorid, int offset, float col[3]);
 void    UI_GetThemeColorShade3ubv(int colorid, int offset, unsigned char col[3]);
diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c
index 4ec535dc627..412e9d1293e 100644
--- a/source/blender/editors/interface/resources.c
+++ b/source/blender/editors/interface/resources.c
@@ -1336,6 +1336,19 @@ void UI_GetThemeColorBlend3ubv(int colorid1, int colorid2, float fac, unsigned c
 	col[2] = floorf((1.0f - fac) * cp1[2] + fac * cp2[2]);
 }
 
+void UI_GetThemeColorBlend3f(int colorid1, int colorid2, float fac, float r_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);
+	r_col[0] = ((1.0f - fac) * cp1[0] + fac * cp2[0]) / 255.0f;
+	r_col[1] = ((1.0f - fac) * cp1[1] + fac * cp2[1]) / 255.0f;
+	r_col[2] = ((1.0f - fac) * cp1[2] + fac * cp2[2]) / 255.0f;
+}
+
 /* blend between to theme colors, and set it */
 void UI_ThemeColorBlend(int colorid1, int colorid2, float fac)
 {




More information about the Bf-blender-cvs mailing list