Porytiles
Loading...
Searching...
No Matches
rgba32.cpp
Go to the documentation of this file.
2
3#include <algorithm>
4#include <set>
5#include <string>
6
7namespace porytiles {
8
9[[nodiscard]] bool Rgba32::is_intrinsically_transparent() const
10{
11 return alpha_ == alpha_transparent;
12}
13
14[[nodiscard]] bool Rgba32::is_extrinsically_transparent(const Rgba32 &extrinsic) const
15{
16 return extrinsic.equals_ignoring_alpha(*this);
17}
18
19[[nodiscard]] bool Rgba32::is_transparent(const Rgba32 &extrinsic) const
20{
22}
23
24std::string Rgba32::to_jasc_str() const
25{
26 return std::to_string(red_) + " " + std::to_string(green_) + " " + std::to_string(blue_);
27}
28
29std::string Rgba32::to_csv_str() const
30{
31 return std::to_string(red_) + ", " + std::to_string(green_) + ", " + std::to_string(blue_);
32}
33
34bool Rgba32::equals_ignoring_alpha(const Rgba32 &other) const
35{
36 return red_ == other.red_ && green_ == other.green_ && blue_ == other.blue_;
37}
38
39// std::ostream &operator<<(std::ostream &os, const Rgba32 &rgba) {
40// // For debugging purposes, print the solid colors with names rather than
41// int values if (rgba == kRgbaBlack || rgba == bgrToRgba(BGR_BLACK)) {
42// os << "black";
43// } else if (rgba == kRgbaRed || rgba == bgrToRgba(BGR_RED)) {
44// os << "red";
45// } else if (rgba == kRgbaGreen || rgba == bgrToRgba(BGR_GREEN)) {
46// os << "green";
47// } else if (rgba == kRgbaBlue || rgba == bgrToRgba(BGR_BLUE)) {
48// os << "blue";
49// } else if (rgba == kRgbaYellow || rgba == bgrToRgba(BGR_YELLOW)) {
50// os << "yellow";
51// } else if (rgba == kRgbaMagenta || rgba == bgrToRgba(BGR_MAGENTA)) {
52// os << "magenta";
53// } else if (rgba == kRgbaCyan || rgba == bgrToRgba(BGR_CYAN)) {
54// os << "cyan";
55// } else if (rgba == kRgbaWhite || rgba == bgrToRgba(BGR_WHITE)) {
56// os << "white";
57// } else if (rgba == kRgbaGrey || rgba == bgrToRgba(BGR_GREY)) {
58// os << "grey";
59// } else if (rgba == kRgbaPurple || rgba == bgrToRgba(BGR_PURPLE)) {
60// os << "purple";
61// } else if (rgba == kRgbaLime || rgba == bgrToRgba(BGR_LIME)) {
62// os << "lime";
63// } else {
64// os << std::to_string(rgba.red()) << "," <<
65// std::to_string(rgba.green()) << "," << std::to_string(rgba.blue());
66// if (rgba.alpha() != 255) {
67// // Only show alpha if not opaque
68// os << "," << std::to_string(rgba.alpha());
69// }
70// }
71// return os;
72// }
73
74} // namespace porytiles
Represents a 32-bit RGBA color.
Definition rgba32.hpp:23
std::string to_csv_str() const
Definition rgba32.cpp:29
static constexpr std::uint8_t alpha_transparent
Definition rgba32.hpp:25
bool is_intrinsically_transparent() const
Checks if this color is intrinsically transparent based on its alpha channel.
Definition rgba32.cpp:9
bool is_transparent(const Rgba32 &extrinsic) const
Checks if this color should be treated as transparent.
Definition rgba32.cpp:19
bool equals_ignoring_alpha(const Rgba32 &other) const
Definition rgba32.cpp:34
bool is_extrinsically_transparent(const Rgba32 &extrinsic) const
Checks if this color matches the extrinsic transparency color.
Definition rgba32.cpp:14
std::string to_jasc_str() const
Definition rgba32.cpp:24