#pragma once #include namespace pdfengine { enum class FillRule { NonZero, EvenOdd }; // Basic point structure struct Point { float x = 0.0f; float y = 0.0f; }; class Path { public: enum class Verb { MoveTo, LineTo, CubicBezierTo, Close }; struct Segment { Verb verb; Point points[3]; }; Path() = default; void moveTo(float x, float y) { m_segments.push_back({Verb::MoveTo, {{x, y}, {}, {}}}); } void lineTo(float x, float y) { m_segments.push_back({Verb::LineTo, {{x, y}, {}, {}}}); } void cubicTo(float cp1x, float cp1y, float cp2x, float cp2y, float x, float y) { m_segments.push_back({Verb::CubicBezierTo, {{cp1x, cp1y}, {cp2x, cp2y}, {x, y}}}); } void close() { m_segments.push_back({Verb::Close, {{}, {}, {}}}); } void addRect(float x, float y, float w, float h) { moveTo(x, y); lineTo(x + w, y); lineTo(x + w, y + h); lineTo(x, y + h); close(); } void clear() { m_segments.clear(); } [[nodiscard]] const std::vector& segments() const { return m_segments; } [[nodiscard]] bool empty() const { return m_segments.empty(); } private: std::vector m_segments; }; }