Skip to content
Snippets Groups Projects
Commit 3fd246bb authored by namark's avatar namark
Browse files

Basic fill algorithm for pixel_writer.

parent 9e50e6b6
No related branches found
No related tags found
No related merge requests found
#include "simple/sdlcore/utils.hpp"
#include "fill.h"
#include "fill.hpp"
#include "../surface.h"
#include "../renderer.h"
......@@ -42,4 +42,28 @@ namespace simple::graphical
return fill(rend, area);
}
void fill(pixel_writer_variant writer, color color)
{
std::visit([&color](auto&& writer)
{
fill_color(writer, color);
}, writer);
}
// hmmm... is this guaranteed to work?
[[maybe_unused]]
void instantiate_fill(pixel_writer_variant var)
{
std::visit([](auto writer)
{
fill(writer, typename decltype(writer)::pixel_type{});
}, var);
}
// template void fill<rgba_pixel, pixel_byte>(const pixel_writer<rgba_pixel, pixel_byte>&, rgba_pixel);
// template void fill<rgb_pixel, pixel_byte>(const pixel_writer<rgb_pixel, pixel_byte>&, rgb_pixel);
// template void fill<uint16_t, pixel_byte>(const pixel_writer<uint16_t, pixel_byte>&, uint16_t);
// template void fill<pixel_byte, pixel_byte>(const pixel_writer<pixel_byte, pixel_byte>&, pixel_byte);
} // namespace simple::graphical
......@@ -3,17 +3,24 @@
#include "../common_def.h"
#include "../color.h"
#include "../pixels.h"
namespace simple::graphical
{
class surface;
class renderer;
bool fill(const surface& surf, color col);
bool fill(const surface& surf, color col, const range2D& area);
bool fill(const surface& surf, color);
bool fill(const surface& surf, color, const range2D&);
bool fill(const renderer& rend);
bool fill(const renderer& rend, const rgba_pixel& color);
bool fill(const renderer& rend, const range2D& area);
bool fill(const renderer& rend, const rgba_pixel& color, const range2D& area);
bool fill(const renderer& rend, const rgba_pixel&);
bool fill(const renderer& rend, const range2D&);
bool fill(const renderer& rend, const rgba_pixel&, const range2D& area);
template <typename Pixel, typename RawType>
void fill(const pixel_writer<Pixel,RawType>&, Pixel);
void fill(pixel_writer_variant, color);
} // namespace simple::graphical
......
#include "fill.h"
namespace simple::graphical
{
template <typename Pixel, typename RawType, typename Color>
void fill_color(const pixel_writer<Pixel, RawType>& writer, Color color)
{
for(int2 i = int2::zero(), size = writer.size(); i.y() < size.y(); ++i.y())
for(i.x() = 0; i.x() < size.x(); ++i.x())
writer.set(color, i);
}
template <typename Pixel, typename RawType>
void fill(const pixel_writer<Pixel, RawType>& writer, Pixel pixel)
{
fill_color(writer, pixel);
}
} // namespace simple::graphical
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment