16 #ifndef OSMANIP_GRAPHICS_CANVAS_HPP
17 #define OSMANIP_GRAPHICS_CANVAS_HPP
26 #include <string_view>
56 explicit Canvas(uint32_t width, uint32_t height);
76 void put(uint32_t x, uint32_t y,
char c, std::string_view
feat =
"");
84 std::string frame_feat_;
87 std::vector<char> char_buffer_;
88 std::vector<std::string> feat_buffer_;
92 static const std::vector<std::vector<std::string>> frames;
Instances of this class are used to draw in a limited 2D space. All the functions that modify the can...
Definition: canvas.hpp:52
void clear()
Fill the canvas with the background.
Definition: canvas.cpp:186
uint32_t width_
Definition: canvas.hpp:100
std::string getBackgroundFeat() const
Get the optional feat of the background.
Definition: canvas.cpp:143
uint32_t getHeight() const
Get the height of the canvas.
Definition: canvas.cpp:127
uint32_t height_
Definition: canvas.hpp:100
std::string getFrameFeat() const
Get the frame feature (if set).
Definition: canvas.cpp:151
uint32_t getWidth() const
Get the width of the canvas.
Definition: canvas.cpp:119
void setBackground(char c, std::string_view feat="")
Set the char that fills the background and an optional feat.
Definition: canvas.cpp:70
bool isFrameEnabled() const
Return True if the frame is enabled. Otherwise return False.
Definition: canvas.cpp:180
Canvas(uint32_t width, uint32_t height)
Construct a new Canvas:: Canvas object. The size of the canvas in characters must be specified upon c...
Definition: canvas.cpp:53
void setFrame(FrameStyle, std::string_view feat="")
Set the FrameStyle of the canvas and an optional feat.
Definition: canvas.cpp:82
void enableFrame(bool frame_enabled)
Flag to frame or not the canvas. The frame doesn't increase the size taken by the canvas....
Definition: canvas.cpp:172
char getBackground() const
Get the char that fills the background.
Definition: canvas.cpp:135
void put(uint32_t x, uint32_t y, char c, std::string_view feat="")
Put a character in the canvas, given its coordinates and an optional feat. An out-of-bounds exception...
Definition: canvas.cpp:201
FrameStyle getFrameStyle() const
Get the frame style.
Definition: canvas.cpp:159
void setWidth(uint32_t width)
Set the width of the canvas.
Definition: canvas.cpp:93
void refresh()
Display the canvas in the console.
Definition: canvas.cpp:210
void setHeight(uint32_t height)
Set the height of the canvas.
Definition: canvas.cpp:104
Definition: canvas.cpp:30
FrameStyle
Enum class used to define the frame style.
Definition: canvas.hpp:38
@ ASCII
Definition: canvas.hpp:38
@ EMPTY
Definition: canvas.hpp:38
@ BOX
Definition: canvas.hpp:38
const std::string & feat(const std::unordered_map< std::string, std::string > &generic_map, const std::string &feat_string)
It takes an std::map object as the first argument and an std::string object (map key) as the second a...
Definition: common.cpp:41