STLL  0.0
Simple Text Layouting Library
color.h
Go to the documentation of this file.
1 /*
2  * STLL Simple Text Layouting Library
3  *
4  * STLL is the legal property of its developers, whose
5  * names are listed in the COPYRIGHT file, which is included
6  * within the source distribution.
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public License
10  * as published by the Free Software Foundation; either version 2.1
11  * of the License, or (at your option) any later version.
12 
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17 
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21  */
22 #ifndef STLL_COLOR_H
23 #define STLL_COLOR_H
24 
25 #include <cstdint>
26 
31 namespace STLL {
32 
36 class Color_c
37 {
38  private:
39  uint8_t val[4];
40 
41  public:
42 
44  Color_c(void) : val{0, 0, 0, 0} {}
45 
47  Color_c(uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255) : val{r, g, b, a} {}
48 
49 
50  uint8_t r(void) const { return val[0]; }
51  uint8_t g(void) const { return val[1]; }
52  uint8_t b(void) const { return val[2]; }
53  uint8_t a(void) const { return val[3]; }
54 
56  bool operator== (const Color_c & rhs) const
57  {
58  return (val[0] == rhs.val[0]) && (val[1] == rhs.val[1]) &&
59  (val[2] == rhs.val[2]) && (val[3] == rhs.val[3]);
60  }
61 
63  void operator= (const Color_c & rhs)
64  {
65  val[0] = rhs.val[0];
66  val[1] = rhs.val[1];
67  val[2] = rhs.val[2];
68  val[3] = rhs.val[3];
69  }
70 };
71 
72 }
73 
74 #endif
uint8_t r(void) const
get the r value of the colour
Definition: color.h:50
a little class representing an RGBA colour value, an a value of 255 is assumed to be opaque ...
Definition: color.h:36
void operator=(const Color_c &rhs)
Definition: color.h:63
uint8_t a(void) const
get the a value of the colour
Definition: color.h:53
Color_c(void)
Definition: color.h:44
The namespace for the library. Every function and class is within this namespace. ...
Definition: color.h:31
uint8_t g(void) const
get the g value of the colour
Definition: color.h:51
uint8_t b(void) const
get the b value of the colour
Definition: color.h:52
bool operator==(const Color_c &rhs) const
Definition: color.h:56
Color_c(uint8_t r, uint8_t g, uint8_t b, uint8_t a=255)
Definition: color.h:47