13
0

add Gtkmm2ext::random_color()

This commit is contained in:
Paul Davis 2020-06-10 14:10:52 -06:00
parent a3039d3895
commit fc25e074ac
2 changed files with 9 additions and 0 deletions

View File

@ -21,6 +21,7 @@
#include <cmath>
#include <stdint.h>
#include <cfloat>
#include <cstdlib>
#include "pbd/failed_constructor.h"
#include "pbd/string_convert.h"
@ -698,3 +699,9 @@ Gtkmm2ext::set_source_rgb_a (cairo_t *cr, Color color, float alpha)
alpha
);
}
Color
Gtkmm2ext::random_color ()
{
return ((random() % 16777215) << 8 | 0xff);
}

View File

@ -31,6 +31,8 @@ namespace Gtkmm2ext
typedef uint32_t Color;
extern LIBGTKMM2EXT_API Color random_color ();
/* conventient way to use Gtkmm2ext::Color with libcairo */
extern LIBGTKMM2EXT_API void set_source_rgba (Cairo::RefPtr<Cairo::Context>, Gtkmm2ext::Color);
extern LIBGTKMM2EXT_API void set_source_rgb_a (Cairo::RefPtr<Cairo::Context>, Gtkmm2ext::Color, float alpha); //override the color's alpha