aGrUM
3.3.2
a C++ library for (probabilistic) graphical models
Toggle main menu visibility
dotColor.h
Go to the documentation of this file.
1
/****************************************************************************
2
* This file is part of the aGrUM/pyAgrum library. *
3
* *
4
* Copyright (c) 2005-2026 by *
5
* - Pierre-Henri WUILLEMIN(_at_LIP6) *
6
* - Christophe GONZALES(_at_AMU) *
7
* *
8
* The aGrUM/pyAgrum library is free software; you can redistribute it *
9
* and/or modify it under the terms of either : *
10
* *
11
* - the GNU Lesser General Public License as published by *
12
* the Free Software Foundation, either version 3 of the License, *
13
* or (at your option) any later version, *
14
* - the MIT license (MIT), *
15
* - or both in dual license, as here. *
16
* *
17
* (see https://agrum.gitlab.io/articles/dual-licenses-lgplv3mit.html) *
18
* *
19
* This aGrUM/pyAgrum library is distributed in the hope that it will be *
20
* useful, but WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
21
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES MERCHANTABILITY or FITNESS *
22
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
23
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
24
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
25
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR *
26
* OTHER DEALINGS IN THE SOFTWARE. *
27
* *
28
* See LICENCES for more details. *
29
* *
30
* SPDX-FileCopyrightText: Copyright 2005-2026 *
31
* - Pierre-Henri WUILLEMIN(_at_LIP6) *
32
* - Christophe GONZALES(_at_AMU) *
33
* SPDX-License-Identifier: LGPL-3.0-or-later OR MIT *
34
* *
35
* Contact : info_at_agrum_dot_org *
36
* homepage : http://agrum.gitlab.io *
37
* gitlab : https://gitlab.com/agrumery/agrum *
38
* *
39
****************************************************************************/
40
48
#ifndef GUM_DOT_COLOR_H
49
#define GUM_DOT_COLOR_H
50
51
#include <string>
52
53
#include <
agrum/agrum.h
>
54
55
#include <string_view>
56
57
namespace
gum::dot
{
58
60
struct
Rgb
{
61
unsigned
char
red
;
62
unsigned
char
green
;
63
unsigned
char
blue
;
64
};
65
68
inline
constexpr
std::string_view
ADAPTIVE_COLOR
=
"adaptive"
;
69
82
GUM_SHARED_PUBLIC
bool
parseColor
(std::string_view color,
Rgb
& rgb);
83
88
GUM_SHARED_PUBLIC
double
brightness
(
const
Rgb
& rgb);
89
94
GUM_SHARED_PUBLIC std::string
contrastColor
(
const
Rgb
& rgb);
95
107
GUM_SHARED_PUBLIC std::string
108
resolveFgColor
(std::string_view fgColor, std::string_view bgColor, std::string_view fallback);
109
110
}
// namespace gum::dot
111
112
#endif
// GUM_DOT_COLOR_H
agrum.h
gum::dot
Definition
dotColor.cpp:55
gum::dot::ADAPTIVE_COLOR
constexpr std::string_view ADAPTIVE_COLOR
the special value of a font color: black or white, according to the brightness of the background
Definition
dotColor.h:68
gum::dot::resolveFgColor
std::string resolveFgColor(std::string_view fgColor, std::string_view bgColor, std::string_view fallback)
The font color to use on a background, once the special value adaptive is resolved.
Definition
dotColor.cpp:280
gum::dot::brightness
double brightness(const Rgb &rgb)
Perceived brightness of a color, between 0 (black) and 255 (white): 0.299 R + 0.587 G + 0....
Definition
dotColor.cpp:274
gum::dot::parseColor
bool parseColor(std::string_view color, Rgb &rgb)
Reads a color as it is written in a dot attribute.
Definition
dotColor.cpp:245
gum::dot::contrastColor
std::string contrastColor(const Rgb &rgb)
The text color which is readable on a background: white if its brightness is at most 153,...
Definition
dotColor.cpp:276
gum::dot::Rgb
a color given by its three components, each one between 0 and 255
Definition
dotColor.h:60
gum::dot::Rgb::red
unsigned char red
Definition
dotColor.h:61
gum::dot::Rgb::green
unsigned char green
Definition
dotColor.h:62
gum::dot::Rgb::blue
unsigned char blue
Definition
dotColor.h:63
aGrUM
3.3.2
© PHW&CG&others - 2022
DoXyGeN 1.18.0