29 lines
732 B
C++
29 lines
732 B
C++
#pragma once
|
|
|
|
#include <cstddef>
|
|
#include <filesystem>
|
|
#include <fstream>
|
|
|
|
#include "renderer.hpp"
|
|
#include "bitmap.hpp"
|
|
|
|
class PgmRenderer : public Renderer
|
|
{
|
|
public:
|
|
PgmRenderer(const std::filesystem::path& path, size_t width, size_t height);
|
|
|
|
void DrawLine(const math::Vector& p0, const math::Vector& p1) override;
|
|
void DrawRectangle(const math::Vector& pos, const math::Vector& size, float angle) override;
|
|
void DrawCircle(const math::Vector& center, float radius) override;
|
|
|
|
void Flush() override;
|
|
|
|
~PgmRenderer() override = default;
|
|
|
|
private:
|
|
std::ofstream m_file;
|
|
Bitmap m_bitmap;
|
|
|
|
void RasterizeLine(int x0, int y0, int x1, int y1);
|
|
void RasterizeCircle(int xm, int ym, int r);
|
|
}; |