GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/resources/dye/dyecolor.h Lines: 14 14 100.0 %
Date: 2021-03-17 Branches: 0 0 0.0 %

Line Branch Exec Source
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
29
struct DyeColor final
30
{
31
192
    DyeColor() noexcept2 :
32
        valueA(buildHex(0, 0, 0, 255)),
33
        valueS(buildHex(0, 0, 0, 0)),
34
192
        valueSOgl(buildHexOgl(0, 0, 0, 0))
35
    {
36
192
        value[3] = 255;
37
    }
38
39
    DyeColor(const uint8_t r,
40
             const uint8_t g,
41
             const uint8_t b) noexcept2 :
42
192
        valueA(buildHex(r, g, b, 255)),
43
        valueS(buildHex(r, g, b, 0)),
44
192
        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
4137
             const uint8_t a) noexcept2 :
56
        valueA(buildHex(r, g, b, a)),
57
        valueS(buildHex(r, g, b, 0)),
58
4137
        valueSOgl(buildHexOgl(0, b, g, r))
59
    {
60
4137
        value[0] = r;
61
4137
        value[1] = g;
62
4137
        value[2] = b;
63
4137
        value[3] = a;
64
    }
65
66
    A_DEFAULT_COPY(DyeColor)
67
68
    void update()
69
    {
70
4137
        valueA = buildHex(value[0], value[1], value[2], value[3]);
71
4137
        valueS = buildHex(value[0], value[1], value[2], 0);
72
4137
        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