Prawn::Document::GraphicsState

Public Instance Methods

close_graphics_state() click to toggle source
     # File lib/prawn/document/graphics_state.rb, line 101
101:       def close_graphics_state
102:         add_content "Q"
103:       end
graphic_stack() click to toggle source
     # File lib/prawn/document/graphics_state.rb, line 125
125:       def graphic_stack
126:         state.page.stack
127:       end
graphic_state() click to toggle source
     # File lib/prawn/document/graphics_state.rb, line 129
129:       def graphic_state
130:         save_graphics_state unless graphic_stack.current_state
131:         graphic_stack.current_state 
132:       end
open_graphics_state() click to toggle source

Pushes the current graphics state on to the graphics state stack so we can restore it when finished with a change we want to isolate (such as modifying the transformation matrix). Used in pairs with restore_graphics_state or passed a block

Example without a block:

  save_graphics_state
  rotate 30
  text "rotated text"
  restore_graphics_state

Example with a block:

  save_graphics_state do
    rotate 30
    text "rotated text"
  end
    # File lib/prawn/document/graphics_state.rb, line 97
97:       def open_graphics_state
98:         add_content "q"
99:       end
restore_graphics_state() click to toggle source

Pops the last saved graphics state off the graphics state stack and restores the state to those values

     # File lib/prawn/document/graphics_state.rb, line 116
116:       def restore_graphics_state
117:         if graphic_stack.empty?
118:           raise Prawn::Errors::EmptyGraphicStateStack, 
119:             "\n You have reached the end of the graphic state stack" 
120:         end
121:         close_graphics_state 
122:         graphic_stack.restore_graphic_state
123:       end
save_graphics_state(graphic_state = nil) click to toggle source
     # File lib/prawn/document/graphics_state.rb, line 105
105:       def save_graphics_state(graphic_state = nil)
106:         graphic_stack.save_graphic_state(graphic_state)
107:         open_graphics_state
108:         if block_given?
109:           yield
110:           restore_graphics_state
111:         end
112:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.