This commit is contained in:
itsmattkc
2020-05-06 00:11:09 +10:00
41 changed files with 230 additions and 90 deletions
+13
View File
@@ -78,6 +78,14 @@ Color::Color(const char *data, const PixelFormat::Format &format)
}
}
Color::Color(const QColor &c)
{
set_red(c.redF());
set_green(c.greenF());
set_blue(c.blueF());
set_alpha(c.alphaF());
}
void Color::toHsv(float *hue, float *sat, float *val) const
{
float fCMax = qMax(qMax(red(), green()), blue());
@@ -207,6 +215,11 @@ QColor Color::toQColor() const
return c;
}
float Color::GetRoughLuminance() const
{
return (2*red()+blue()+3*green())/6.0f;
}
const Color &Color::operator+=(const Color &rhs)
{
for (int i=0;i<kRGBAChannels;i++) {
+6
View File
@@ -52,6 +52,8 @@ public:
Color(const char *data, const PixelFormat::Format &format);
Color(const QColor& c);
/**
* @brief Creates a Color struct from hue/saturation/value
*
@@ -86,6 +88,10 @@ public:
QColor toQColor() const;
// Suuuuper rough luminance value mostly used for UI (determining whether to overlay with black
// or white text)
float GetRoughLuminance() const;
// Assignment math operators
const Color& operator+=(const Color& rhs);
const Color& operator-=(const Color& rhs);