4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Angus Leeming
9 * Full author contact details are available in file CREDITS
12 /* structs RGBColor and HSVColor to enable simple conversion between
23 /** Given col, fills r, g, b in the range 0-255.
24 The function returns true if successful.
25 It returns false on failure and sets r, g, b to 0. */
26 bool getRGBColor(LColor::color col,
27 unsigned int & r, unsigned int & g, unsigned int & b);
30 /// returns a string of form #rrggbb, given an RGBColor struct
31 string const X11hexname(RGBColor const & col);
37 HSVColor() : h(0.0), s(0.0), v(0.0) {}
38 HSVColor(double hue, double sat, double val)
39 : h(hue), s(sat), v(val) {}
40 HSVColor(RGBColor const &);
47 RGBColor() : r(0), g(0), b(0) {}
48 RGBColor(unsigned int red, unsigned int green, unsigned int blue)
49 : r(red), g(green), b(blue) {}
50 RGBColor(HSVColor const &);
51 /// \param x11hexname is of the form "#ffa071"
52 RGBColor(string const & x11hexname);
55 struct NamedColor : public RGBColor {
57 NamedColor() : RGBColor() {}
58 NamedColor(string const & n, RGBColor const & c)
59 : RGBColor(c), name(n) {}
60 RGBColor const & color() const { return *this; }
61 string const & getname() const { return name; }
65 bool operator==(RGBColor const & c1, RGBColor const & c2)
67 return (c1.r == c2.r && c1.g == c2.g && c1.b == c2.b);
72 bool operator!=(RGBColor const & c1, RGBColor const & c2)