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:
authorAlexander Ewering <blender@instinctive.de>2005-10-05 01:23:19 +0400
committerAlexander Ewering <blender@instinctive.de>2005-10-05 01:23:19 +0400
commit784a99b9b023e655b02c7cf04160fbd787386c6c (patch)
tree83c80172c06482d93a0a721a0e099fd548a1eed8 /source/blender/blenlib
parent42bd456060a4c1ffebcd26ca5a32eb9b5a0a2edb (diff)
Beware, coded between 10 phone calls and 20 sudden surprises, but I still
hope it's somehow usable :-) Colourpicker update: ------------------- 1) Converted numbuts to sliders and made the colourpicker wider. Sliders are more useful for something like RGB and HSV because they're fixed range values 2) Added a hex button for entering HTML-like color (#RRGGBB, can be entered both with and without the hash sign). This should completely replace the former strange NKEY functionality in buttonswindows, and even add hex support for buttons which didn't have it before. Please test thoroughly, I never coded something in a hurry like this. There are small rounding errors still... Maybe someone finds the reason? :)
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r--source/blender/blenlib/BLI_arithb.h2
-rw-r--r--source/blender/blenlib/intern/arithb.c13
2 files changed, 15 insertions, 0 deletions
diff --git a/source/blender/blenlib/BLI_arithb.h b/source/blender/blenlib/BLI_arithb.h
index f31729ac54a..fedcefcd8b8 100644
--- a/source/blender/blenlib/BLI_arithb.h
+++ b/source/blender/blenlib/BLI_arithb.h
@@ -650,6 +650,8 @@ hsv_to_rgb(
float *g, float *b
);
+void hex_to_rgb(char *hexcol, float *r, float *g, float *b);
+
void
rgb_to_hsv(
float r, float g, float b,
diff --git a/source/blender/blenlib/intern/arithb.c b/source/blender/blenlib/intern/arithb.c
index 723a046b699..ad2d5c1e458 100644
--- a/source/blender/blenlib/intern/arithb.c
+++ b/source/blender/blenlib/intern/arithb.c
@@ -2520,6 +2520,19 @@ void hsv_to_rgb(float h, float s, float v, float *r, float *g, float *b)
}
}
+void hex_to_rgb(char *hexcol, float *r, float *g, float *b)
+{
+ unsigned int ri, gi, bi;
+
+ if (hexcol[0] == '#') hexcol++;
+
+ if (sscanf(hexcol, "%02x%02x%02x", &ri, &gi, &bi)) {
+ *r = ri / 255.0;
+ *g = gi / 255.0;
+ *b = bi / 255.0;
+ }
+}
+
void rgb_to_hsv(float r, float g, float b, float *lh, float *ls, float *lv)
{
float h, s, v;