diff --git a/include/image.h b/include/image.h index 7ad6ca7..926e47e 100644 --- a/include/image.h +++ b/include/image.h @@ -9,13 +9,9 @@ public: array = {}; } - T& get(const int32_t x, const int32_t y) { - return array[y * Width + x]; + decltype(auto) operator[](this auto& self, const int32_t x, const int32_t y) { + return self.array[y * Width + x]; } - T get(const int32_t x, const int32_t y) const { - return array[y * Width + x]; - } - - std::array array = {}; + std::array array = {}; }; diff --git a/src/main.cpp b/src/main.cpp index 13e6033..126d1c2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -74,7 +74,7 @@ bool calculate_tile(const int32_t from_x, const int32_t to_width, const int32_t break; } - colors.get(x, y) = glm::vec4(chosen_display, 1.0f); + colors[x, y] = glm::vec4(chosen_display, 1.0f); image_dirty = true; } @@ -189,7 +189,7 @@ void dump_to_file() { int i = 0; for (int32_t y = height - 1; y >= 0; y--) { for (int32_t x = 0; x < width; x++) { - const glm::ivec4 c = colors.get(x, y); + const glm::ivec4 c = colors[x, y]; pixels[i++] = c.r; pixels[i++] = c.g; pixels[i++] = c.b;