Drop the bool operator for ObjectURI, to avoid getting the kind of side-effect that...
[gnash.git] / libcore / RGBA.cpp
blobb6c53da96c04eae5a203ba4fcf7f0a5ab82e0523
1 //
2 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Free Software
3 // Foundation, Inc
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 //
20 #include "RGBA.h"
21 #include "GnashNumeric.h"
22 #include "log.h"
23 #include <sstream>
25 namespace gnash {
27 std::string
28 rgba::toShortString() const
30 std::stringstream ss;
31 ss << +m_r << "," << +m_g << "," << +m_b << "," << +m_a;
32 return ss.str();
35 void
36 rgba::set_lerp(const rgba& a, const rgba& b, float f)
38 m_r = frnd(lerp<float>(a.m_r, b.m_r, f));
39 m_g = frnd(lerp<float>(a.m_g, b.m_g, f));
40 m_b = frnd(lerp<float>(a.m_b, b.m_b, f));
41 m_a = frnd(lerp<float>(a.m_a, b.m_a, f));
44 rgba
45 colorFromHexString(const std::string& color)
47 std::stringstream ss(color);
48 boost::uint32_t hexnumber;
50 if (!(ss >> std::hex >> hexnumber)) {
51 log_error("Failed to convert string to RGBA value! This is a "
52 "Gnash bug");
53 return rgba();
56 rgba ret;
57 ret.parseRGB(hexnumber);
58 return ret;
61 std::ostream&
62 operator<<(std::ostream& os, const rgba& r)
64 return os << "rgba: " << +r.m_r << "," << +r.m_g << "," << +r.m_b << ","
65 << +r.m_a;
68 } // namespace gnash
71 // Local Variables:
72 // mode: C++
73 // c-basic-offset: 8
74 // tab-width: 8
75 // indent-tabs-mode: t
76 // End: