Porytiles
Loading...
Searching...
No Matches
index_pixel.hpp
Go to the documentation of this file.
1#pragma once
2
3// ReSharper disable once CppUnusedIncludeDirective
4#include <compare>
5#include <set>
6
8
9namespace porytiles2 {
10
22 public:
23 IndexPixel() : index_{0} {}
24
25 // NOLINTNEXTLINE(google-explicit-constructor)
26 IndexPixel(unsigned int index) : index_{index}
27 {
28 // TODO: don't hardcode 16 here
29 // if (index_ >= 16) {
30 // panic("invalid IndexPixel value: " + std::to_string(index_));
31 // }
32 }
33
34 bool operator==(const IndexPixel &other) const = default;
35
36 auto operator<=>(const IndexPixel &) const = default;
37
46 [[nodiscard]] bool is_transparent() const
47 {
48 return index_ == 0;
49 }
50
51 [[nodiscard]] unsigned int index() const
52 {
53 return index_;
54 }
55
56 private:
57 unsigned int index_;
58};
59
60} // namespace porytiles2
Represents an indexed color pixel.
bool is_transparent() const
Checks if this indexed pixel is transparent.
IndexPixel(unsigned int index)
auto operator<=>(const IndexPixel &) const =default
bool operator==(const IndexPixel &other) const =default
unsigned int index() const