Scroom 0.14-49-gb7ae7a6d
Loading...
Searching...
No Matches
Color Class Reference

#include <color.hh>

Inheritance diagram for Color:
Inheritance graph
Collaboration diagram for Color:
Collaboration graph

Public Member Functions

 Color ()=default
 
 Color (double red_, double green_, double blue_, double alpha_=1.0)
 
 Color (double gray, double alpha_=1.0)
 
Coloroperator+= (const Color &rhs)
 
Coloroperator/= (double d)
 
Coloroperator*= (double d)
 
std::string getHex () const
 
uint32_t getRGB24 () const
 
uint32_t getARGB32 () const
 
void setColor (cairo_t *cr) const
 
GdkColor getGdkColor () const
 
Color getContrastingBlackOrWhite () const
 
ColorsetAlpha (double alpha_)
 
Color setAlpha (double alpha_) const
 

Public Attributes

double alpha {1.0}
 
double red {0.0}
 
double green {0.0}
 
double blue {0.0}
 

Detailed Description

Represent a (ARGB) color

Constructor & Destructor Documentation

◆ Color() [1/3]

Color::Color ( )
default

Default constructor. Create black

Referenced by getContrastingBlackOrWhite(), and setAlpha().

Here is the caller graph for this function:

◆ Color() [2/3]

Color::Color ( double  red_,
double  green_,
double  blue_,
double  alpha_ = 1.0 
)
inline

Constructor. Use the given RGB values

50 : alpha(alpha_)
51 , red(red_)
52 , green(green_)
53 , blue(blue_)
54 {
55 }
double green
Definition color.hh:41
double blue
Definition color.hh:42
double red
Definition color.hh:40
double alpha
Definition color.hh:39

◆ Color() [3/3]

Color::Color ( double  gray,
double  alpha_ = 1.0 
)
inlineexplicit

Constructor. Create the given gray value

59 : alpha(alpha_)
60 , red(gray)
61 , green(gray)
62 , blue(gray)
63 {
64 }

Member Function Documentation

◆ getARGB32()

uint32_t Color::getARGB32 ( ) const
inline
113 {
114 return byteFromDouble(alpha) << 24 | byteFromDouble(red) << 16 | byteFromDouble(green) << 8 | byteFromDouble(blue) << 0;
115 }
uint8_t byteFromDouble(double d)
Definition color.hh:21

Referenced by Operations8bpp::cache(), and OperationsColormapped::cache().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getContrastingBlackOrWhite()

Color Color::getContrastingBlackOrWhite ( ) const
inline
122 {
123 // see http://stackoverflow.com/a/3943023
124 const double L = 0.2126 * Detail::computeC(red) + 0.7152 * Detail::computeC(green) + 0.0722 * Detail::computeC(blue);
125 return Color(L > 0.179 ? 0 : 1);
126 }
Color()=default
double computeC(double c)
Definition color.hh:28

Referenced by CommonOperations::drawPixelValue(), and anonymous_namespace{transparentoverlayviewinfo.cc}::setToggleButtonColor().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getGdkColor()

GdkColor Color::getGdkColor ( ) const
inline
uint16_t shortFromDouble(double d)
Definition color.hh:23
Here is the call graph for this function:

◆ getHex()

std::string Color::getHex ( ) const
inline
94 {
95 std::stringstream ss;
96
97 ss << std::hex << std::setfill('0');
98
99
100 ss << std::hex << std::setw(2) << static_cast<int>(byteFromDouble(red));
101 ss << std::hex << std::setw(2) << static_cast<int>(byteFromDouble(green));
102 ss << std::hex << std::setw(2) << static_cast<int>(byteFromDouble(blue));
103
104 return ss.str();
105 }

Referenced by anonymous_namespace{transparentoverlayviewinfo.cc}::setToggleButtonColor().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getRGB24()

uint32_t Color::getRGB24 ( ) const
inline
108 {
109 return 0xFF000000 | byteFromDouble(red) << 16 | byteFromDouble(green) << 8 | byteFromDouble(blue) << 0;
110 }
Here is the call graph for this function:

◆ operator*=()

Color & Color::operator*= ( double  d)
inline
85 {
86 alpha *= d;
87 red *= d;
88 green *= d;
89 blue *= d;
90 return *this;
91 }

◆ operator+=()

Color & Color::operator+= ( const Color rhs)
inline
67 {
68 alpha += rhs.alpha;
69 red += rhs.red;
70 green += rhs.green;
71 blue += rhs.blue;
72 return *this;
73 }

◆ operator/=()

Color & Color::operator/= ( double  d)
inline
76 {
77 alpha /= d;
78 red /= d;
79 green /= d;
80 blue /= d;
81 return *this;
82 }

◆ setAlpha() [1/2]

Color & Color::setAlpha ( double  alpha_)
inline
128{ return *this *= alpha_; }

Referenced by MonochromeColormapHelper::regenerateColormap(), and setAlpha().

Here is the caller graph for this function:

◆ setAlpha() [2/2]

Color Color::setAlpha ( double  alpha_) const
inline
130{ return Color(*this).setAlpha(alpha_); }
Here is the call graph for this function:

◆ setColor()

void Color::setColor ( cairo_t *  cr) const
inline
117{ cairo_set_source_rgba(cr, red, green, blue, alpha); }
cairo_t * cr
Definition transformpresentation_test.cc:72

Referenced by CommonOperations::drawPixelValue().

Here is the caller graph for this function:

Member Data Documentation

◆ alpha

◆ blue

◆ green

◆ red


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