pick route colors from the color palette (with random variation) #9115

This commit is contained in:
Paul Davis 2022-12-07 21:27:46 -07:00
parent cd7c981e6e
commit cd4b6e85a8
3 changed files with 21 additions and 3 deletions

View File

@ -65,7 +65,7 @@ AxisView::~AxisView()
Gdk::Color
AxisView::unique_random_color()
{
return ::unique_random_color (used_colors);
return ::unique_random_color (used_colors, true);
}
string

View File

@ -680,10 +680,28 @@ ARDOUR_UI_UTILS::escape_underscores (string const & s)
}
Gdk::Color
ARDOUR_UI_UTILS::unique_random_color (list<Gdk::Color>& used_colors)
ARDOUR_UI_UTILS::unique_random_color (list<Gdk::Color>& used_colors, bool from_palette)
{
Gdk::Color newcolor;
if (from_palette) {
string cp = UIConfiguration::instance().get_stripable_color_palette ();
Gdk::ArrayHandle_Color gc = ColorSelection::palette_from_string (cp);
std::vector<Gdk::Color> c (gc);
int n = random () % c.size();
Gtkmm2ext::HSV hsv (Gtkmm2ext::gdk_color_to_rgba (c[n]));
do {
newcolor.set_hsv (hsv.h, hsv.s, hsv.v);
hsv = random() % 1000 > 500 ? hsv.darker ((random() % 500) / 1000.0) : hsv.lighter ((random() % 500 / 1000.0));
} while (find (used_colors.begin(), used_colors.end(), newcolor) != used_colors.end());
used_colors.push_back (newcolor);
return newcolor;
}
while (1) {
double h, s, v;

View File

@ -98,7 +98,7 @@ void resize_window_to_proportion_of_monitor (Gtk::Window*, int, int);
std::string escape_underscores (std::string const &);
Gdk::Color unique_random_color (std::list<Gdk::Color> &);
Gdk::Color unique_random_color (std::list<Gdk::Color> &, bool from_palette = false);
std::string rate_as_string (float r);
std::string samples_as_time_string (ARDOUR::samplecnt_t s, float r, bool show_samples = false);