#include "QuadraticBezierCurve.h"

#include "PointParser.h"

QuadraticBezierCurve::QuadraticBezierCurve(const Point& startPoint, const Point& endPoint, const Point& controlPoint)
	:	mStartPoint(startPoint),
		mEndPoint(endPoint),
		mControlPoint(controlPoint)
{

}

Point QuadraticBezierCurve::getFirstPoint() const
{
	return mStartPoint;
}

Point QuadraticBezierCurve::getEndPoint() const
{
	return mEndPoint;
}

Point QuadraticBezierCurve::getControlPoint() const
{
	return mControlPoint;
}

std::string QuadraticBezierCurve::toPostScriptString(std::size_t precision) const
{
	if (mPostscriptPositioning == PostscriptPositioning::RELATIVE_TO)
	{
		return "q" + PointParser::toStringRelative(mControlPoint, mStartPoint, 2, " ", precision) + " " + PointParser::toStringRelative(mEndPoint, mStartPoint, 2, " ", precision);
	}
	else
	{
		return "Q" + PointParser::toString(mControlPoint, 2, " ", precision) + " " + PointParser::toString(mEndPoint, 2, " ", precision);
	}
}

Bounds QuadraticBezierCurve::getBounds() const
{
	return {};
}

const Point& QuadraticBezierCurve::getLocation() const
{
	return mStartPoint;
}

void QuadraticBezierCurve::sample(SparseGrid<bool>*) const
{

}

QuadraticBezierCurve::Type QuadraticBezierCurve::getType() const
{
	return Type::CURVE;
}

QuadraticBezierCurve::CurveType QuadraticBezierCurve::getCurveType() const
{
	return CurveType::QUADRATIC_BEZIER;
}
