]> git.localhorst.tv Git - l2e.git/blob - src/graphics/Color.h
42cbc89b6870df98c2c6154e4548c16f959dc3c4
[l2e.git] / src / graphics / Color.h
1 /*
2  * Color.h
3  *
4  *  Created on: Sep 1, 2012
5  *      Author: holy
6  */
7
8 #ifndef GRAPHICS_COLOR_H_
9 #define GRAPHICS_COLOR_H_
10
11 #include <SDL.h>
12
13 namespace graphics {
14
15 class Color {
16
17 public:
18         Color() :r(0), g(0), b(0), a(255) { }
19         Color(Uint8 r, Uint8 g, Uint8 b, Uint8 a = 255) : r(r), g(g), b(b), a(a) { }
20
21 public:
22         Uint8 RedChannel() const { return r; }
23         Uint8 GreenChannel() const { return g; }
24         Uint8 BlueChannel() const { return b; }
25         Uint8 AlphaChannel() const { return a; }
26
27         Uint32 MapRGB(SDL_PixelFormat *f) const { return SDL_MapRGB(f, r, g, b); }
28         Uint32 MapRGBA(SDL_PixelFormat *f) const { return SDL_MapRGBA(f, r, g, b, a); }
29
30         void SetRedChannel(Uint8 i) { r = i; }
31         void SetGreenChannel(Uint8 i) { g = i; }
32         void SetBlueChannel(Uint8 i) { b = i; }
33         void SetAlphaChannel(Uint8 i) { a = i; }
34
35 private:
36         Uint8 r, g, b, a;
37
38 };
39
40 }
41
42 #endif /* GRAPHICS_COLOR_H_ */