CanvasLib
Loading...
Searching...
No Matches
canv::Canvas Class Reference

The main class representing the canvas. To use it you only need to: More...

#include <CanvasLib.hpp>

Public Types

enum class  DrawMode { Fill , Outline }
 

Public Member Functions

 Canvas (const Canvas &)=delete
 
 Canvas (Canvas &&)=delete
 
auto operator= (const Canvas &) -> Canvas &=delete
 
auto operator= (Canvas &&) -> Canvas &=delete
 
 Canvas (uint32_t width, uint32_t height)
 Initializes the name field to the name of the project.
 
void start ()
 starts the main window cycle IN MAIN THREAD
 
void setUpdateFunction (std::function< void(double)> upd)
 sets update function that will be called every frame
 
void drawRectangle (float x, float y, float w, float h)
 draws a rectangle with specified coordinates and size
 
void drawEllipse (float cx, float cy, float rx, float ry, int segments=40)
 draws an ellipse, if u want circle just pass same x and y radius for triangle use segments = 3
 
void setFillColor (const Color &color)
 sets the fill color
 
void setDrawMode (const DrawMode &drawMode)
 sets draw mode from Canvas::DrawMode enum
 

Static Public Member Functions

static void enableWatches ()
 Enables rendering watches in terminal.
 
static void disableWatches ()
 Disables rendering watches in terminal.
 
static void setWatch (const std::string &key, const std::string &value)
 Adds or updates entry in watches table.
 
static void removeWatch (const std::string &key)
 Removes entry from watches table, does nothing if it doesn't exist.
 

Detailed Description

The main class representing the canvas. To use it you only need to:

Member Function Documentation

◆ removeWatch()

static void canv::Canvas::removeWatch ( const std::string & key)
static

Removes entry from watches table, does nothing if it doesn't exist.

Note
Default entries can't be deleted

◆ setUpdateFunction()

void canv::Canvas::setUpdateFunction ( std::function< void(double)> upd)

sets update function that will be called every frame

Parameters
updfunction (or lambda) with void(double) signature. Double parameter is fps scale factor

◆ setWatch()

static void canv::Canvas::setWatch ( const std::string & key,
const std::string & value )
static

Adds or updates entry in watches table.

Watches allow you to add rows to the table in terminal interface (one that contains rendering statistics by default)


The documentation for this class was generated from the following file: