#ifndef PIXEL_MAP_HPP_
#define PIXEL_MAP_HPP_

#include <vector>
#include <cinttypes>
#include <string>

/**
 * @brief Represents an RGBA pixel map.
 *
 * TODO: The new `Bitmap` which I made because I forgot about this is better, we should remove this soon.
 */
class PixelMap
{
public:
    struct Pixel
    {
        uint8_t red;
        uint8_t green;
        uint8_t blue;
        uint8_t alpha;
    };

private:
    int width = 0;
    int height = 0;
    std::vector<Pixel> pixels;

public:
    /**
     * @brief Construct a new pixel map and fill it with a background.
     * 
     * @param width The width of the pixel map.
     * @param height The height of the pixel map.
     * @param background The background to fill with (transparent by default).
     */
    PixelMap(int width, int height, Pixel background = Pixel{0, 0, 0, 0});

    /**
     * @brief Get the pixel at the specified coordinates (must be within bounds).
     */
    Pixel& at(int x, int y);

    /**
     * @brief Fill the specified rectangular area with the specified pixel.
     * 
     * This method does not do alpha blending, only replaces the pixels. The whole
     * rectangle must be within bounds.
     */
    void fillRect(int x, int y, int width, int height, Pixel pixel);

    /**
     * @brief Write this pixel map to a PNG file.
     * 
     * @param path The path to create the file at.
     */
    void writePNG(std::string path);
};

#endif