libosmscout 0.1
Loading...
Searching...
No Matches
osmscout::Color Class Referencefinal

Representation of a color with red, green and blue value (RGB) and a alpha channel. More...

#include <Color.h>

Public Member Functions

Color Alpha (double newAlpha) const
 Color ()=default
 Color (double r, double g, double b) noexcept
 Color (double r, double g, double b, double a) noexcept
Color Darken (double factor) const
Color Decolor () const
double GetA () const
double GetB () const
double GetG () const
double GetR () const
bool IsSolid () const
bool IsVisible () const
Color Lighten (double factor) const
bool operator!= (const Color &other) const
bool operator< (const Color &other) const
bool operator== (const Color &other) const
std::string ToHexString () const
 ~Color ()=default

Static Public Member Functions

static Color FromHexString (const std::string &hexString)
 Convert the given color string to a color value.
static bool FromHexString (const std::string &hexString, Color &color)
static bool FromW3CKeywordString (const std::string &colorKeyword, Color &color)
 Convert the give color keyword to a color value.
static bool IsHexString (const std::string &hexString)

Static Public Attributes

static const Color AQUA
static const Color BLACK
static const Color BLUE
static const Color DARK_AQUA
static const Color DARK_BLUE
static const Color DARK_FUCHSIA
static const Color DARK_GRAY
static const Color DARK_GREEN
static const Color DARK_RED
static const Color DARK_YELLOW
static const Color FUCHSIA
static const Color GRAY
static const Color GREEN
static const Color LIGHT_GRAY
static const Color LIME
static const Color LUCENT_WHITE
static const Color MAROON
static const Color NAVY
static const Color OLIVE
static const Color PURPLE
static const Color RED
static const Color SILVER
static const Color TEAL
static const Color WHITE
static const Color YELLOW

Detailed Description

Representation of a color with red, green and blue value (RGB) and a alpha channel.

This class follow the "rule of zero" (see https://en.cppreference.com/w/cpp/language/rule_of_three)

Constructor & Destructor Documentation

◆ Color() [1/3]

◆ ~Color()

osmscout::Color::~Color ( )
default

◆ Color() [2/3]

osmscout::Color::Color ( double r,
double g,
double b,
double a )
inlinenoexcept

◆ Color() [3/3]

osmscout::Color::Color ( double r,
double g,
double b )
inlinenoexcept

Member Function Documentation

◆ Alpha()

Color osmscout::Color::Alpha ( double newAlpha) const
inline

◆ Darken()

Color osmscout::Color::Darken ( double factor) const
inline

◆ Decolor()

Color osmscout::Color::Decolor ( ) const
inline

References Color().

◆ FromHexString() [1/2]

Color osmscout::Color::FromHexString ( const std::string & hexString)
static

Convert the given color string to a color value.

The string must either be of the format

  • #HHHHHH
  • #HHHHHHHH

where '#' is the symbol itself and 'H' represents a hexadecimal value

Parameters
hexString(lowercase)
Returns

References Color(), and osmscout::GetHexValue().

Referenced by osmscout::oss::Parser::COLOR_VALUE(), FromHexString(), osmscout::ColorFeature::Parse(), and osmscout::OverlayObject::setColor().

◆ FromHexString() [2/2]

bool osmscout::Color::FromHexString ( const std::string & hexString,
Color & color )
static

◆ FromW3CKeywordString()

bool osmscout::Color::FromW3CKeywordString ( const std::string & colorKeyword,
Color & color )
static

Convert the give color keyword to a color value.

Just basic color set is supported. See https://www.w3.org/TR/css-color-3/#html4

Parameters
colorKeyword
color
Returns
true on success, false otherwise

References AQUA, BLACK, BLUE, Color(), DARK_AQUA, DARK_BLUE, DARK_FUCHSIA, DARK_GRAY, DARK_GREEN, DARK_RED, DARK_YELLOW, FUCHSIA, GRAY, GREEN, LIGHT_GRAY, LIME, MAROON, NAVY, OLIVE, PURPLE, RED, SILVER, TEAL, WHITE, and YELLOW.

Referenced by osmscout::ColorFeature::Parse(), and osmscout::OverlayObject::setColor().

◆ GetA()

◆ GetB()

◆ GetG()

◆ GetR()

◆ IsHexString()

bool osmscout::Color::IsHexString ( const std::string & hexString)
static

Referenced by FromHexString().

◆ IsSolid()

bool osmscout::Color::IsSolid ( ) const
inline

◆ IsVisible()

bool osmscout::Color::IsVisible ( ) const
inline

◆ Lighten()

Color osmscout::Color::Lighten ( double factor) const
inline

◆ operator!=()

bool osmscout::Color::operator!= ( const Color & other) const
inline

References Color().

◆ operator<()

bool osmscout::Color::operator< ( const Color & other) const

References Color().

◆ operator==()

bool osmscout::Color::operator== ( const Color & other) const
inline

References Color().

◆ ToHexString()

std::string osmscout::Color::ToHexString ( ) const

Member Data Documentation

◆ AQUA

const Color osmscout::Color::AQUA
static

Referenced by FromW3CKeywordString().

◆ BLACK

const Color osmscout::Color::BLACK
static

◆ BLUE

const Color osmscout::Color::BLUE
static

Referenced by FromW3CKeywordString().

◆ DARK_AQUA

const Color osmscout::Color::DARK_AQUA
static

Referenced by FromW3CKeywordString().

◆ DARK_BLUE

const Color osmscout::Color::DARK_BLUE
static

Referenced by FromW3CKeywordString().

◆ DARK_FUCHSIA

const Color osmscout::Color::DARK_FUCHSIA
static

Referenced by FromW3CKeywordString().

◆ DARK_GRAY

const Color osmscout::Color::DARK_GRAY
static

Referenced by FromW3CKeywordString().

◆ DARK_GREEN

const Color osmscout::Color::DARK_GREEN
static

Referenced by FromW3CKeywordString().

◆ DARK_RED

const Color osmscout::Color::DARK_RED
static

Referenced by FromW3CKeywordString().

◆ DARK_YELLOW

const Color osmscout::Color::DARK_YELLOW
static

Referenced by FromW3CKeywordString().

◆ FUCHSIA

const Color osmscout::Color::FUCHSIA
static

Referenced by FromW3CKeywordString().

◆ GRAY

const Color osmscout::Color::GRAY
static

Referenced by FromW3CKeywordString().

◆ GREEN

const Color osmscout::Color::GREEN
static

Referenced by FromW3CKeywordString().

◆ LIGHT_GRAY

const Color osmscout::Color::LIGHT_GRAY
static

Referenced by FromW3CKeywordString().

◆ LIME

const Color osmscout::Color::LIME
static

Referenced by FromW3CKeywordString().

◆ LUCENT_WHITE

const Color osmscout::Color::LUCENT_WHITE
static

◆ MAROON

const Color osmscout::Color::MAROON
static

Referenced by FromW3CKeywordString().

◆ NAVY

const Color osmscout::Color::NAVY
static

Referenced by FromW3CKeywordString().

◆ OLIVE

const Color osmscout::Color::OLIVE
static

Referenced by FromW3CKeywordString().

◆ PURPLE

const Color osmscout::Color::PURPLE
static

Referenced by FromW3CKeywordString().

◆ RED

const Color osmscout::Color::RED
static

Referenced by FromW3CKeywordString().

◆ SILVER

const Color osmscout::Color::SILVER
static

Referenced by FromW3CKeywordString().

◆ TEAL

const Color osmscout::Color::TEAL
static

Referenced by FromW3CKeywordString().

◆ WHITE

const Color osmscout::Color::WHITE
static

Referenced by FromW3CKeywordString().

◆ YELLOW

const Color osmscout::Color::YELLOW
static

Referenced by FromW3CKeywordString().


The documentation for this class was generated from the following files: