CanvasShape.hpp
Define simple shapes to draw on a canvas.
Canvas shapes can be defined in detail, describing how they modify a canvas.
Other, more specific actions defined here are: CanvasCircle CanvasRect
-
class CanvasShape : public CanvasAction
- #include <CanvasShape.hpp>
Define an arbitrary shape to draw on a canvas (base class)
Subclassed by CanvasCircle, CanvasClearRect, CanvasLine, CanvasMultiLine, CanvasPolygon, CanvasRect, CanvasText
Public Functions
-
inline CanvasShape(double _x, double _y, const std::string &fc = "", const std::string &lc = "", double lw = 1.0)
-
inline CanvasShape(Point _p, const std::string &fc = "", const std::string &lc = "", double lw = 1.0)
-
inline virtual ~CanvasShape()
-
inline void MoveTo(double _x, double _y)
Shift the position of this shape to coordinates.
-
inline void SetLineWidth(double lw = 1.0)
Setup details needed before drawing lines.
-
inline void ApplyColor()
Actually change the color on screen.
-
inline CanvasShape(double _x, double _y, const std::string &fc = "", const std::string &lc = "", double lw = 1.0)
-
class CanvasCircle : public CanvasShape
- #include <CanvasShape.hpp>
Track a circle shape to be drawn on a canvas.
Public Functions
-
inline CanvasCircle(double _x, double _y, double _r, const std::string &fc = "", const std::string &lc = "", double lw = 1.0)
-
inline CanvasCircle(Point _p, double _r, const std::string &fc = "", const std::string &lc = "", double lw = 1.0)
-
inline CanvasCircle(Circle circle, const std::string &fc = "", const std::string &lc = "", double lw = 1.0)
-
inline virtual void Apply()
Apply current action to emp_i.ctx.
-
inline virtual CanvasAction *Clone() const
Make a copy of the current action.
Private Members
-
double radius
Circle radius.
-
inline CanvasCircle(double _x, double _y, double _r, const std::string &fc = "", const std::string &lc = "", double lw = 1.0)
-
class CanvasRect : public CanvasShape
- #include <CanvasShape.hpp>
Track a rectangle shape to be drawn on a canvas.
Public Functions
-
inline CanvasRect(Point _p, double _w, double _h, const std::string &fc = "", const std::string &lc = "")
-
inline CanvasRect(double _x, double _y, double _w, double _h, const std::string &fc = "", const std::string &lc = "")
-
inline virtual void Apply()
Apply current action to emp_i.ctx.
-
inline virtual CanvasAction *Clone() const
Make a copy of the current action.
-
inline CanvasRect(Point _p, double _w, double _h, const std::string &fc = "", const std::string &lc = "")
-
class CanvasClearRect : public CanvasShape
- #include <CanvasShape.hpp>
Clear a rectangular area in a canvas.
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 CanvasPolygon : public CanvasShape
- #include <CanvasShape.hpp>
An arbitrary-sized polygon to be drawn on a canvas.
Public Functions
-
inline CanvasPolygon(const vector<Point> &p, const std::string &fc = "", const std::string &lc = "")
-
inline CanvasPolygon &AddPoint(double x, double y)
-
inline CanvasPolygon &AddPoint(Point p)
-
inline virtual void Apply()
Apply current action to emp_i.ctx.
-
inline virtual CanvasAction *Clone() const
Make a copy of the current action.
-
inline CanvasPolygon(const vector<Point> &p, const std::string &fc = "", const std::string &lc = "")
-
class CanvasLine : public CanvasShape
- #include <CanvasShape.hpp>
A line segment on the canvas.
Public Functions
-
inline CanvasLine(double _x1, double _y1, double _x2, double _y2, const std::string &lc = "", double lw = 1.0)
Y-position for second point of line segment.
-
inline virtual void Apply()
Apply current action to emp_i.ctx.
-
inline virtual CanvasAction *Clone() const
Make a copy of the current action.
-
inline CanvasLine(double _x1, double _y1, double _x2, double _y2, const std::string &lc = "", double lw = 1.0)
-
class CanvasMultiLine : public CanvasShape
- #include <CanvasShape.hpp>
A whole series of line segments on the canvas. Currently not working…
Public Functions
-
inline CanvasMultiLine(double _x1, double _y1, const vector<Point> &_points, const std::string &lc = "", double lw = 1.0)
-
inline CanvasMultiLine(Point p1, const vector<Point> &_points, const std::string &lc = "", double lw = 1.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 CanvasMultiLine(double _x1, double _y1, const vector<Point> &_points, const std::string &lc = "", double lw = 1.0)
-
class CanvasText : public CanvasShape
- #include <CanvasShape.hpp>
Text to be written on a canvas.
Public Functions
-
inline CanvasText(Point p, const std::string &_text, const std::string &fc = "", const std::string &lc = "")
-
inline virtual void Apply()
Apply current action to emp_i.ctx.
-
inline void Center(bool c = true)
Center this text.
-
inline bool GetCenter() const
Identify if text is centered.
-
inline virtual CanvasAction *Clone() const
Make a copy of the current action.
-
inline CanvasText(Point p, const std::string &_text, const std::string &fc = "", const std::string &lc = "")