CanvasAction.hpp
Define a base class for all actions that can be done to widgets, plus simple actions.
This file is part of Empirical, https://github.com/devosoft/Empirical Copyright (C) 2015-2018 Michigan State University MIT Software license; see doc/LICENSE.md
CanvasAction objects modify the appearance of a canvas and can be tracked to reconstruct the state of the canvas from scratch.
Other, more specific actions defined here are: CanvasStrokeColor CanvasRotate CanvasFont
See also CanvasShape.h for more actions.
Defines
-
INCLUDE_EMP_WEB_CANVAS_ACTION_HPP_GUARD
-
class CanvasAction
- #include <CanvasAction.hpp>
Base class to maintain canvas actions.
Subclassed by CanvasFont, CanvasImage, CanvasRotate, CanvasShape, CanvasStrokeColor
Public Functions
-
inline CanvasAction()
-
inline CanvasAction(const CanvasAction&)
-
inline virtual ~CanvasAction()
-
virtual void Apply() = 0
Apply current action to emp_i.ctx.
-
virtual CanvasAction *Clone() const = 0
Make a copy of the current action.
-
inline CanvasAction()
-
class CanvasStrokeColor : public CanvasAction
- #include <CanvasAction.hpp>
Set the line color on subsequent draw-related actions.
Public Functions
-
inline virtual void Apply()
Apply current action to emp_i.ctx.
-
inline virtual CanvasAction *Clone() const
Make a copy of the current action.
-
inline virtual void Apply()
-
class CanvasRotate : public CanvasAction
- #include <CanvasAction.hpp>
Rotate the entire canvas for subsequent drawings.
Public Functions
-
inline CanvasRotate(double a)
-
inline virtual void Apply()
Apply current action to emp_i.ctx.
-
inline virtual CanvasAction *Clone() const
Make a copy of the current action.
Protected Attributes
-
double angle
-
inline CanvasRotate(double a)
-
class CanvasFont : public CanvasAction
- #include <CanvasAction.hpp>
Change the default font to be used.
Public Functions
-
inline virtual void Apply()
Apply current action to emp_i.ctx.
-
inline virtual CanvasAction *Clone() const
Make a copy of the current action.
-
inline virtual void Apply()
-
class CanvasImage : public CanvasAction
- #include <CanvasAction.hpp>
Change the default font to be used.
Public Functions
-
inline CanvasImage(const RawImage &raw_image, double _x = 0.0, double _y = 0.0, double _w = 0.0, double _h = 0.0)
-
inline CanvasImage(const std::string &url, double _x = 0.0, double _y = 0.0, double _w = 0.0, double _h = 0.0)
-
inline virtual void Apply()
Apply current action to emp_i.ctx.
-
inline virtual CanvasAction *Clone() const
Make a copy of the current action.
-
inline CanvasImage(const RawImage &raw_image, double _x = 0.0, double _y = 0.0, double _w = 0.0, double _h = 0.0)