Added assignment operators for rgb and hsb
This commit is contained in:
parent
965117d291
commit
5ee6c17faa
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user