Represents an ASCII-art drawing and its corresponding bounding box.
More...
#include <shape.h>
|
| | Shape (std::vector< std::string > shape) |
| | Take in an array of lines and right-pad the shorter ones with ' ' to the width of the longest line. More...
|
| |
| int | width () const |
| |
| int | height () const |
| |
| char | charAt (int col, int row) const |
| | Fetch the character at the given coordinate pair. More...
|
| |
Represents an ASCII-art drawing and its corresponding bounding box.
Definition at line 7 of file shape.h.
◆ Shape()
| Shape::Shape |
( |
std::vector< std::string > |
shape | ) |
|
|
explicit |
Take in an array of lines and right-pad the shorter ones with ' ' to the width of the longest line.
Definition at line 9 of file shape.cpp.
◆ charAt()
| char Shape::charAt |
( |
int |
col, |
|
|
int |
row |
|
) |
| const |
Fetch the character at the given coordinate pair.
- Parameters
-
| col | 0-based column (x) index |
| row | 0-based row (y) index |
- Returns
- character at the given position
- Exceptions
-
| std::out_of_range | if the row or column is out of bounds (negative or too large) |
Definition at line 33 of file shape.cpp.
◆ height()
| int Shape::height |
( |
| ) |
const |
- Returns
- the height of the bounding box
Definition at line 31 of file shape.cpp.
◆ width()
| int Shape::width |
( |
| ) |
const |
- Returns
- the width of the bounding box (0 if the height is 0)
Definition at line 29 of file shape.cpp.
The documentation for this class was generated from the following files: