#pragma once

#include "Color.h"

#include <wrl.h>

class SceneModel;
class Point;
class DirectX2dInterface;

class PathElement;
class Curve;

struct ID2D1SolidColorBrush;
struct ID2D1GeometrySink;

namespace D2D1
{
	class ColorF;
}
struct D2D_POINT_2F;

class DirectX2dPainter
{
public:
	void startDrawing();

	void clearBackground(const Color& color);

	void finishDrawing();

	void paint(SceneModel* model);

	void setD2dInterface(DirectX2dInterface* d2dIterface);

private:
	void onLine(PathElement* element, ID2D1GeometrySink* sink);

	void onLineSegment(PathElement* element, ID2D1GeometrySink* sink);

	void onArc(Curve* element, ID2D1GeometrySink* sink);

	void onQuadraticBezier(Curve* element, ID2D1GeometrySink* sink);

	void onCubicBezier(Curve* element, ID2D1GeometrySink* sink);

	void paintRect(SceneModel* model);

	void paintCircle(SceneModel* model);

	void paintPath(SceneModel* model);

	void paintLine(SceneModel* model);

	void paintPolygon(SceneModel* model);

	static D2D1::ColorF toD2dColor(const Color& color);

	static D2D_POINT_2F toD2dPoint(const Point& point);

	Microsoft::WRL::ComPtr<ID2D1SolidColorBrush> mSolidBrush;
	
	DirectX2dInterface* mD2dInterface{ nullptr };
};