SVGPathBuilder.cpp [plain text]
#include "config.h"
#include "SVGPathBuilder.h"
#include "Path.h"
namespace WebCore {
SVGPathBuilder::SVGPathBuilder(Path& path)
: m_path(path)
{
}
void SVGPathBuilder::moveTo(const FloatPoint& targetPoint, bool closed, PathCoordinateMode mode)
{
m_current = mode == AbsoluteCoordinates ? targetPoint : m_current + targetPoint;
if (closed && !m_path.isEmpty())
m_path.closeSubpath();
m_path.moveTo(m_current);
}
void SVGPathBuilder::lineTo(const FloatPoint& targetPoint, PathCoordinateMode mode)
{
m_current = mode == AbsoluteCoordinates ? targetPoint : m_current + targetPoint;
m_path.addLineTo(m_current);
}
void SVGPathBuilder::curveToCubic(const FloatPoint& point1, const FloatPoint& point2, const FloatPoint& targetPoint, PathCoordinateMode mode)
{
if (mode == RelativeCoordinates) {
m_path.addBezierCurveTo(m_current + point1, m_current + point2, m_current + targetPoint);
m_current += targetPoint;
} else {
m_current = targetPoint;
m_path.addBezierCurveTo(point1, point2, m_current);
}
}
void SVGPathBuilder::closePath()
{
m_path.closeSubpath();
}
}