Skip to main content

InterpreterState

Struct InterpreterState 

Source
pub struct InterpreterState { /* private fields */ }
Expand description

Full interpreter state that combines the CTM with the graphics state.

This is the interpreter-level state that tracks everything needed during content stream processing. The q operator pushes a copy onto the stack; Q restores from the stack.

Implementations§

Source§

impl InterpreterState

Source

pub fn new() -> Self

Create a new interpreter state with identity CTM and default graphics state.

Source

pub fn ctm(&self) -> &Ctm

Get the current transformation matrix.

Source

pub fn ctm_array(&self) -> [f64; 6]

Get the current CTM as a 6-element array [a, b, c, d, e, f].

Source

pub fn graphics_state(&self) -> &GraphicsState

Get the current graphics state.

Source

pub fn graphics_state_mut(&mut self) -> &mut GraphicsState

Get a mutable reference to the current graphics state.

Source

pub fn stack_depth(&self) -> usize

Returns the current stack depth.

Source

pub fn save_state(&mut self)

q operator: save the current graphics state onto the stack.

Source

pub fn restore_state(&mut self) -> bool

Q operator: restore the most recently saved graphics state.

Returns false if the stack is empty (unbalanced Q).

Source

pub fn concat_matrix(&mut self, a: f64, b: f64, c: f64, d: f64, e: f64, f: f64)

cm operator: concatenate a matrix with the current CTM.

The new matrix is pre-multiplied: CTM’ = new_matrix × CTM_current. This follows the PDF spec where cm modifies the CTM by pre-concatenating.

Source

pub fn set_line_width(&mut self, width: f64)

w operator: set line width.

Source

pub fn set_dash_pattern(&mut self, dash_array: Vec<f64>, dash_phase: f64)

d operator: set dash pattern.

Source

pub fn set_stroking_gray(&mut self, gray: f32)

G operator: set stroking color to DeviceGray.

Source

pub fn set_non_stroking_gray(&mut self, gray: f32)

g operator: set non-stroking color to DeviceGray.

Source

pub fn set_stroking_rgb(&mut self, r: f32, g: f32, b: f32)

RG operator: set stroking color to DeviceRGB.

Source

pub fn set_non_stroking_rgb(&mut self, r: f32, g: f32, b: f32)

rg operator: set non-stroking color to DeviceRGB.

Source

pub fn set_stroking_cmyk(&mut self, c: f32, m: f32, y: f32, k: f32)

K operator: set stroking color to DeviceCMYK.

Source

pub fn set_non_stroking_cmyk(&mut self, c: f32, m: f32, y: f32, k: f32)

k operator: set non-stroking color to DeviceCMYK.

Source

pub fn set_stroking_color(&mut self, components: &[f32])

SC/SCN operator: set stroking color from components.

Interprets component count to determine color space:

  • 1 component → Gray
  • 3 components → RGB
  • 4 components → CMYK
  • other → Other
Source

pub fn set_non_stroking_color(&mut self, components: &[f32])

sc/scn operator: set non-stroking color from components.

Interprets component count to determine color space:

  • 1 component → Gray
  • 3 components → RGB
  • 4 components → CMYK
  • other → Other

Trait Implementations§

Source§

impl Clone for InterpreterState

Source§

fn clone(&self) -> InterpreterState

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for InterpreterState

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for InterpreterState

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl PartialEq for InterpreterState

Source§

fn eq(&self, other: &InterpreterState) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for InterpreterState

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.