This class is used to plot mathematical functions R -> R. In addition to all the properties of a basic Canvas, this one also has an offset and a scale for the plot. The offset is the first value in x and y to be represented in the canvas and the scale is the difference in x or y that each character represents relative to the previous one. For example: a canvas of size = (15, 10) with offset = (3,2) and scale = (7, 5) will represent the functions you draw from x=3 to x=3+15*7=108 and from y=2 to y=2+10*5=52.
More...
|
| Plot2DCanvas (uint32_t w, uint32_t h) |
| Construct a new Plot2D:: Plot2D object. The same as its parent, the constructor requires the dimensions of the canvas. More...
|
|
void | setOffset (float xOff, float yOff) |
| Set the offset_x and offset_y of the canvas. More...
|
|
void | setScale (float xScale, float yScale) |
| Set the scale_x and scale_y of the canvas. More...
|
|
float | getOffsetX () const |
| Get the offset_x of the canvas. More...
|
|
float | getOffsetY () const |
| Get the offset_y of the canvas. More...
|
|
float | getScaleX () const |
| Get the scale_x of the canvas. More...
|
|
float | getScaleY () const |
| Get the scale_y of the canvas. More...
|
|
template<typename Y , typename X > |
void | draw (std::function< Y(X)> function, char c, std::string_view feat="") |
| Plot a function that receives an argument of a numeric type X and returns a numeric value of type Y. Represent it with a given char c and an optional feat. More...
|
|
| 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...
|
|
This class is used to plot mathematical functions R -> R. In addition to all the properties of a basic Canvas, this one also has an offset and a scale for the plot. The offset is the first value in x and y to be represented in the canvas and the scale is the difference in x or y that each character represents relative to the previous one. For example: a canvas of size = (15, 10) with offset = (3,2) and scale = (7, 5) will represent the functions you draw from x=3 to x=3+15*7=108 and from y=2 to y=2+10*5=52.