This source file includes following definitions.
- moveTo
- lineTo
- curveToCubic
- closePath
#include "config.h"
#include "core/svg/SVGPathBuilder.h"
#include "platform/graphics/Path.h"
namespace WebCore {
SVGPathBuilder::SVGPathBuilder()
: m_path(0)
{
}
void SVGPathBuilder::moveTo(const FloatPoint& targetPoint, bool closed, PathCoordinateMode mode)
{
ASSERT(m_path);
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)
{
ASSERT(m_path);
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)
{
ASSERT(m_path);
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()
{
ASSERT(m_path);
m_path->closeSubpath();
}
}