]> git.tdb.fi Git - libs/gl.git/blob - source/color.h
2c48cd494bbcae09e080e963f1b8d9634c67d839
[libs/gl.git] / source / color.h
1 /* $Id$
2
3 This file is part of libmspgl
4 Copyright © 2007  Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
6 */
7
8 #ifndef MSP_GL_COLOR_H_
9 #define MSP_GL_COLOR_H_
10
11 namespace Msp {
12 namespace GL {
13
14 struct Color
15 {
16         float r, g, b, a;
17
18         Color(): r(1), g(1), b(1), a(1) { }
19         Color(float v): r(v), g(v), b(v), a(1) { }
20         Color(float r_, float g_, float b_): r(r_), g(g_), b(b_), a(1) { }
21         Color(float r_, float g_, float b_, float a_): r(r_), g(g_), b(b_), a(a_) { }
22         Color operator*(float f) const { return Color(r*f, g*f, b*f, a); }
23         Color operator+(const Color &c) const { return Color(r+c.r, g+c.g, b+c.g, 1-(1-a)*(1-c.a)); }
24         bool operator==(const Color &c) const { return (r==c.r && b==c.b && g==c.g && a==c.a); }
25         bool operator!=(const Color &c) const { return !operator==(c); }
26 };
27
28 } // namespace GL
29 } // namespace Msp
30
31 #endif