GCC Code Coverage Report


Directory: src/gate/
File: src/gate/graphics/cxx_colors.cpp
Date: 2025-09-14 13:10:38
Exec Total Coverage
Lines: 8 37 21.6%
Functions: 2 12 16.7%
Branches: 0 6 0.0%

Line Branch Exec Source
1 /* GATE PROJECT LICENSE:
2 +----------------------------------------------------------------------------+
3 | Copyright(c) 2018-2025, Stefan Meislinger <sm@opengate.at> |
4 | All rights reserved. |
5 | |
6 | Redistribution and use in source and binary forms, with or without |
7 | modification, are permitted provided that the following conditions are met:|
8 | |
9 | 1. Redistributions of source code must retain the above copyright notice, |
10 | this list of conditions and the following disclaimer. |
11 | 2. Redistributions in binary form must reproduce the above copyright |
12 | notice, this list of conditions and the following disclaimer in the |
13 | documentation and/or other materials provided with the distribution. |
14 | |
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"|
16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
18 | ARE DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
25 | THE POSSIBILITY OF SUCH DAMAGE. |
26 +----------------------------------------------------------------------------+
27 */
28
29 #include "gate/graphics/colors.hpp"
30 #include "gate/exceptions.hpp"
31 #include "gate/results.hpp"
32
33 namespace gate
34 {
35 namespace graph
36 {
37
38 Color::Color(uint32_t rgba)
39 {
40 this->value.rgba = rgba;
41
42 }
43 32 Color::Color(uint8_t r, uint8_t g, uint8_t b, uint8_t a)
44 {
45 32 this->value.r = r;
46 32 this->value.g = g;
47 32 this->value.b = b;
48 32 this->value.a = a;
49 32 }
50 Color::Color(gate_color_t const& col)
51 : value(col)
52 {
53 }
54
55 gate_color_t* Color::c_impl()
56 {
57 return &this->value;
58 }
59 1 gate_color_t const* Color::c_impl() const
60 {
61 1 return &this->value;
62 }
63
64 gate_color_t* Color::operator->()
65 {
66 return &this->value;
67 }
68 gate_color_t const* Color::operator->() const
69 {
70 return &this->value;
71 }
72
73
74
75 void Color::setOpaque(Color const& color)
76 {
77 gate_color_set_opaque(&this->value, &color.value);
78 }
79 void Color::setOpaque(gate_color_t const& color)
80 {
81 gate_color_set_opaque(&this->value, &color);
82
83 }
84
85 void Color::setTransparent(Color const& color)
86 {
87 gate_color_set_transparent(&this->value, &color.value);
88 }
89 void Color::setTransparent(gate_color_t const& color)
90 {
91 gate_color_set_transparent(&this->value, &color);
92 }
93
94
95 Color Color::parseHex(String const& text)
96 {
97 Color ret;
98 if (0 == gate_color_parse_hex(text.c_str(), text.length(), &ret.value))
99 {
100 GATEXX_RAISE_EXCEPTION(results::InvalidData, "Failed to parse hex color", 0);
101 }
102 return ret;
103 }
104
105 Color const Color::Black = Color(0x00, 0x00, 0x00);
106 Color const Color::Blue = Color(0x00, 0x00, 0x99);
107 Color const Color::Green = Color(0x00, 0x99, 0x00);
108 Color const Color::Cyan = Color(0x00, 0x99, 0x99);
109 Color const Color::Red = Color(0x99, 0x00, 0x00);
110 Color const Color::Magenta = Color(0x99, 0x00, 0x99);
111 Color const Color::Brown = Color(0x99, 0x66, 0x33);
112 Color const Color::LightGray = Color(0x99, 0x99, 0x99);
113 Color const Color::DarkGray = Color(0x66, 0x66, 0x66);
114 Color const Color::BrightBlue = Color(0x66, 0x66, 0xff);
115 Color const Color::BrightGreen = Color(0x66, 0xff, 0x66);
116 Color const Color::BrightCyan = Color(0x66, 0xff, 0xff);
117 Color const Color::BrightRed = Color(0xff, 0x66, 0x66);
118 Color const Color::BrightMagenta = Color(0xff, 0x66, 0xff);
119 Color const Color::Yellow = Color(0xff, 0xff, 0x66);
120 Color const Color::White = Color(0xff, 0xff, 0xff);
121
122
123 } // end of namespace graph
124 } // end of namespace gate
125