Files
pdf/engine/include/pdfengine/graphics_state.hpp
T
2026-07-23 11:31:26 +05:30

52 lines
917 B
C++

#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;
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) {}
[[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 {
Matrix ctm;
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;
};
}