Added assignment operators for rgb and hsb

This commit is contained in:
Bob Polis 2022-09-28 17:32:51 +02:00
parent 965117d291
commit 5ee6c17faa
2 changed files with 14 additions and 0 deletions

View File

@ -96,3 +96,14 @@ Color::Color(const std::string& hex) {
iss >> std::hex >> val;
_rgb.b = val / 256.0;
}
Color& Color::operator=(const RGB& rgb) {
_rgb = rgb;
return *this;
}
Color& Color::operator=(const HSB& hsb) {
Color tmp {hsb};
_rgb = tmp._rgb;
return *this;
}

View File

@ -24,6 +24,9 @@ class Color {
operator RGB() const { return _rgb; }
operator HSB() const;
Color& operator=(const RGB& rgb);
Color& operator=(const HSB& hsb);
private:
RGB _rgb;
};