1 #ifndef TERMOX_TERMINAL_DETAIL_CANVAS_HPP
2 #define TERMOX_TERMINAL_DETAIL_CANVAS_HPP
8 #include <termox/painter/color.hpp>
9 #include <termox/painter/glyph.hpp>
10 #include <termox/widget/area.hpp>
11 #include <termox/widget/point.hpp>
13 namespace ox::detail {
20 using Buffer_t = std::vector<Glyph>;
24 using Diff = std::vector<std::pair<ox::Point, ox::Glyph>>;
32 [[nodiscard]]
auto area() const -> ox::Area;
35 [[nodiscard]] auto
at(ox::Point p) const -> ox::
Glyph;
38 [[nodiscard]] auto
at(ox::Point p) -> ox::
Glyph&;
47 [[nodiscard]] auto
begin() -> Buffer_t::iterator;
50 [[nodiscard]] auto
begin() const -> Buffer_t::const_iterator;
53 [[nodiscard]] auto
end() -> Buffer_t::iterator;
56 [[nodiscard]] auto
end() const -> Buffer_t::const_iterator;
65 std::unique_ptr<
Canvas> resize_buffer_ =
nullptr;
80 void merge_and_diff(
Canvas const& next,
88 void generate_color_diff(
Color color,
97 auto print(
Canvas::
Diff const& diff, std::ostream& os) -> std::ostream&;
Color numbers [0 - 180] are valid.
Definition: color.hpp:16
A 2D field of Glyphs, useful as a screen buffer.
Definition: canvas.hpp:18
auto begin() -> Buffer_t::iterator
Return begin iterator to internal buffer.
Definition: canvas.cpp:71
void resize(ox::Area a)
Resize the Canvas to the given Area a.
Definition: canvas.cpp:55
std::vector< std::pair< ox::Point, ox::Glyph > > Diff
Type used to model differences between two Canvas objects.
Definition: canvas.hpp:24
auto end() -> Buffer_t::iterator
Return end iterator to internal buffer.
Definition: canvas.cpp:78
auto at(ox::Point p) const -> ox::Glyph
Return the Glyph at Point p.
Definition: canvas.cpp:41
Canvas(ox::Area a)
Construct a new Canvas with Area of a.
Definition: canvas.cpp:36
auto area() const -> ox::Area
Return the current size of the Canvas.
Definition: canvas.cpp:39
void reset()
Sets all Glyphs to default construction.
Definition: canvas.cpp:85
Holds a description of a paintable tile on the screen.
Definition: glyph.hpp:11