TermOx
glyph_matrix.hpp
1 #ifndef TERMOX_PAINTER_GLYPH_MATRIX_HPP
2 #define TERMOX_PAINTER_GLYPH_MATRIX_HPP
3 #include <vector>
4 
5 #include <termox/painter/glyph.hpp>
6 #include <termox/widget/area.hpp>
7 #include <termox/widget/point.hpp>
8 
9 namespace ox {
10 
12 class Glyph_matrix {
13  public:
15 
16  explicit Glyph_matrix(Area area);
17 
18  public:
20 
22  void resize(Area area);
23 
25  void clear();
26 
28  [[nodiscard]] auto width() const -> int;
29 
31  [[nodiscard]] auto height() const -> int;
32 
34 
35  [[nodiscard]] auto operator()(Point p) -> Glyph&;
36 
38 
39  [[nodiscard]] auto operator()(Point p) const -> Glyph;
40 
42 
43  [[nodiscard]] auto at(Point p) -> Glyph&;
44 
46 
47  [[nodiscard]] auto at(Point p) const -> Glyph;
48 
49  private:
50  std::vector<std::vector<Glyph>> matrix_;
51 };
52 
53 } // namespace ox
54 #endif // TERMOX_PAINTER_GLYPH_MATRIX_HPP
Holds a matrix of Glyphs, provides simple access by indices.
Definition: glyph_matrix.hpp:12
auto at(Point p) -> Glyph &
Glyph access operator. {0, 0} is top left. x grows south and y east.
Definition: glyph_matrix.cpp:41
void clear()
Remove all Glyphs from the matrix and set width/height to 0.
Definition: glyph_matrix.cpp:25
Glyph_matrix(Area area)
Construct with a set width and height, or defaults to 0 for each.
Definition: glyph_matrix.cpp:11
auto width() const -> int
Return the width of the matrix.
Definition: glyph_matrix.cpp:27
auto operator()(Point p) -> Glyph &
Glyph access operator. {0, 0} is top left. x grows south and y east.
Definition: glyph_matrix.cpp:34
void resize(Area area)
Resize the width and height of the matrix.
Definition: glyph_matrix.cpp:15
auto height() const -> int
Return the height of the matrix.
Definition: glyph_matrix.cpp:32
Holds a description of a paintable tile on the screen.
Definition: glyph.hpp:11