Commit 21952646 authored by Romain Bignon's avatar Romain Bignon

add methods to change color

parent 48e99d99
......@@ -50,9 +50,14 @@ Color::Color(Uint8 r, Uint8 g, Uint8 b, Uint8 a){
SetColor(r, g, b, a);
}
Color::Color(const Color& c)
{
SetColor(c.red, c.green, c.blue, c.alpha);
}
bool Color::operator==(const Color &color) const{
return red == color.red
&& green == color.green
return red == color.red
&& green == color.green
&& blue == color.blue /*
&& alpha == color.alpha*/;
}
......@@ -80,6 +85,14 @@ Uint8 Color::GetAlpha() const{
return alpha;
}
Color Color::WithAlpha(Uint8 a) const
{
Color c(*this);
c.SetAlpha(a);
return c;
}
SDL_Color Color::GetSDLColor() const{
SDL_Color sdlColor;
......
......@@ -54,11 +54,17 @@ private:
public:
Color();
Color(const Color&);
Color(Uint8 r, Uint8 g, Uint8 b, Uint8 a);
bool operator==(const Color &color) const;
void SetColor(Uint8 r, Uint8 g, Uint8 b, Uint8 a);
void SetRed(Uint8 r) { red = r; }
void SetGreen(Uint8 g) { green = g; }
void SetBlue(Uint8 b) { blue = b; }
void SetAlpha(Uint8 a) { alpha = a; }
Color WithAlpha(Uint8 a) const;
Uint8 GetRed() const;
Uint8 GetGreen() const;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment