X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;ds=sidebyside;f=synfig-core%2Ftrunk%2Fsrc%2Fsynfig%2Fcolor.h;h=d3ae54d43b6f56302bb387980b011a78fac9cdf0;hb=6063c6a017d00a2572b6691b055ba22b7de2991e;hp=a6b81acf8bcc55a95d813eba83461cec0be70924;hpb=cc54c38609ee9745ad678e5e9b9d7d2912be9c95;p=synfig.git diff --git a/synfig-core/trunk/src/synfig/color.h b/synfig-core/trunk/src/synfig/color.h index a6b81ac..d3ae54d 100644 --- a/synfig-core/trunk/src/synfig/color.h +++ b/synfig-core/trunk/src/synfig/color.h @@ -32,7 +32,7 @@ #include #include #include "gamma.h" -#include +#include #ifdef USE_HALF_TYPE #include @@ -107,6 +107,7 @@ public: private: value_type a_, r_, g_, b_; + static String hex_; public: @@ -263,6 +264,18 @@ public: //! Synonym for get_a(). \see get_a() const value_type& get_alpha()const { return get_a(); } + //! Converts a 2 character hex string \a s (00-ff) into a ColorReal (0.0-1.0) + static ColorReal hex2real(String s); + + //! Converts a ColorReal \a c (0.0-1.0) into a 2 character hex string (00-ff) + static const String real2hex(ColorReal c); + + //! Returns the color as a 6 character hex sting + const String& get_hex()const { return hex_ = real2hex(r_)+real2hex(g_)+real2hex(b_); } + + //! Sets the color's R, G, and B from a 3 or 6 character hex string + void set_hex(String& hex); + //! Sets the RED component to \a x Color& set_r(const value_type& x) { r_ = x; return *this; }