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 porytiles2 {
8
9[[nodiscard]] bool Rgba32::is_transparent(const Rgba32 &extrinsic) const
10{
11 if (alpha_ == alpha_transparent) {
12 return true;
13 }
14
15 return extrinsic.equals_ignoring_alpha(*this);
16}
17
18std::string Rgba32::to_jasc_str() const
19{
20 return std::to_string(red_) + " " + std::to_string(green_) + " " + std::to_string(blue_);
21}
22
23bool Rgba32::equals_ignoring_alpha(const Rgba32 &other) const
24{
25 return red_ == other.red_ && green_ == other.green_ && blue_ == other.blue_;
26}
27
28// std::ostream &operator<<(std::ostream &os, const Rgba32 &rgba) {
29// // For debugging purposes, print the solid colors with names rather than
30// int values if (rgba == kRgbaBlack || rgba == bgrToRgba(BGR_BLACK)) {
31// os << "black";
32// } else if (rgba == kRgbaRed || rgba == bgrToRgba(BGR_RED)) {
33// os << "red";
34// } else if (rgba == kRgbaGreen || rgba == bgrToRgba(BGR_GREEN)) {
35// os << "green";
36// } else if (rgba == kRgbaBlue || rgba == bgrToRgba(BGR_BLUE)) {
37// os << "blue";
38// } else if (rgba == kRgbaYellow || rgba == bgrToRgba(BGR_YELLOW)) {
39// os << "yellow";
40// } else if (rgba == kRgbaMagenta || rgba == bgrToRgba(BGR_MAGENTA)) {
41// os << "magenta";
42// } else if (rgba == kRgbaCyan || rgba == bgrToRgba(BGR_CYAN)) {
43// os << "cyan";
44// } else if (rgba == kRgbaWhite || rgba == bgrToRgba(BGR_WHITE)) {
45// os << "white";
46// } else if (rgba == kRgbaGrey || rgba == bgrToRgba(BGR_GREY)) {
47// os << "grey";
48// } else if (rgba == kRgbaPurple || rgba == bgrToRgba(BGR_PURPLE)) {
49// os << "purple";
50// } else if (rgba == kRgbaLime || rgba == bgrToRgba(BGR_LIME)) {
51// os << "lime";
52// } else {
53// os << std::to_string(rgba.red()) << "," <<
54// std::to_string(rgba.green()) << "," << std::to_string(rgba.blue());
55// if (rgba.alpha() != 255) {
56// // Only show alpha if not opaque
57// os << "," << std::to_string(rgba.alpha());
58// }
59// }
60// return os;
61// }
62
63} // namespace porytiles2
Represents a 32-bit RGBA color.
Definition rgba32.hpp:21
bool equals_ignoring_alpha(const Rgba32 &other) const
Definition rgba32.cpp:23
std::string to_jasc_str() const
Definition rgba32.cpp:18
static constexpr std::uint8_t alpha_transparent
Definition rgba32.hpp:23
bool is_transparent(const Rgba32 &extrinsic) const
Checks if this color should be treated as transparent.
Definition rgba32.cpp:9