ManaPlus
dyecolor.h
Go to the documentation of this file.
1 /*
2  * The ManaPlus Client
3  * Copyright (C) 2013-2019 The ManaPlus Developers
4  * Copyright (C) 2019-2021 Andrei Karas
5  *
6  * This file is part of The ManaPlus Client.
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * 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, see <http://www.gnu.org/licenses/>.
20  */
21 
22 #ifndef RESOURCES_DYE_DYECOLOR_H
23 #define RESOURCES_DYE_DYECOLOR_H
24 
25 #include "utils/buildhex.h"
26 
27 #include "localconsts.h"
28 
30 {
32  valueA(buildHex(0, 0, 0, 255)),
33  valueS(buildHex(0, 0, 0, 0)),
34  valueSOgl(buildHexOgl(0, 0, 0, 0))
35  {
36  value[3] = 255;
37  }
38 
39  DyeColor(const uint8_t r,
40  const uint8_t g,
41  const uint8_t b) noexcept2 :
42  valueA(buildHex(r, g, b, 255)),
43  valueS(buildHex(r, g, b, 0)),
44  valueSOgl(buildHexOgl(0, b, g, r))
45  {
46  value[0] = r;
47  value[1] = g;
48  value[2] = b;
49  value[3] = 255;
50  }
51 
52  DyeColor(const uint8_t r,
53  const uint8_t g,
54  const uint8_t b,
55  const uint8_t a) noexcept2 :
56  valueA(buildHex(r, g, b, a)),
57  valueS(buildHex(r, g, b, 0)),
58  valueSOgl(buildHexOgl(0, b, g, r))
59  {
60  value[0] = r;
61  value[1] = g;
62  value[2] = b;
63  value[3] = a;
64  }
65 
67 
68  void update()
69  {
70  valueA = buildHex(value[0], value[1], value[2], value[3]);
71  valueS = buildHex(value[0], value[1], value[2], 0);
72  valueSOgl = buildHexOgl(0, value[2], value[1], value[0]);
73  }
74 
75  union
76  {
77  uint8_t value[4];
78  uint32_t valueAOgl;
79  };
80  uint32_t valueA;
81  uint32_t valueS;
82  uint32_t valueSOgl;
83 };
84 
85 #endif // RESOURCES_DYE_DYECOLOR_H
#define buildHex(a, b, c, d)
Definition: buildhex.h:42
#define buildHexOgl(a, b, c, d)
Definition: buildhex.h:46
#define noexcept2
Definition: localconsts.h:50
#define final
Definition: localconsts.h:46
#define A_DEFAULT_COPY(func)
Definition: localconsts.h:41
uint32_t valueSOgl
Definition: dyecolor.h:82
uint8_t value[4]
Definition: dyecolor.h:77
DyeColor()
Definition: dyecolor.h:31
uint32_t valueS
Definition: dyecolor.h:81
uint32_t valueA
Definition: dyecolor.h:80
uint32_t valueAOgl
Definition: dyecolor.h:78
DyeColor(const uint8_t r, const uint8_t g, const uint8_t b, const uint8_t a)
Definition: dyecolor.h:52
void update()
Definition: dyecolor.h:68
DyeColor(const uint8_t r, const uint8_t g, const uint8_t b)
Definition: dyecolor.h:39