summaryrefslogtreecommitdiff
path: root/gtk2_ardour/utils.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2013-06-27 15:51:57 -0400
committerPaul Davis <paul@linuxaudiosystems.com>2013-06-27 15:51:57 -0400
commit6618c9e4060da66964bd5707be442ba3f0f156ef (patch)
treea1cb59b63fd921dff3f9bee942a14f803aaa4d68 /gtk2_ardour/utils.cc
parent0e656f0a13344e7fdc6a3cb01482b5f5f6c021f4 (diff)
use HSV to pick random colors and avoid over-saturation or over-brightness
Diffstat (limited to 'gtk2_ardour/utils.cc')
-rw-r--r--gtk2_ardour/utils.cc13
1 files changed, 12 insertions, 1 deletions
diff --git a/gtk2_ardour/utils.cc b/gtk2_ardour/utils.cc
index cab8b1ff7c..c0fc619f68 100644
--- a/gtk2_ardour/utils.cc
+++ b/gtk2_ardour/utils.cc
@@ -755,6 +755,13 @@ unique_random_color (list<Gdk::Color>& used_colors)
while (1) {
+ double h, s, v;
+
+ h = fmod (random(), 360.0);
+ s = (random() % 65535) / 65535.0;
+ v = (random() % 65535) / 65535.0;
+
+#if 0
/* avoid neon/glowing tones by limiting them to the
"inner section" (paler) of a color wheel/circle.
*/
@@ -764,7 +771,11 @@ unique_random_color (list<Gdk::Color>& used_colors)
newcolor.set_red (random() % max_saturation);
newcolor.set_blue (random() % max_saturation);
newcolor.set_green (random() % max_saturation);
-
+#else
+ s = min (0.5, s); /* not too saturated */
+ v = max (0.9, v); /* not too bright */
+ newcolor.set_hsv (h, s, v);
+#endif
if (used_colors.size() == 0) {
used_colors.push_back (newcolor);
return newcolor;