Files
pdf/engine/include/pdfengine/graphics_state.hpp
T
2026-06-22 15:18:47 +05:30

52 lines
905 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;
};
}