Path construction interpreter (m l c re S f B)
This commit is contained in:
@@ -72,6 +72,7 @@ public:
|
||||
|
||||
Path path;
|
||||
PathPaintOp paintOp = PathPaintOp::Stroke;
|
||||
FillRule fillRule = FillRule::NonZero;
|
||||
Matrix transform;
|
||||
};
|
||||
|
||||
|
||||
@@ -48,7 +48,8 @@ struct DrawTextCommand : public Command {
|
||||
|
||||
struct FillPathCommand : public Command {
|
||||
Path path;
|
||||
explicit FillPathCommand(Path path) : path(std::move(path)) {}
|
||||
FillRule rule;
|
||||
explicit FillPathCommand(Path path, FillRule rule = FillRule::NonZero) : path(std::move(path)), rule(rule) {}
|
||||
void accept(CommandVisitor& visitor) const override;
|
||||
};
|
||||
|
||||
@@ -58,6 +59,13 @@ struct StrokePathCommand : public Command {
|
||||
void accept(CommandVisitor& visitor) const override;
|
||||
};
|
||||
|
||||
struct FillStrokePathCommand : public Command {
|
||||
Path path;
|
||||
FillRule rule;
|
||||
explicit FillStrokePathCommand(Path path, FillRule rule = FillRule::NonZero) : path(std::move(path)), rule(rule) {}
|
||||
void accept(CommandVisitor& visitor) const override;
|
||||
};
|
||||
|
||||
struct DrawImageCommand : public Command {
|
||||
ImageInfo image;
|
||||
Matrix matrix;
|
||||
@@ -82,6 +90,7 @@ public:
|
||||
virtual void visit(const DrawTextCommand& cmd) = 0;
|
||||
virtual void visit(const FillPathCommand& cmd) = 0;
|
||||
virtual void visit(const StrokePathCommand& cmd) = 0;
|
||||
virtual void visit(const FillStrokePathCommand& cmd) = 0;
|
||||
virtual void visit(const DrawImageCommand& cmd) = 0;
|
||||
};
|
||||
|
||||
@@ -104,8 +113,9 @@ public:
|
||||
void setTransform(const Matrix& m);
|
||||
void fillRect(float x, float y, float w, float h);
|
||||
void drawText(const std::string& text, float x, float y);
|
||||
void fillPath(const Path& path);
|
||||
void fillPath(const Path& path, FillRule rule = FillRule::NonZero);
|
||||
void strokePath(const Path& path);
|
||||
void fillStrokePath(const Path& path, FillRule rule = FillRule::NonZero);
|
||||
void drawImage(const ImageInfo& image, const Matrix& m, float opacity = 1.0f);
|
||||
|
||||
[[nodiscard]] size_t size() const noexcept { return m_commands.size(); }
|
||||
|
||||
@@ -4,6 +4,11 @@
|
||||
|
||||
namespace pdfengine {
|
||||
|
||||
enum class FillRule {
|
||||
NonZero,
|
||||
EvenOdd
|
||||
};
|
||||
|
||||
// Basic point structure
|
||||
struct Point {
|
||||
float x = 0.0f;
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include <pdfengine/content_object.hpp>
|
||||
#include <pdfengine/display_list.hpp>
|
||||
|
||||
namespace pdfengine {
|
||||
|
||||
// PathObjectInterpreter converts a PathObject into DisplayList commands
|
||||
class PathObjectInterpreter {
|
||||
public:
|
||||
static void interpret(const PathObject& pathObj, DisplayList& displayList);
|
||||
};
|
||||
|
||||
} // namespace pdfengine
|
||||
@@ -21,6 +21,7 @@ public:
|
||||
void visit(const DrawTextCommand& cmd) override;
|
||||
void visit(const FillPathCommand& cmd) override;
|
||||
void visit(const StrokePathCommand& cmd) override;
|
||||
void visit(const FillStrokePathCommand& cmd) override;
|
||||
void visit(const DrawImageCommand& cmd) override;
|
||||
// Renders the entire display list to the canvas
|
||||
void render(const DisplayList& displayList);
|
||||
|
||||
Reference in New Issue
Block a user