X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-core%2Ftrunk%2Fsrc%2Fsynfig%2Fcolor.h;h=d3ae54d43b6f56302bb387980b011a78fac9cdf0;hb=4ce272bc94d4199b51a211164b30da823633c30c;hp=776d9d7cce1ba20576d167e64b9ac0807743dbfc;hpb=5ddcf36f04cfbd10fabda4e3c5633cb27cdd4c0a;p=synfig.git diff --git a/synfig-core/trunk/src/synfig/color.h b/synfig-core/trunk/src/synfig/color.h index 776d9d7..d3ae54d 100644 --- a/synfig-core/trunk/src/synfig/color.h +++ b/synfig-core/trunk/src/synfig/color.h @@ -2,7 +2,7 @@ /*! \file color.h ** \brief Color Class Implementation ** -** $Id: color.h,v 1.1.1.1 2005/01/04 01:23:14 darco Exp $ +** $Id$ ** ** \legal ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley @@ -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: @@ -216,10 +217,10 @@ public: g_(G), b_(B) { } - /*! \param C Source for color components + /*! \param c Source for color components ** \param A Opacity(alpha) */ Color(const Color& c, const value_type& A): - a_(c.a_), + a_(A), r_(c.r_), g_(c.g_), b_(c.b_) { } @@ -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; }