[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] /srv/bzr/gnash/trunk r11345: RGBA can parse values from h
From: |
Bob Naugle |
Subject: |
[Gnash-commit] /srv/bzr/gnash/trunk r11345: RGBA can parse values from hex string (eg. #FF0000) |
Date: |
Thu, 30 Jul 2009 12:43:13 -0600 |
User-agent: |
Bazaar (1.13.1) |
------------------------------------------------------------
revno: 11345
committer: Bob Naugle <address@hidden>
branch nick: trunk
timestamp: Thu 2009-07-30 12:43:13 -0600
message:
RGBA can parse values from hex string (eg. #FF0000)
modified:
libcore/RGBA.cpp
libcore/RGBA.h
libcore/TextField.cpp
=== modified file 'libcore/RGBA.cpp'
--- a/libcore/RGBA.cpp 2009-03-24 10:56:52 +0000
+++ b/libcore/RGBA.cpp 2009-07-30 18:43:13 +0000
@@ -83,6 +83,16 @@
}
void
+rgba::fromShortString(std::string color)
+{
+ std::stringstream ss(color);
+ int hexnumber;
+ ss.ignore();
+ ss >> std::hex >> hexnumber;
+ parseRGB(hexnumber);
+}
+
+void
rgba::set_lerp(const rgba& a, const rgba& b, float f)
{
m_r = static_cast<boost::uint8_t>(frnd(flerp(a.m_r, b.m_r, f)));
=== modified file 'libcore/RGBA.h'
--- a/libcore/RGBA.h 2009-06-15 11:32:49 +0000
+++ b/libcore/RGBA.h 2009-07-30 18:43:13 +0000
@@ -125,6 +125,11 @@
// neater string output (example: "0,0,0,255")
std::string toShortString() const;
+ /// Set values from string (eg. #FF0000)
+ //
+ /// @param color Hex String in '#xxxxxx' format
+ void fromShortString(std::string color);
+
bool operator== (const rgba& o) const
{
return m_r == o.m_r &&
=== modified file 'libcore/TextField.cpp'
--- a/libcore/TextField.cpp 2009-07-30 16:45:10 +0000
+++ b/libcore/TextField.cpp 2009-07-30 18:43:13 +0000
@@ -1564,14 +1564,8 @@
attloc = attributes.find("COLOR");
if (attloc != attributes.end()) {
//font COLOR attribute
- boost::uint8_t r = std::strtol(
- attloc->second.substr(1,2).data(), NULL,
16);
- boost::uint8_t g = std::strtol(
- attloc->second.substr(3,2).data(), NULL,
16);
- boost::uint8_t b = std::strtol(
- attloc->second.substr(5,2).data(), NULL,
16);
- boost::uint8_t a = 255; //alpha not given in
color attribute
- rgba color(r,g,b,a);
+ rgba color;
+ color.fromShortString(attloc->second);
newrec.setColor(color);
}
attloc = attributes.find("FACE");
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] /srv/bzr/gnash/trunk r11345: RGBA can parse values from hex string (eg. #FF0000),
Bob Naugle <=