diff options
author | HampusM <hampus@hampusmat.com> | 2022-02-27 17:12:49 +0100 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2022-06-13 17:56:53 +0200 |
commit | fe79577396231f2edb7927f1f61ce814f03851a7 (patch) | |
tree | d353a1caa449ec772dcf9a8681084fc2d6e64116 /src/engine/graphics/string_matrix.cpp | |
parent | 6964d48c970e5f7b11897096c816271785af23ac (diff) |
add basic engine graphics
Diffstat (limited to 'src/engine/graphics/string_matrix.cpp')
-rw-r--r-- | src/engine/graphics/string_matrix.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/engine/graphics/string_matrix.cpp b/src/engine/graphics/string_matrix.cpp new file mode 100644 index 0000000..e259e96 --- /dev/null +++ b/src/engine/graphics/string_matrix.cpp @@ -0,0 +1,41 @@ +#include "string_matrix.hpp" + +StringMatrix::StringMatrix(const IBounds &bounds) + : _rows(bounds.height()), _columns(bounds.width()) +{ + _matrix.reserve(bounds.height()); + _matrix.assign(_matrix.capacity(), std::vector<std::string_view>(bounds.width())); +}; + +void StringMatrix::fill(std::string_view element) +{ + for (unsigned int row = 0U; row < _matrix.capacity(); row++) + { + std::vector<std::string_view> row_vector = _matrix[row]; + + for (unsigned int column = 0U; column < row_vector.capacity(); column++) + { + _matrix[row][column] = element; + } + } +} + +std::string_view StringMatrix::get(const IVector2 &pos) const +{ + return _matrix[pos.y()][pos.x()]; +} + +void StringMatrix::set(const IVector2 &pos, std::string_view element) +{ + _matrix[pos.y()][pos.x()] = element; +} + +unsigned int StringMatrix::rows() const +{ + return _rows; +} + +unsigned int StringMatrix::columns() const +{ + return _columns; +} |