Instances of this class are used to draw in a limited 2D space. All the functions that modify the canvas do it internally; to make the changes effective in the console, you must use the refresh method.
More...
#include <canvas.hpp>
|
| Canvas (uint32_t width, uint32_t height) |
| Construct a new Canvas:: Canvas object. The size of the canvas in characters must be specified upon construction. More...
|
|
void | enableFrame (bool frame_enabled) |
| Flag to frame or not the canvas. The frame doesn't increase the size taken by the canvas. Instead, reduces the 2D space to draw in two columns and two rows (used to print the frame itself). More...
|
|
void | setFrame (FrameStyle, std::string_view feat="") |
| Set the FrameStyle of the canvas and an optional feat. More...
|
|
void | setBackground (char c, std::string_view feat="") |
| Set the char that fills the background and an optional feat. More...
|
|
void | setWidth (uint32_t width) |
| Set the width of the canvas. More...
|
|
void | setHeight (uint32_t height) |
| Set the height of the canvas. More...
|
|
char | getBackground () const |
| Get the char that fills the background. More...
|
|
std::string | getBackgroundFeat () const |
| Get the optional feat of the background. More...
|
|
bool | isFrameEnabled () const |
| Return True if the frame is enabled. Otherwise return False. More...
|
|
std::string | getFrameFeat () const |
| Get the frame feature (if set). More...
|
|
FrameStyle | getFrameStyle () const |
| Get the frame style. More...
|
|
uint32_t | getWidth () const |
| Get the width of the canvas. More...
|
|
uint32_t | getHeight () const |
| Get the height of the canvas. More...
|
|
void | clear () |
| Fill the canvas with the background. More...
|
|
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 will be thrown if the coordinates are outside the canvas. More...
|
|
void | refresh () |
| Display the canvas in the console. More...
|
|
Instances of this class are used to draw in a limited 2D space. All the functions that modify the canvas do it internally; to make the changes effective in the console, you must use the refresh method.
◆ Canvas()
osm::Canvas::Canvas |
( |
uint32_t |
width, |
|
|
uint32_t |
height |
|
) |
| |
|
explicit |
Construct a new Canvas:: Canvas object. The size of the canvas in characters must be specified upon construction.
- Parameters
-
width | Width of the canvas. |
height | Height of the canvas. |
◆ clear()
void osm::Canvas::clear |
( |
| ) |
|
Fill the canvas with the background.
◆ enableFrame()
void osm::Canvas::enableFrame |
( |
bool |
frame_enabled | ) |
|
Flag to frame or not the canvas. The frame doesn't increase the size taken by the canvas. Instead, reduces the 2D space to draw in two columns and two rows (used to print the frame itself).
- Parameters
-
frame_enabled | Set to True to enable the frame. Otherwise set to False. |
◆ getBackground()
char osm::Canvas::getBackground |
( |
| ) |
const |
Get the char that fills the background.
- Returns
- char The char that fills the background.
◆ getBackgroundFeat()
std::string osm::Canvas::getBackgroundFeat |
( |
| ) |
const |
Get the optional feat of the background.
- Returns
- std::string The optional feat of the background.
◆ getFrameFeat()
std::string osm::Canvas::getFrameFeat |
( |
| ) |
const |
Get the frame feature (if set).
- Returns
- std::string The frame feature.
◆ getFrameStyle()
Get the frame style.
- Returns
- FrameStyle The frame style.
◆ getHeight()
uint32_t osm::Canvas::getHeight |
( |
| ) |
const |
Get the height of the canvas.
- Returns
- uint32_t The height of the canvas.
◆ getWidth()
uint32_t osm::Canvas::getWidth |
( |
| ) |
const |
Get the width of the canvas.
- Returns
- uint32_t The width of the canvas.
◆ isFrameEnabled()
bool osm::Canvas::isFrameEnabled |
( |
| ) |
const |
Return True if the frame is enabled. Otherwise return False.
- Returns
- bool The frame enabled flag.
◆ put()
void osm::Canvas::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 will be thrown if the coordinates are outside the canvas.
- Parameters
-
c | The char to put. |
x | The x position. |
y | The y position. |
feat | The optional feature. |
◆ refresh()
void osm::Canvas::refresh |
( |
| ) |
|
Display the canvas in the console.
◆ setBackground()
void osm::Canvas::setBackground |
( |
char |
c, |
|
|
std::string_view |
feat = "" |
|
) |
| |
Set the char that fills the background and an optional feat.
- Parameters
-
c | The char that fills the background. |
feat | The optional feat. |
◆ setFrame()
void osm::Canvas::setFrame |
( |
FrameStyle |
fs, |
|
|
std::string_view |
feat = "" |
|
) |
| |
Set the FrameStyle of the canvas and an optional feat.
- Parameters
-
fs | The FrameStyle of the canvas. |
feat | The optional feature. |
◆ setHeight()
void osm::Canvas::setHeight |
( |
uint32_t |
height | ) |
|
Set the height of the canvas.
- Parameters
-
height | The canvas height to set. |
◆ setWidth()
void osm::Canvas::setWidth |
( |
uint32_t |
width | ) |
|
Set the width of the canvas.
- Parameters
-
width | The canvas width to set. |
◆ height_
uint32_t osm::Canvas::height_ |
|
protected |
◆ width_
uint32_t osm::Canvas::width_ |
|
protected |
The documentation for this class was generated from the following files: