Class: PDF::Core::GraphicState
- Inherits:
-
Object
- Object
- PDF::Core::GraphicState
- Defined in:
- lib/pdf/core/graphics_state.rb
Overview
Graphics state. It’s a partial represenation of PDF graphics state. Only the parts implemented in Prawn are present here.
NOTE: This class may be a good candidate for a copy-on-write hash.
Instance Attribute Summary collapse
-
#cap_style ⇒ Symbol
Line cap.
-
#color_space ⇒ Hash
Color space.
-
#dash ⇒ Hash<[:dash, :space, :phase], [nil, Numeric]>
Dash.
-
#fill_color ⇒ String
Fill color.
-
#join_style ⇒ Symbol
Line Join.
-
#line_width ⇒ Numberic
Line width.
-
#stroke_color ⇒ Object
Stroke color.
Instance Method Summary collapse
-
#dash_setting ⇒ String
PDF representation of dash settings.
-
#initialize(previous_state = nil) ⇒ GraphicState
constructor
A new instance of GraphicState.
Constructor Details
#initialize(previous_state = nil) ⇒ GraphicState
Returns a new instance of GraphicState.
92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/pdf/core/graphics_state.rb', line 92 def initialize(previous_state = nil) if previous_state initialize_copy(previous_state) else @color_space = {} @fill_color = '000000' @stroke_color = '000000' @dash = { dash: nil, space: nil, phase: 0 } @cap_style = :butt @join_style = :miter @line_width = 1 end end |
Instance Attribute Details
#cap_style ⇒ Symbol
Line cap
74 75 76 |
# File 'lib/pdf/core/graphics_state.rb', line 74 def cap_style @cap_style end |
#color_space ⇒ Hash
Color space
66 67 68 |
# File 'lib/pdf/core/graphics_state.rb', line 66 def color_space @color_space end |
#dash ⇒ Hash<[:dash, :space, :phase], [nil, Numeric]>
Dash
70 71 72 |
# File 'lib/pdf/core/graphics_state.rb', line 70 def dash @dash end |
#fill_color ⇒ String
Fill color
86 87 88 |
# File 'lib/pdf/core/graphics_state.rb', line 86 def fill_color @fill_color end |
#join_style ⇒ Symbol
Line Join
78 79 80 |
# File 'lib/pdf/core/graphics_state.rb', line 78 def join_style @join_style end |
#line_width ⇒ Numberic
Line width
82 83 84 |
# File 'lib/pdf/core/graphics_state.rb', line 82 def line_width @line_width end |
#stroke_color ⇒ Object
Stroke color
89 90 91 |
# File 'lib/pdf/core/graphics_state.rb', line 89 def stroke_color @stroke_color end |
Instance Method Details
#dash_setting ⇒ String
PDF representation of dash settings
109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/pdf/core/graphics_state.rb', line 109 def dash_setting return '[] 0 d' unless @dash[:dash] array = if @dash[:dash].is_a?(Array) @dash[:dash] else [@dash[:dash], @dash[:space]] end "[#{PDF::Core.real_params(array)}] #{PDF::Core.real(@dash[:phase])} d" end |