Canvas.hpp

Manage an HTML canvas object.

class Canvas : public internal::WidgetFacet<Canvas>
#include <Canvas.hpp>

Manage an HTML Canvas object.

Public Types

using INFO_TYPE = CanvasInfo

Public Functions

inline Canvas(double w, double h, const std::string &in_id = "")

Create a new canvas with the specified size and optional HTML identifier.

inline Canvas(const Canvas &in)

Link to an existing canvas.

inline Canvas(const Widget &in)
inline Canvas()
inline virtual ~Canvas()
inline void SetSize(double w, double h)

Set Canvas size.

template<typename ...Ts>
inline Canvas &Circle(Point center, double _r, Ts&&... vals)

Add a Circle to this canvas; provide constructor for the CanvasCircle with a position and radius as well as optional face color, line color, and line width.

template<typename ...Ts>
inline Canvas &Circle(double _x, double _y, double _r, Ts&&... vals)
template<typename ...Ts>
inline Canvas &Rect(Point corner, double w, double h, Ts&&... vals)

Add a Rectangle to this canvas at x,y with width w and heigh h. Optional face color and line color.

template<typename ...Ts>
inline Canvas &Rect(double x, double y, double w, double h, Ts&&... vals)
template<typename ...Ts>
inline Canvas &Image(const RawImage &image, Point corner, Ts&&... vals)

Add an Image to this canvas at x,y with width w and heigh h.

template<typename ...Ts>
inline Canvas &Image(const RawImage &image, double x, double y, Ts&&... vals)
template<typename ...Ts>
inline Canvas &Line(double x1, double y1, double x2, double y2, Ts&&... vals)

Add a Line from x1,y1 to x2,y2. Optional face color and line color.

template<typename ...Ts>
inline Canvas &Line(Point p1, Point p2, Ts&&... vals)
template<typename ...Ts>
inline Canvas &MultiLine(Point p1, const vector<Point> &points, Ts&&... vals)

Add a Line from x1,y1 to x2,y2. Optional face color and line color.

template<typename ...Ts>
inline Canvas &Text(Point p, Ts&&... vals)

Add a string to this canvas at x,y with specified text. Optional face color and line color.

template<typename ...Ts>
inline Canvas &Text(double x, double y, Ts&&... vals)
template<typename ...Ts>
inline Canvas &CenterText(Point p, Ts&&... vals)

Add a string to this canvas centered at x,y with specified text. Optional face color and line color.

template<typename ...Ts>
inline Canvas &CenterText(double x, double y, Ts&&... vals)
inline Canvas &Font(const std::string font)

Update the default font for text.

inline Canvas &Draw(const Circle &circle, const std::string &fc = "", const std::string &lc = "")

Draw a circle onto this canvas.

inline Canvas &Draw(const CanvasShape &shape)

Draw an arbitrary shape onto this canvas.

inline Canvas &StrokeColor(std::string c)

Change the default stroke color.

inline Canvas &Rotate(double angle)

Rotate the entire canvas.

inline Canvas &Clear()

Clear everything off of this canvas.

inline Canvas &Clear(const std::string &bg_color)

Clear to a specific background color.

inline void DownloadPNG() const

Download a PNG image of a canvas.

inline void DownloadPNG(const std::string &fname) const

Download a PNG image of a canvas.

inline void SavePNG(const std::string &fname) const

Save a PNG image of a canvas with node.js.

Protected Functions

inline CanvasInfo *Info()
inline const CanvasInfo *Info() const
inline Canvas(CanvasInfo *in_info)

Friends

friend class CanvasInfo