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.
Source Code
lib/pdf/core/graphics_state.rb, line 92
92 | def initialize(previous_state = nil) |
93 | if previous_state |
94 | initialize_copy(previous_state) |
95 | else
|
96 | @color_space = {} |
97 | @fill_color = '000000' |
98 | @stroke_color = '000000' |
99 | @dash = { dash: nil, space: nil, phase: 0 } |
100 | @cap_style = :butt |
101 | @join_style = :miter |
102 | @line_width = 1 |
103 | end
|
104 | end
|
Instance Attribute Details
#cap_style ⇒ Symbol
Line cap
Source Code
lib/pdf/core/graphics_state.rb, line 74
74 | def cap_style |
75 | @cap_style
|
76 | end
|
#color_space ⇒ Hash
Color space
Source Code
lib/pdf/core/graphics_state.rb, line 66
66 | def color_space |
67 | @color_space
|
68 | end
|
#dash ⇒ Hash<[:dash, :space, :phase], [nil, Numeric]>
Dash
Source Code
lib/pdf/core/graphics_state.rb, line 70
70 | def dash |
71 | @dash
|
72 | end
|
#fill_color ⇒ String
Fill color
Source Code
lib/pdf/core/graphics_state.rb, line 86
86 | def fill_color |
87 | @fill_color
|
88 | end
|
#join_style ⇒ Symbol
Line Join
Source Code
lib/pdf/core/graphics_state.rb, line 78
78 | def join_style |
79 | @join_style
|
80 | end
|
#line_width ⇒ Numberic
Line width
Source Code
lib/pdf/core/graphics_state.rb, line 82
82 | def line_width |
83 | @line_width
|
84 | end
|
#stroke_color ⇒ Object
Stroke color
Source Code
lib/pdf/core/graphics_state.rb, line 89
89 | def stroke_color |
90 | @stroke_color
|
91 | end
|
Instance Method Details
#dash_setting ⇒ String
PDF representation of dash settings
Source Code
lib/pdf/core/graphics_state.rb, line 109
109 | def dash_setting |
110 | return '[] 0 d' unless @dash[:dash] |
111 | |
112 | array = |
113 | if @dash[:dash].is_a?(Array) |
114 | @dash[:dash] |
115 | else
|
116 | [@dash[:dash], @dash[:space]] |
117 | end
|
118 | |
119 | "[#{PDF::Core.real_params(array)}] #{PDF::Core.real(@dash[:phase])} d" |
120 | end
|