GraphicsState
Graphics state (ISO 32000-1 §8.4).
Every PDF content stream runs inside a stack of graphics states. q pushes a copy; Q pops back. cm, color setters, font setters etc. mutate the top of the stack. We model this with an immutable GraphicsState data class and a stack on the side (see GraphicsStack) — easier to reason about than a mutable struct, and the cost is a small allocation per q.
Text state (Tm, Tlm, font, size, spacing) is tracked separately on TextState and lives only inside BT…ET blocks.
Constructors
Properties
Current non-stroke colour space (cs operator).
Active fill pattern — set by scn when the fill colour-space is /Pattern. When non-null, fillColor is ignored and paint operators route through the canvas's gradient/tile path. Cleared by any plain colour setter (g, rg, k, cs, sc).
Per-pixel alpha multiplier for strokes (ExtGState /CA), 0..1.
Current stroke colour space (CS operator).
Active stroke pattern — same semantics as fillPattern for SCN.
Functions
Merge the non-null fields of ext into this state. Spec semantics for gs <name>: only entries present in the ExtGState override; everything else passes through.