PathTraversalState.h [plain text]
#ifndef PathTraversalState_h
#define PathTraversalState_h
#include "FloatPoint.h"
#include "Path.h"
namespace WebCore {
class PathTraversalState {
public:
enum class Action {
TotalLength,
VectorAtLength,
SegmentAtLength,
};
PathTraversalState(Action, float desiredLength = 0);
public:
bool processPathElement(PathElementType, const FloatPoint*);
bool processPathElement(const PathElement& element) { return processPathElement(element.type, element.points); }
Action action() const { return m_action; }
void setAction(Action action) { m_action = action; }
float desiredLength() const { return m_desiredLength; }
void setDesiredLength(float desiredLength) { m_desiredLength = desiredLength; }
bool success() const { return m_success; }
float totalLength() const { return m_totalLength; }
FloatPoint current() const { return m_current; }
float normalAngle() const { return m_normalAngle; }
private:
void closeSubpath();
void moveTo(const FloatPoint&);
void lineTo(const FloatPoint&);
void quadraticBezierTo(const FloatPoint&, const FloatPoint&);
void cubicBezierTo(const FloatPoint&, const FloatPoint&, const FloatPoint&);
bool finalizeAppendPathElement();
bool appendPathElement(PathElementType, const FloatPoint*);
private:
Action m_action;
bool m_success { false };
FloatPoint m_current;
FloatPoint m_start;
float m_totalLength { 0 };
float m_desiredLength { 0 };
FloatPoint m_previous;
float m_normalAngle { 0 }; bool m_isZeroVector { false };
};
}
#endif