pub struct GraphicsState {Show 22 fields
pub matrix: [f64; 6],
pub screen: ScreenParams,
pub stroke_alpha: f64,
pub fill_alpha: f64,
pub pattern_stroke_alpha: f64,
pub pattern_fill_alpha: f64,
pub line_width: f64,
pub line_cap: LineCap,
pub line_join: LineJoin,
pub miter_limit: f64,
pub flatness: f64,
pub line_dash: Vec<f64>,
pub line_dash_phase: f64,
pub clip: Clip,
pub soft_mask: Option<Box<AnyBitmap>>,
pub overprint_mode: i32,
pub rgb_transfer: [TransferLut; 3],
pub gray_transfer: TransferLut,
pub cmyk_transfer: [TransferLut; 4],
pub device_n_transfer: Vec<[u8; 256]>,
pub overprint_mask: u32,
pub delete_soft_mask: bool,
}Expand description
The complete graphics state for one rendering context.
Patterns are stubbed as () for Phase 1; Phase 2 replaces them with
Box<dyn Pattern>.
Fields§
§matrix: [f64; 6]Current transformation matrix in column-vector 2-D affine form: [a, b, c, d, e, f].
screen: ScreenParamsHalftone screen parameters controlling frequency, angle, and spot function.
stroke_alpha: f64Opacity for stroking operations. 0.0 = fully transparent, 1.0 = fully opaque.
fill_alpha: f64Opacity for fill operations. 0.0 = fully transparent, 1.0 = fully opaque.
pattern_stroke_alpha: f64Effective stroke alpha after multiplying in pattern alpha (used when multiply_pattern_alpha is set).
pattern_fill_alpha: f64Effective fill alpha after multiplying in pattern alpha (used when multiply_pattern_alpha is set).
line_width: f64Stroke line width in user-space units; must be ≥ 0.
line_cap: LineCapStyle of line end caps (butt, round, or square).
line_join: LineJoinStyle of line joins (miter, round, or bevel).
miter_limit: f64Maximum ratio of miter length to line width before a miter join is beveled; default 10.0.
flatness: f64Maximum permitted distance between the path and the approximating line segments; default 1.0.
line_dash: Vec<f64>Dash pattern array: alternating on/off lengths in user-space units.
line_dash_phase: f64Offset into the dash pattern at which stroking begins.
clip: ClipActive clipping region; updated by clip operators.
soft_mask: Option<Box<AnyBitmap>>Soft mask bitmap (None if no soft mask is active).
overprint_mode: i32PDF overprint mode: 0 = CompatibleOverprint, 1 = IsolatePaint.
rgb_transfer: [TransferLut; 3]Transfer LUTs — RGB channels (R=0, G=1, B=2).
gray_transfer: TransferLutTransfer LUT for the gray channel.
cmyk_transfer: [TransferLut; 4]Transfer LUTs — CMYK channels (C=0, M=1, Y=2, K=3).
device_n_transfer: Vec<[u8; 256]>Transfer LUTs — DeviceN channels (indices 0..SPOT_NCOMPS+4 = 8).
overprint_mask: u32Bitmask of color components that participate in overprinting; default 0xFFFF_FFFF (all).
delete_soft_mask: boolWhether the soft mask should be deleted on the next state restore.
New states cloned for an XObject explicitly clear this so child
renders do not inherit the parent’s deletion intent.
Implementations§
Source§impl GraphicsState
impl GraphicsState
Sourcepub fn new(width: u32, height: u32, vector_antialias: bool) -> Self
pub fn new(width: u32, height: u32, vector_antialias: bool) -> Self
Construct the default state for a new page.
clip is set to [0, 0, width-0.001, height-0.001] — the intentional
0.001 inset matches SplashState constructor and avoids edge-pixel issues.
§Panics
Panics (in debug builds only) if width or height is zero. A zero
dimension would produce a negative clip bound (0.0 - 0.001 = -0.001),
which is meaningless and almost certainly a caller bug.
Sourcepub fn set_transfer(
&mut self,
r: &[u8; 256],
g: &[u8; 256],
b: &[u8; 256],
gray: &[u8; 256],
)
pub fn set_transfer( &mut self, r: &[u8; 256], g: &[u8; 256], b: &[u8; 256], gray: &[u8; 256], )
Apply new RGB and gray transfer functions, deriving CMYK and DeviceN[0..4]
from the inverted current RGB/gray values before overwriting them.
Matches SplashState::setTransfer in SplashState.cc exactly.
§Derivation
CMYK uses a subtractive colour model: a CMYK value of 0 means “no ink” (full brightness) and 255 means “full ink” (zero brightness). The relationship to the existing RGB transfer LUT is therefore:
Step 1 – invert the index: look up rgb_transfer_R at position (255 - i)
to obtain the complemented input value.
Step 2 – invert the result: subtract from 255 to flip from additive to
subtractive space.
cmykTransferC[i] = 255 - rgb_transfer_R[255 - i] ← C mapped from R
cmykTransferM[i] = 255 - rgb_transfer_G[255 - i] ← M mapped from G
cmykTransferY[i] = 255 - rgb_transfer_B[255 - i] ← Y mapped from B
cmykTransferK[i] = 255 - gray_transfer[255 - i] ← K mapped from gray
deviceNTransfer[0..=3][i] = same as CMYK (C/M/Y/K), respectivelyOnly after the CMYK/DeviceN tables have been built are rgb_transfer and
gray_transfer overwritten with the new r, g, b, gray LUTs.
Sourcepub fn save_clone(&self) -> Self
pub fn save_clone(&self) -> Self
Clone this state for save().
Clip scanners are shared via Arc (matching C++ shared_ptr semantics).
The soft mask is NOT inherited — the new state starts with soft_mask = None.
Sourcepub fn transfer_set(&self) -> TransferSet<'_>
pub fn transfer_set(&self) -> TransferSet<'_>
Borrow the transfer tables as a TransferSet for use in the pipe.
The returned TransferSet borrows from self and is valid for the lifetime
of this GraphicsState.