Files

52 lines
917 B
C++
Raw Permalink Normal View History

2026-05-22 15:49:10 +05:30
#pragma once
#include <vector>
#include <stdexcept>
namespace pdfengine {
struct Matrix {
float a = 1.0f, b = 0.0f;
float c = 0.0f, d = 1.0f;
float e = 0.0f, f = 0.0f;
Matrix() = default;
2026-07-23 11:31:26 +05:30
Matrix(float _a, float _b, float _c, float _d, float _e, float _f)
: a(_a), b(_b), c(_c), d(_d), e(_e), f(_f) {}
2026-05-22 15:49:10 +05:30
[[nodiscard]] Matrix multiply(const Matrix& other) const noexcept;
void transform(float& x, float& y) const noexcept;
};
struct Color {
float r = 0.0f;
float g = 0.0f;
float b = 0.0f;
};
struct GraphicsState {
2026-06-22 15:18:47 +05:30
Matrix ctm;
2026-05-22 15:49:10 +05:30
Color fillColor;
Color strokeColor;
float lineWidth = 1.0f;
};
class GraphicsStateStack {
public:
GraphicsStateStack();
void push();
void pop();
[[nodiscard]] GraphicsState& current();
[[nodiscard]] const GraphicsState& current() const;
private:
std::vector<GraphicsState> m_stack;
};
2026-06-22 15:18:47 +05:30
}