Geogram  Version 1.9.1
A programming library of geometric algorithms
color.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2000-2022 Inria
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * * Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  * * Redistributions in binary form must reproduce the above copyright notice,
11  * this list of conditions and the following disclaimer in the documentation
12  * and/or other materials provided with the distribution.
13  * * Neither the name of the ALICE Project-Team nor the names of its
14  * contributors may be used to endorse or promote products derived from this
15  * software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
21  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27  * POSSIBILITY OF SUCH DAMAGE.
28  *
29  * Contact: Bruno Levy
30  *
31  * https://www.inria.fr/fr/bruno-levy
32  *
33  * Inria,
34  * Domaine de Voluceau,
35  * 78150 Le Chesnay - Rocquencourt
36  * FRANCE
37  *
38  */
39 
40 
41 #ifndef H_OGF_IMAGE_TYPES_COLOR_H
42 #define H_OGF_IMAGE_TYPES_COLOR_H
43 
44 #include <geogram/basic/common.h>
45 #include <geogram/basic/geometry.h>
46 
51 namespace GEO {
52 
57  template <class T> class GenColor : public vecng<4,T> {
58  public:
63 
68  inline GenColor(const superclass& rhs) : superclass(rhs) {
69  }
70 
75  inline GenColor(const T* rhs) : superclass(rhs) {
76  }
77 
82  inline GenColor(
83  T r=0, T g=0, T b=0, T a=1
84  ):superclass(r,g,b,a) {
85  }
86 
92  inline GenColor& operator=(const superclass& rhs) {
93  superclass::operator=(rhs);
94  return *this;
95  }
96 
101  T r() const {
102  return superclass::x;
103  }
104 
109  T g() const {
110  return superclass::y;
111  }
112 
117  T b() const {
118  return superclass::z;
119  }
120 
125  T a() const {
126  return superclass::w;
127  }
128 
133  void set_r(T r) {
134  superclass::x = r;
135  }
136 
141  void set_g(T g) {
142  superclass::y = g;
143  }
144 
149  void set_b(T b) {
150  superclass::z = b;
151  }
152 
157  void set_a(T a) {
158  superclass::w = a;
159  }
160 
161  };
162 
169 }
170 
171 #endif
A generic color type.
Definition: color.h:57
vecng< 4, T > superclass
The superclass type.
Definition: color.h:62
T a() const
Gets the alpha component (transparency).
Definition: color.h:125
T g() const
Gets the green component.
Definition: color.h:109
GenColor & operator=(const superclass &rhs)
assignment operator.
Definition: color.h:92
GenColor(T r=0, T g=0, T b=0, T a=1)
GenColor constructor from 4 parameters.
Definition: color.h:82
void set_r(T r)
Sets the red component.
Definition: color.h:133
void set_b(T b)
Sets the blue component.
Definition: color.h:149
void set_a(T a)
Sets the alpha component (transparency).
Definition: color.h:157
T r() const
Gets the red component.
Definition: color.h:101
void set_g(T g)
Sets the green component.
Definition: color.h:141
GenColor(const T *rhs)
GenColor constructor from T array.
Definition: color.h:75
T b() const
Gets the blue component.
Definition: color.h:117
GenColor(const superclass &rhs)
GenColor copy constructor.
Definition: color.h:68
Specialization of class vecn3 for DIM == 4.
Definition: vecg.h:958
T w
Vector w coordinate.
Definition: vecg.h:1139
T x
Vector x coordinate.
Definition: vecg.h:1133
T y
Vector y coordinate.
Definition: vecg.h:1135
T z
Vector z coordinate.
Definition: vecg.h:1137
Generic maths vector.
Definition: vecg.h:70
Common include file, providing basic definitions. Should be included before anything else by all head...
Geometric functions in 2d and 3d.
Global Vorpaline namespace.
Definition: basic.h:55
GenColor< Numeric::float64 > Color
Default representation of colors.
Definition: color.h:168