Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2012-05-26 15:01:01 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-05-26 15:01:01 +0400
commit63788b47d6e805a97aac1501d3e64e1ada7e40b3 (patch)
tree4a0f33da8af8081ec87cc9846dc83cc39f8b2289 /source/blender/editors/interface
parente727056c2e34857dd5556e66c9858506eb63e987 (diff)
add vector versions of hsv_to_rgb, rgb_to_hsv & rgb_to_hsv_compat
Diffstat (limited to 'source/blender/editors/interface')
-rw-r--r--source/blender/editors/interface/interface.c22
-rw-r--r--source/blender/editors/interface/interface_handlers.c38
-rw-r--r--source/blender/editors/interface/interface_regions.c24
-rw-r--r--source/blender/editors/interface/interface_widgets.c34
4 files changed, 59 insertions, 59 deletions
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index c0cd17d16d2..5394cb46049 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -1437,15 +1437,15 @@ double ui_get_but_val(uiBut *but)
}
}
else if (but->type == HSVSLI) {
- float h, s, v, *fp;
+ float *fp, hsv[3];
fp = (but->editvec) ? but->editvec : (float *)but->poin;
- rgb_to_hsv(fp[0], fp[1], fp[2], &h, &s, &v);
+ rgb_to_hsv_v(fp, hsv);
switch (but->str[0]) {
- case 'H': value = h; break;
- case 'S': value = s; break;
- case 'V': value = v; break;
+ case 'H': value = hsv[0]; break;
+ case 'S': value = hsv[1]; break;
+ case 'V': value = hsv[2]; break;
}
}
else if (but->pointype == CHA) {
@@ -1513,18 +1513,18 @@ void ui_set_but_val(uiBut *but, double value)
}
else if (but->pointype == 0) ;
else if (but->type == HSVSLI) {
- float h, s, v, *fp;
+ float *fp, hsv[3];
fp = (but->editvec) ? but->editvec : (float *)but->poin;
- rgb_to_hsv(fp[0], fp[1], fp[2], &h, &s, &v);
+ rgb_to_hsv_v(fp, hsv);
switch (but->str[0]) {
- case 'H': h = value; break;
- case 'S': s = value; break;
- case 'V': v = value; break;
+ case 'H': hsv[0] = value; break;
+ case 'S': hsv[1] = value; break;
+ case 'V': hsv[2] = value; break;
}
- hsv_to_rgb(h, s, v, fp, fp + 1, fp + 2);
+ hsv_to_rgb_v(hsv, fp);
}
else {
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index 91e6b3d0590..edb0bdc05f5 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -2953,14 +2953,14 @@ static int ui_do_but_BLOCK(bContext *C, uiBut *but, uiHandleButtonData *data, wm
float col[3];
ui_get_but_vectorf(but, col);
- rgb_to_hsv_compat(col[0], col[1], col[2], hsv, hsv + 1, hsv + 2);
+ rgb_to_hsv_compat_v(col, hsv);
if (event->type == WHEELDOWNMOUSE)
hsv[2] = CLAMPIS(hsv[2] - 0.05f, 0.0f, 1.0f);
else
hsv[2] = CLAMPIS(hsv[2] + 0.05f, 0.0f, 1.0f);
- hsv_to_rgb(hsv[0], hsv[1], hsv[2], data->vec, data->vec + 1, data->vec + 2);
+ hsv_to_rgb_v(hsv, data->vec);
ui_set_but_vectorf(but, data->vec);
button_activate_state(C, but, BUTTON_STATE_EXIT);
@@ -3106,7 +3106,7 @@ static int ui_numedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, int mx,
ui_get_but_vectorf(but, rgb);
- rgb_to_hsv_compat(rgb[0], rgb[1], rgb[2], hsv, hsv + 1, hsv + 2);
+ rgb_to_hsv_compat_v(rgb, hsv);
/* relative position within box */
x = ((float)mx - but->x1) / (but->x2 - but->x1);
@@ -3152,7 +3152,7 @@ static int ui_numedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, int mx,
assert(!"invalid hsv type");
}
- hsv_to_rgb(hsv[0], hsv[1], hsv[2], rgb, rgb + 1, rgb + 2);
+ hsv_to_rgb_v(hsv, rgb);
copy_v3_v3(data->vec, rgb);
data->draglastx = mx;
@@ -3175,7 +3175,7 @@ static void ui_ndofedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, wmNDOF
}
ui_get_but_vectorf(but, rgb);
- rgb_to_hsv_compat(rgb[0], rgb[1], rgb[2], hsv, hsv + 1, hsv + 2);
+ rgb_to_hsv_compat_v(rgb, hsv);
switch ((int)but->a1) {
case UI_GRAD_SV:
@@ -3213,7 +3213,7 @@ static void ui_ndofedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, wmNDOF
assert(!"invalid hsv type");
}
- hsv_to_rgb(hsv[0], hsv[1], hsv[2], rgb, rgb + 1, rgb + 2);
+ hsv_to_rgb_v(hsv, rgb);
copy_v3_v3(data->vec, rgb);
ui_set_but_vectorf(but, data->vec);
}
@@ -3265,12 +3265,15 @@ static int ui_do_but_HSVCUBE(bContext *C, uiBlock *block, uiBut *but, uiHandleBu
def = MEM_callocN(sizeof(float) * len, "reset_defaults - float");
RNA_property_float_get_default_array(&but->rnapoin, but->rnaprop, def);
- rgb_to_hsv(def[0], def[1], def[2], def_hsv, def_hsv + 1, def_hsv + 2);
+ rgb_to_hsv_v(def, def_hsv);
ui_get_but_vectorf(but, rgb);
- rgb_to_hsv_compat(rgb[0], rgb[1], rgb[2], hsv, hsv + 1, hsv + 2);
+ rgb_to_hsv_compat_v(rgb, hsv);
+
+ def_hsv[0] = hsv[0];
+ def_hsv[1] = hsv[1];
- hsv_to_rgb(hsv[0], hsv[1], def_hsv[2], rgb, rgb + 1, rgb + 2);
+ hsv_to_rgb_v(def_hsv, rgb);
ui_set_but_vectorf(but, rgb);
RNA_property_update(C, &but->rnapoin, but->rnaprop);
@@ -3314,7 +3317,7 @@ static int ui_numedit_but_HSVCIRCLE(uiBut *but, uiHandleButtonData *data, int mx
ui_get_but_vectorf(but, rgb);
copy_v3_v3(hsv, ui_block_hsv_get(but->block));
- rgb_to_hsv_compat(rgb[0], rgb[1], rgb[2], hsv, hsv + 1, hsv + 2);
+ rgb_to_hsv_compat_v(rgb, hsv);
/* exception, when using color wheel in 'locked' value state:
* allow choosing a hue for black values, by giving a tiny increment */
@@ -3334,7 +3337,7 @@ static int ui_numedit_but_HSVCIRCLE(uiBut *but, uiHandleButtonData *data, int mx
if (but->flag & UI_BUT_COLOR_CUBIC)
hsv[1] = 1.0f - sqrt3f(1.0f - hsv[1]);
- hsv_to_rgb(hsv[0], hsv[1], hsv[2], rgb, rgb + 1, rgb + 2);
+ hsv_to_rgb_v(hsv, rgb);
if ((but->flag & UI_BUT_VEC_SIZE_LOCK) && (rgb[0] || rgb[1] || rgb[2])) {
normalize_v3(rgb);
@@ -3357,7 +3360,7 @@ static void ui_ndofedit_but_HSVCIRCLE(uiBut *but, uiHandleButtonData *data, wmND
float sensitivity = (shift ? 0.15f : 0.3f) * ndof->dt;
ui_get_but_vectorf(but, rgb);
- rgb_to_hsv_compat(rgb[0], rgb[1], rgb[2], hsv, hsv + 1, hsv + 2);
+ rgb_to_hsv_compat_v(rgb, hsv);
/* Convert current colour on hue/sat disc to circular coordinates phi, r */
phi = fmodf(hsv[0] + 0.25f, 1.0f) * -2.0f * (float)M_PI;
@@ -3391,7 +3394,7 @@ static void ui_ndofedit_but_HSVCIRCLE(uiBut *but, uiHandleButtonData *data, wmND
if (hsv[2] == 0.0f) hsv[2] = 0.0001f;
}
- hsv_to_rgb(hsv[0], hsv[1], hsv[2], data->vec, data->vec + 1, data->vec + 2);
+ hsv_to_rgb_v(hsv, data->vec);
if ((but->flag & UI_BUT_VEC_SIZE_LOCK) && (data->vec[0] || data->vec[1] || data->vec[2])) {
normalize_v3(data->vec);
@@ -3447,12 +3450,15 @@ static int ui_do_but_HSVCIRCLE(bContext *C, uiBlock *block, uiBut *but, uiHandle
def = MEM_callocN(sizeof(float) * len, "reset_defaults - float");
RNA_property_float_get_default_array(&but->rnapoin, but->rnaprop, def);
- rgb_to_hsv(def[0], def[1], def[2], def_hsv, def_hsv + 1, def_hsv + 2);
+ rgb_to_hsv_v(def, def_hsv);
ui_get_but_vectorf(but, rgb);
- rgb_to_hsv_compat(rgb[0], rgb[1], rgb[2], hsv, hsv + 1, hsv + 2);
+ rgb_to_hsv_compat_v(rgb, hsv);
- hsv_to_rgb(hsv[0], def_hsv[1], hsv[2], rgb, rgb + 1, rgb + 2);
+ def_hsv[0] = hsv[0];
+ def_hsv[2] = hsv[2];
+
+ hsv_to_rgb_v(def_hsv, rgb);
ui_set_but_vectorf(but, rgb);
RNA_property_update(C, &but->rnapoin, but->rnaprop);
diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c
index 5459f689e9f..b690d1f9dc9 100644
--- a/source/blender/editors/interface/interface_regions.c
+++ b/source/blender/editors/interface/interface_regions.c
@@ -339,13 +339,13 @@ static void rgb_tint(float col[3],
float col_hsv_from[3];
float col_hsv_to[3];
- rgb_to_hsv(col[0], col[1], col[2], col_hsv_from + 0, col_hsv_from + 1, col_hsv_from + 2);
+ rgb_to_hsv_v(col, col_hsv_from);
col_hsv_to[0] = h;
col_hsv_to[1] = h_strength;
col_hsv_to[2] = (col_hsv_from[2] * (1.0f - v_strength)) + (v * v_strength);
- hsv_to_rgb(col_hsv_to[0], col_hsv_to[1], col_hsv_to[2], col + 0, col + 1, col + 2);
+ hsv_to_rgb_v(col_hsv_to, col);
}
static void ui_tooltip_region_draw_cb(const bContext *UNUSED(C), ARegion *ar)
@@ -1847,7 +1847,7 @@ void ui_set_but_hsv(uiBut *but)
float col[3];
float *hsv = ui_block_hsv_get(but->block);
- hsv_to_rgb(hsv[0], hsv[1], hsv[2], col, col + 1, col + 2);
+ hsv_to_rgb_v(hsv, col);
ui_set_but_vectorf(but, col);
}
@@ -1860,7 +1860,7 @@ static void ui_update_block_buts_rgb(uiBlock *block, const float rgb[3])
/* this is to keep the H and S value when V is equal to zero
* and we are working in HSV mode, of course!
*/
- rgb_to_hsv_compat(rgb[0], rgb[1], rgb[2], hsv, hsv + 1, hsv + 2);
+ rgb_to_hsv_compat_v(rgb, hsv);
// this updates button strings, is hackish... but button pointers are on stack of caller function
for (bt = block->buttons.first; bt; bt = bt->next) {
@@ -1942,7 +1942,7 @@ static void do_hsv_rna_cb(bContext *UNUSED(C), void *bt1, void *UNUSED(arg))
float rgb[3];
float *hsv = ui_block_hsv_get(but->block);
- hsv_to_rgb(hsv[0], hsv[1], hsv[2], rgb, rgb + 1, rgb + 2);
+ hsv_to_rgb_v(hsv, rgb);
ui_update_block_buts_rgb(but->block, rgb);
@@ -2157,7 +2157,7 @@ static void uiBlockPicker(uiBlock *block, float rgba[4], PointerRNA *ptr, Proper
uiButSetFunc(bt, do_hex_rna_cb, bt, hexcol);
uiDefBut(block, LABEL, 0, IFACE_("(Gamma Corrected)"), 0, -80, butwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
- rgb_to_hsv(rgba[0], rgba[1], rgba[2], hsv, hsv + 1, hsv + 2);
+ rgb_to_hsv_v(rgba, hsv);
picker_new_hide_reveal(block, colormode);
}
@@ -2178,18 +2178,18 @@ static int ui_picker_small_wheel_cb(const bContext *UNUSED(C), uiBlock *block, w
for (but = block->buttons.first; but; but = but->next) {
if (but->type == HSVCUBE && but->active == NULL) {
uiPopupBlockHandle *popup = block->handle;
- float col[3];
+ float rgb[3];
float *hsv = ui_block_hsv_get(block);
- ui_get_but_vectorf(but, col);
+ ui_get_but_vectorf(but, rgb);
- rgb_to_hsv_compat(col[0], col[1], col[2], hsv, hsv + 1, hsv + 2);
+ rgb_to_hsv_compat_v(rgb, hsv);
hsv[2] = CLAMPIS(hsv[2] + add, 0.0f, 1.0f);
- hsv_to_rgb(hsv[0], hsv[1], hsv[2], col, col + 1, col + 2);
+ hsv_to_rgb_v(hsv, rgb);
- ui_set_but_vectorf(but, col);
+ ui_set_but_vectorf(but, rgb);
- ui_update_block_buts_rgb(block, col);
+ ui_update_block_buts_rgb(block, rgb);
if (popup)
popup->menuretval = UI_RETURN_UPDATE;
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index 4d483b69ca2..87c2f2dc20b 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -1885,7 +1885,7 @@ static void ui_draw_but_HSVCIRCLE(uiBut *but, uiWidgetColors *wcol, rcti *rect)
/* color */
ui_get_but_vectorf(but, rgb);
copy_v3_v3(hsv, ui_block_hsv_get(but->block));
- rgb_to_hsv_compat(rgb[0], rgb[1], rgb[2], hsv, hsv + 1, hsv + 2);
+ rgb_to_hsv_compat_v(rgb, hsv);
copy_v3_v3(hsvo, hsv);
/* exception: if 'lock' is set
@@ -1911,7 +1911,7 @@ static void ui_draw_but_HSVCIRCLE(uiBut *but, uiWidgetColors *wcol, rcti *rect)
ui_hsvcircle_vals_from_pos(hsv, hsv + 1, rect, centx + co * radius, centy + si * radius);
CLAMP(hsv[2], 0.0f, 1.0f); /* for display only */
- hsv_to_rgb(hsv[0], hsv[1], hsv[2], col, col + 1, col + 2);
+ hsv_to_rgb_v(hsv, col);
glColor3fv(col);
glVertex2f(centx + co * radius, centy + si * radius);
}
@@ -2081,37 +2081,31 @@ void ui_draw_gradient(rcti *rect, const float hsv[3], int type, float alpha)
static void ui_draw_but_HSVCUBE(uiBut *but, rcti *rect)
{
- float rgb[3], h, s, v;
+ float rgb[3];
float x = 0.0f, y = 0.0f;
float *hsv = ui_block_hsv_get(but->block);
- float hsvn[3];
+ float hsv_n[3];
- h = hsv[0];
- s = hsv[1];
- v = hsv[2];
+ copy_v3_v3(hsv_n, hsv);
ui_get_but_vectorf(but, rgb);
- rgb_to_hsv_compat(rgb[0], rgb[1], rgb[2], &h, &s, &v);
-
- hsvn[0] = h;
- hsvn[1] = s;
- hsvn[2] = v;
+ rgb_to_hsv_compat_v(rgb, hsv_n);
- ui_draw_gradient(rect, hsvn, but->a1, 1.f);
+ ui_draw_gradient(rect, hsv_n, but->a1, 1.0f);
switch ((int)but->a1) {
case UI_GRAD_SV:
- x = v; y = s; break;
+ x = hsv_n[2]; y = hsv_n[1]; break;
case UI_GRAD_HV:
- x = h; y = v; break;
+ x = hsv_n[0]; y = hsv_n[2]; break;
case UI_GRAD_HS:
- x = h; y = s; break;
+ x = hsv_n[0]; y = hsv_n[1]; break;
case UI_GRAD_H:
- x = h; y = 0.5; break;
+ x = hsv_n[0]; y = 0.5; break;
case UI_GRAD_S:
- x = s; y = 0.5; break;
+ x = hsv_n[1]; y = 0.5; break;
case UI_GRAD_V:
- x = v; y = 0.5; break;
+ x = hsv_n[2]; y = 0.5; break;
}
/* cursor */
@@ -2140,7 +2134,7 @@ static void ui_draw_but_HSV_v(uiBut *but, rcti *rect)
color_profile = BLI_PR_NONE;
ui_get_but_vectorf(but, rgb);
- rgb_to_hsv(rgb[0], rgb[1], rgb[2], hsv, hsv + 1, hsv + 2);
+ rgb_to_hsv_v(rgb, hsv);
v = hsv[2];
if (color_profile)