diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-06-21 23:45:36 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-06-21 23:45:36 +0400 |
commit | 9b8a97c039d88104e438f372c13d5d64b222347d (patch) | |
tree | 5988c407aaa503f92daae1d9d4450a71ce380bfe /source | |
parent | 40f974d15f544639af0b7f056bb8e6966119c221 (diff) |
hue color display still was shifted, turned out the resolution was a bit too low.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/interface/interface_intern.h | 2 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_widgets.c | 13 |
2 files changed, 10 insertions, 5 deletions
diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index 9af3ff3bdd8..1f88db033a4 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -447,7 +447,7 @@ extern void ui_draw_aligned_panel(struct uiStyle *style, uiBlock *block, rcti *r /* 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); diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index 464298fa57e..07b1217b1bd 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -1946,8 +1946,9 @@ static void ui_draw_but_HSVCIRCLE(uiBut *but, uiWidgetColors *wcol, rcti *rect) /* ************ 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 @@ void ui_draw_gradient(rcti *rect, const float hsv[3], int type, float alpha) /* 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 @@ void ui_draw_gradient(rcti *rect, const float hsv[3], int type, float alpha) 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 @@ void ui_draw_gradient(rcti *rect, const float hsv[3], int type, float alpha) // 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; |