|
osgEarth 2.1.1
|
Collaboration diagram for osgEarth::Symbology::Color:Public Types | |
| enum | Format { RGBA, ABGR } |
Public Member Functions | |
| Color () | |
| Color (const Color &rhs) | |
| Color (const osg::Vec4f &rgba) | |
| Color (const Color &rhs, float a) | |
| Color (float r, float g, float b, float a=1.0f) | |
| Color (unsigned rgba) | |
| Color (const std::string &html, Format format=RGBA) | |
| std::string | toHTML (Format format=RGBA) const |
| Color | brightness (float factor) const |
Static Public Attributes | |
| static Color | White |
| static Color | Silver |
| static Color | Gray |
| static Color | Black |
| static Color | Red |
| static Color | Maroon |
| static Color | Yellow |
| static Color | Olive |
| static Color | Lime |
| static Color | Green |
| static Color | Aqua |
| static Color | Teal |
| static Color | Blue |
| static Color | Navy |
| static Color | Fuchsia |
| static Color | Purple |
| static Color | Orange |
| static Color | Cyan |
| static Color | DarkGray |
| osgEarth::Symbology::Color::Color | ( | ) | [inline] |
| osgEarth::Symbology::Color::Color | ( | const Color & | rhs | ) | [inline] |
| osgEarth::Symbology::Color::Color | ( | const osg::Vec4f & | rgba | ) | [inline] |
| Color::Color | ( | const Color & | rhs, |
| float | a | ||
| ) |
| osgEarth::Symbology::Color::Color | ( | float | r, |
| float | g, | ||
| float | b, | ||
| float | a = 1.0f |
||
| ) | [inline] |
| Color::Color | ( | unsigned | rgba | ) |
| Color::Color | ( | const std::string & | html, |
| Format | format = RGBA |
||
| ) |
Construct a color from an HTML string (e.g., "#FF0004F")
Parses an HTML color ("#rrggbb" or "#rrggbbaa") into an OSG color.
Definition at line 111 of file Color.cpp.
{
std::string t = html;
std::transform( t.begin(), t.end(), t.begin(), ::tolower );
osg::Vec4ub c(0,0,0,255);
if ( t.length() >= 7 ) {
c.r() |= t[1]<='9' ? (t[1]-'0')<<4 : (10+(t[1]-'a'))<<4;
c.r() |= t[2]<='9' ? (t[2]-'0') : (10+(t[2]-'a'));
c.g() |= t[3]<='9' ? (t[3]-'0')<<4 : (10+(t[3]-'a'))<<4;
c.g() |= t[4]<='9' ? (t[4]-'0') : (10+(t[4]-'a'));
c.b() |= t[5]<='9' ? (t[5]-'0')<<4 : (10+(t[5]-'a'))<<4;
c.b() |= t[6]<='9' ? (t[6]-'0') : (10+(t[6]-'a'));
if ( t.length() == 9 ) {
c.a() = 0;
c.a() |= t[7]<='9' ? (t[7]-'0')<<4 : (10+(t[7]-'a'))<<4;
c.a() |= t[8]<='9' ? (t[8]-'0') : (10+(t[8]-'a'));
}
}
float w = ((float)c.r())/255.0f;
float x = ((float)c.g())/255.0f;
float y = ((float)c.b())/255.0f;
float z = ((float)c.a())/255.0f;
if ( format == RGBA )
set( w, x, y, z );
else // ABGR
set( z, y, x, w );
}
| Color Color::brightness | ( | float | factor | ) | const |
| std::string Color::toHTML | ( | Format | format = RGBA | ) | const |
Encode the color at an HTML color string (e.g., "#FF004F78")
Makes an HTML color ("#rrggbb" or "#rrggbbaa") from an OSG color.
Definition at line 142 of file Color.cpp.
{
float w, x, y, z;
if ( format == RGBA ) {
w = r(), x = g(), y = b(), z = a();
}
else { // ABGR
w = a(), x = b(), y = g(), z = r();
}
std::stringstream buf;
buf << "#";
buf << std::hex << std::setw(2) << std::setfill('0') << (int)(w*255.0f);
buf << std::hex << std::setw(2) << std::setfill('0') << (int)(x*255.0f);
buf << std::hex << std::setw(2) << std::setfill('0') << (int)(y*255.0f);
buf << std::hex << std::setw(2) << std::setfill('0') << (int)(z*255.0f);
std::string ssStr = buf.str();
return ssStr;
}
Color Color::Aqua [static] |
Color Color::Black [static] |
Color Color::Blue [static] |
Color Color::Cyan [static] |
Color Color::DarkGray [static] |
Color Color::Fuchsia [static] |
Color Color::Gray [static] |
Color Color::Green [static] |
Color Color::Lime [static] |
Color Color::Maroon [static] |
Color Color::Navy [static] |
Color Color::Olive [static] |
Color Color::Orange [static] |
Color Color::Purple [static] |
Color Color::Red [static] |
Color Color::Silver [static] |
Color Color::Teal [static] |
Color Color::White [static] |
Color Color::Yellow [static] |
1.7.3