[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [48179] trunk/blender/source/blender/ editors/interface: hue color display still was shifted, turned out the resolution was a bit too low.

Campbell Barton ideasman42 at gmail.com
Thu Jun 21 21:45:41 CEST 2012


Revision: 48179
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=48179
Author:   campbellbarton
Date:     2012-06-21 19:45:36 +0000 (Thu, 21 Jun 2012)
Log Message:
-----------
hue color display still was shifted, turned out the resolution was a bit too low.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/interface/interface_intern.h
    trunk/blender/source/blender/editors/interface/interface_widgets.c

Modified: trunk/blender/source/blender/editors/interface/interface_intern.h
===================================================================
--- trunk/blender/source/blender/editors/interface/interface_intern.h	2012-06-21 18:34:56 UTC (rev 48178)
+++ trunk/blender/source/blender/editors/interface/interface_intern.h	2012-06-21 19:45:36 UTC (rev 48179)
@@ -447,7 +447,7 @@
 /* interface_draw.c */
 extern void ui_dropshadow(rctf *rct, float radius, float aspect, float alpha, int select);
 
-void ui_draw_gradient(rcti *rect, const float hsv[3], int type, float alpha);
+void ui_draw_gradient(rcti *rect, const float hsv[3], const int type, const float alpha);
 
 void ui_draw_but_HISTOGRAM(ARegion *ar, uiBut *but, struct uiWidgetColors *wcol, rcti *rect);
 void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, struct uiWidgetColors *wcol, rcti *rect);

Modified: trunk/blender/source/blender/editors/interface/interface_widgets.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface_widgets.c	2012-06-21 18:34:56 UTC (rev 48178)
+++ trunk/blender/source/blender/editors/interface/interface_widgets.c	2012-06-21 19:45:36 UTC (rev 48179)
@@ -1946,8 +1946,9 @@
 /* ************ custom buttons, old stuff ************** */
 
 /* draws in resolution of 20x4 colors */
-void ui_draw_gradient(rcti *rect, const float hsv[3], int type, float alpha)
+void ui_draw_gradient(rcti *rect, const float hsv[3], const int type, const float alpha)
 {
+	const float color_step = (type == UI_GRAD_H) ? 0.02 : 0.05f;
 	int a;
 	float h = hsv[0], s = hsv[1], v = hsv[2];
 	float dx, dy, sx1, sx2, sy;
@@ -2004,7 +2005,7 @@
 	
 	/* old below */
 	
-	for (dx = 0.0f; dx < 1.0f; dx += 0.05f) {
+	for (dx = 0.0f; dx < 1.0f; dx += color_step) {
 		// previous color
 		copy_v3_v3(col0[0], col1[0]);
 		copy_v3_v3(col0[1], col1[1]);
@@ -2032,11 +2033,15 @@
 				hsv_to_rgb(dx, 1.0, v,   &col1[3][0], &col1[3][1], &col1[3][2]);
 				break;
 			case UI_GRAD_H:
-				hsv_to_rgb(dx + 0.05f, 1.0, 1.0,   &col1[0][0], &col1[0][1], &col1[0][2]);
+			{
+				/* annoying but without this the color shifts - could be solved some other way
+				 * - campbell */
+				hsv_to_rgb(dx + color_step, 1.0, 1.0,   &col1[0][0], &col1[0][1], &col1[0][2]);
 				copy_v3_v3(col1[1], col1[0]);
 				copy_v3_v3(col1[2], col1[0]);
 				copy_v3_v3(col1[3], col1[0]);
 				break;
+			}
 			case UI_GRAD_S:
 				hsv_to_rgb(h, dx, 1.0,   &col1[1][0], &col1[1][1], &col1[1][2]);
 				copy_v3_v3(col1[0], col1[1]);
@@ -2053,7 +2058,7 @@
 		
 		// rect
 		sx1 = rect->xmin + dx * (rect->xmax - rect->xmin);
-		sx2 = rect->xmin + (dx + 0.05f) * (rect->xmax - rect->xmin);
+		sx2 = rect->xmin + (dx + color_step) * (rect->xmax - rect->xmin);
 		sy = rect->ymin;
 		dy = (rect->ymax - rect->ymin) / 3.0;
 		




More information about the Bf-blender-cvs mailing list