21 #ifndef EMP_WEB_CANVAS_ACTION_H 22 #define EMP_WEB_CANVAS_ACTION_H 36 void Fill(
const std::string & style=
"") {
39 emp_i.ctx.fillStyle = Pointer_stringify($0);
42 EM_ASM({ emp_i.ctx.fill(); });
46 void Stroke(
const std::string & style=
"") {
49 emp_i.ctx.strokeStyle = Pointer_stringify($0);
52 EM_ASM({ emp_i.ctx.stroke(); });
58 emp_i.ctx.lineWidth = $0;
68 virtual void Apply() = 0;
82 var color = Pointer_stringify($0);
83 emp_i.ctx.strokeStyle = color;
114 emp_i.ctx.font = Pointer_stringify($0);
128 : image(raw_image), position(_x,_y), width(_w), height(_h) { ; }
130 : image(raw_image), position(_p), width(_w), height(_h) { ; }
131 CanvasImage(
const std::string & url,
double _x=0.0,
double _y=0.0,
double _w=0.0,
double _h=0.0)
132 : image(url), position(_x,_y), width(_w), height(_h) { ; }
134 : image(url), position(_p), width(_w), height(_h) { ; }
140 emp_i.ctx.drawImage(emp_i.images[$0], $1, $2);
144 emp_i.ctx.drawImage(emp_i.images[$0], $1, $2, $3, $4);
145 }, image.
GetID(), position.
GetX(), position.
GetY(), width, height);
Rotate the entire canvas for subsequent drawings.
Definition: CanvasAction.h:90
int GetID() const
Definition: RawImage.h:139
constexpr TYPE GetX() const
Definition: Point2D.h:39
void Apply()
Apply current action to emp_i.ctx.
Definition: CanvasAction.h:136
virtual void Apply()=0
Apply current action to emp_i.ctx.
CanvasAction * Clone() const
Make a copy of the current action.
Definition: CanvasAction.h:150
CanvasRotate(double a)
Definition: CanvasAction.h:94
CanvasAction * Clone() const
Make a copy of the current action.
Definition: CanvasAction.h:117
CanvasAction()
Definition: CanvasAction.h:63
CanvasImage(const std::string &url, double _x=0.0, double _y=0.0, double _w=0.0, double _h=0.0)
Definition: CanvasAction.h:131
Change the default font to be used.
Definition: CanvasAction.h:106
CanvasImage(const RawImage &raw_image, double _x=0.0, double _y=0.0, double _w=0.0, double _h=0.0)
Definition: CanvasAction.h:127
CanvasStrokeColor(const std::string &c)
Definition: CanvasAction.h:78
void Apply()
Apply current action to emp_i.ctx.
Definition: CanvasAction.h:80
virtual ~CanvasAction()
Definition: CanvasAction.h:65
void Apply()
Apply current action to emp_i.ctx.
Definition: CanvasAction.h:96
std::string color
Color to use.
Definition: CanvasAction.h:76
void LineWidth(double line_width=1.0)
Helper function to set the stroke status.
Definition: CanvasAction.h:56
Handle the fundamental loading of an image (without Widget tracking)
CanvasImage(const RawImage &raw_image, Point _p, double _w=0.0, double _h=0.0)
Definition: CanvasAction.h:129
Base class to maintain canvas actions.
Definition: CanvasAction.h:33
RawImage image
Definition: CanvasAction.h:123
void Apply()
Apply current action to emp_i.ctx.
Definition: CanvasAction.h:112
CanvasFont(const std::string &f)
Definition: CanvasAction.h:110
If we are in emscripten, make sure to include the header.
Definition: array.h:37
Change the default font to be used.
Definition: CanvasAction.h:121
std::string font
Definition: CanvasAction.h:108
virtual CanvasAction * Clone() const =0
Make a copy of the current action.
Set the line color on subsequent draw-related actions.
Definition: CanvasAction.h:74
Fundamental information about a single image.
Definition: RawImage.h:124
CanvasAction(const CanvasAction &)
Definition: CanvasAction.h:64
Point position
Definition: CanvasAction.h:124
double width
Definition: CanvasAction.h:125
CanvasImage(const std::string &url, Point _p, double _w=0.0, double _h=0.0)
Definition: CanvasAction.h:133
CanvasAction * Clone() const
Make a copy of the current action.
Definition: CanvasAction.h:86
constexpr TYPE GetY() const
Definition: Point2D.h:40
void Fill(const std::string &style="")
Helper function to set the fill status.
Definition: CanvasAction.h:36
CanvasAction * Clone() const
Make a copy of the current action.
Definition: CanvasAction.h:101
double angle
Definition: CanvasAction.h:92
void OnLoad(const std::function< void()> &callback_fun)
Add a new function to be called when the image finishes loading.
Definition: RawImage.h:145
void Stroke(const std::string &style="")
Helper function to set the stroke status.
Definition: CanvasAction.h:46