Files
ThreeAM/grid.hpp
2024-01-16 14:21:54 -06:00

60 lines
1.8 KiB
C++

#ifndef H_89BCEB17FBD94DE38B501C2F028FDF35
#define H_89BCEB17FBD94DE38B501C2F028FDF35
#include "colors.hpp"
template <int Size>
class Grid
{
static_assert(Size % 2 == 0);
static constexpr int pixels = Size*Size;
std::array<BigPixel, pixels> data;
public:
static constexpr std::array<int, pixels/4> quad1()
{
std::array<int, pixels/4> q;
for (int i = 0; i < Size/2; i++)
for (int j = 0; j < Size/2; j++)
{
const int count = i * Size/2 + j;
q[count] = i * Size + j;
}
return q;
}
static constexpr std::array<int, pixels/4> quad2()
{
std::array<int, pixels/4> q;
for (int i = 0; i < Size/2; i++)
for (int j = 0; j < Size/2; j++)
{
const int count = i * Size/2 + j;
q[count] = (Size - i - 1) * Size + j;
}
return q;
}
static constexpr std::array<int, pixels/4> quad3()
{
std::array<int, pixels/4> q;
for (int i = 0; i < Size/2; i++)
for (int j = 0; j < Size/2; j++)
{
const int count = i * Size/2 + j;
q[count] = i * Size + j;
}
return q;
}
static constexpr std::array<int, pixels/4> quad4()
{
std::array<int, pixels/4> q;
for (int i = 0; i < Size/2; i++)
for (int j = 0; j < Size/2; j++)
{
const int count = i * Size/2 + j;
q[count] = (Size - i - 1) * Size + (Size - j - 1);
}
return q;
}
};
#endif //H_89BCEB17FBD94DE38B501C2F028FDF35