Class: Pdfrb::Content::GraphicsState
- Inherits:
-
Object
- Object
- Pdfrb::Content::GraphicsState
- Defined in:
- lib/pdfrb/content/graphics_state.rb
Overview
Immutable snapshot of the PDF graphics state (s8.4). The
Processor holds a stack of these for q (push) / Q (pop).
Subclasses (TextState for the text sub-state) compose rather
than inherit.
Defined Under Namespace
Classes: TextState
Instance Attribute Summary collapse
-
#alpha_is_shape ⇒ Object
readonly
Returns the value of attribute alpha_is_shape.
-
#blend_mode ⇒ Object
readonly
Returns the value of attribute blend_mode.
-
#ctm ⇒ Object
readonly
Returns the value of attribute ctm.
-
#dash_pattern ⇒ Object
readonly
Returns the value of attribute dash_pattern.
-
#fill_alpha ⇒ Object
readonly
Returns the value of attribute fill_alpha.
-
#fill_color ⇒ Object
readonly
Returns the value of attribute fill_color.
-
#flatness ⇒ Object
readonly
Returns the value of attribute flatness.
-
#line_cap ⇒ Object
readonly
Returns the value of attribute line_cap.
-
#line_join ⇒ Object
readonly
Returns the value of attribute line_join.
-
#line_width ⇒ Object
readonly
Returns the value of attribute line_width.
-
#miter_limit ⇒ Object
readonly
Returns the value of attribute miter_limit.
-
#overprint ⇒ Object
readonly
Returns the value of attribute overprint.
-
#overprint_mode ⇒ Object
readonly
Returns the value of attribute overprint_mode.
-
#soft_mask ⇒ Object
readonly
Returns the value of attribute soft_mask.
-
#stroke_alpha ⇒ Object
readonly
Returns the value of attribute stroke_alpha.
-
#stroke_color ⇒ Object
readonly
Returns the value of attribute stroke_color.
-
#text_state ⇒ Object
readonly
Returns the value of attribute text_state.
Instance Method Summary collapse
-
#initialize(ctm: Pdfrb::Model::Matrix.identity, text_state: TextState.new, fill_color: nil, stroke_color: nil, line_width: 1.0, line_cap: 0, line_join: 0, miter_limit: 10.0, dash_pattern: [].freeze, flatness: 0, alpha_is_shape: false, stroke_alpha: 1.0, fill_alpha: 1.0, blend_mode: :Normal, soft_mask: nil, overprint: false, overprint_mode: 0) ⇒ GraphicsState
constructor
A new instance of GraphicsState.
- #to_h ⇒ Object
-
#with(**overrides) ⇒ Object
Returns a new GraphicsState with the given overrides (the original is frozen).
Constructor Details
#initialize(ctm: Pdfrb::Model::Matrix.identity, text_state: TextState.new, fill_color: nil, stroke_color: nil, line_width: 1.0, line_cap: 0, line_join: 0, miter_limit: 10.0, dash_pattern: [].freeze, flatness: 0, alpha_is_shape: false, stroke_alpha: 1.0, fill_alpha: 1.0, blend_mode: :Normal, soft_mask: nil, overprint: false, overprint_mode: 0) ⇒ GraphicsState
Returns a new instance of GraphicsState.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/pdfrb/content/graphics_state.rb', line 16 def initialize(ctm: Pdfrb::Model::Matrix.identity, text_state: TextState.new, fill_color: nil, stroke_color: nil, line_width: 1.0, line_cap: 0, line_join: 0, miter_limit: 10.0, dash_pattern: [].freeze, flatness: 0, alpha_is_shape: false, stroke_alpha: 1.0, fill_alpha: 1.0, blend_mode: :Normal, soft_mask: nil, overprint: false, overprint_mode: 0) @ctm = ctm @text_state = text_state @fill_color = fill_color @stroke_color = stroke_color @line_width = line_width.to_f @line_cap = line_cap.to_i @line_join = line_join.to_i @miter_limit = miter_limit.to_f @dash_pattern = dash_pattern @flatness = flatness.to_i @alpha_is_shape = alpha_is_shape @stroke_alpha = stroke_alpha.to_f @fill_alpha = fill_alpha.to_f @blend_mode = blend_mode @soft_mask = soft_mask @overprint = overprint @overprint_mode = overprint_mode.to_i end |
Instance Attribute Details
#alpha_is_shape ⇒ Object (readonly)
Returns the value of attribute alpha_is_shape.
10 11 12 |
# File 'lib/pdfrb/content/graphics_state.rb', line 10 def alpha_is_shape @alpha_is_shape end |
#blend_mode ⇒ Object (readonly)
Returns the value of attribute blend_mode.
10 11 12 |
# File 'lib/pdfrb/content/graphics_state.rb', line 10 def blend_mode @blend_mode end |
#ctm ⇒ Object (readonly)
Returns the value of attribute ctm.
10 11 12 |
# File 'lib/pdfrb/content/graphics_state.rb', line 10 def ctm @ctm end |
#dash_pattern ⇒ Object (readonly)
Returns the value of attribute dash_pattern.
10 11 12 |
# File 'lib/pdfrb/content/graphics_state.rb', line 10 def dash_pattern @dash_pattern end |
#fill_alpha ⇒ Object (readonly)
Returns the value of attribute fill_alpha.
10 11 12 |
# File 'lib/pdfrb/content/graphics_state.rb', line 10 def fill_alpha @fill_alpha end |
#fill_color ⇒ Object (readonly)
Returns the value of attribute fill_color.
10 11 12 |
# File 'lib/pdfrb/content/graphics_state.rb', line 10 def fill_color @fill_color end |
#flatness ⇒ Object (readonly)
Returns the value of attribute flatness.
10 11 12 |
# File 'lib/pdfrb/content/graphics_state.rb', line 10 def flatness @flatness end |
#line_cap ⇒ Object (readonly)
Returns the value of attribute line_cap.
10 11 12 |
# File 'lib/pdfrb/content/graphics_state.rb', line 10 def line_cap @line_cap end |
#line_join ⇒ Object (readonly)
Returns the value of attribute line_join.
10 11 12 |
# File 'lib/pdfrb/content/graphics_state.rb', line 10 def line_join @line_join end |
#line_width ⇒ Object (readonly)
Returns the value of attribute line_width.
10 11 12 |
# File 'lib/pdfrb/content/graphics_state.rb', line 10 def line_width @line_width end |
#miter_limit ⇒ Object (readonly)
Returns the value of attribute miter_limit.
10 11 12 |
# File 'lib/pdfrb/content/graphics_state.rb', line 10 def miter_limit @miter_limit end |
#overprint ⇒ Object (readonly)
Returns the value of attribute overprint.
10 11 12 |
# File 'lib/pdfrb/content/graphics_state.rb', line 10 def overprint @overprint end |
#overprint_mode ⇒ Object (readonly)
Returns the value of attribute overprint_mode.
10 11 12 |
# File 'lib/pdfrb/content/graphics_state.rb', line 10 def overprint_mode @overprint_mode end |
#soft_mask ⇒ Object (readonly)
Returns the value of attribute soft_mask.
10 11 12 |
# File 'lib/pdfrb/content/graphics_state.rb', line 10 def soft_mask @soft_mask end |
#stroke_alpha ⇒ Object (readonly)
Returns the value of attribute stroke_alpha.
10 11 12 |
# File 'lib/pdfrb/content/graphics_state.rb', line 10 def stroke_alpha @stroke_alpha end |
#stroke_color ⇒ Object (readonly)
Returns the value of attribute stroke_color.
10 11 12 |
# File 'lib/pdfrb/content/graphics_state.rb', line 10 def stroke_color @stroke_color end |
#text_state ⇒ Object (readonly)
Returns the value of attribute text_state.
10 11 12 |
# File 'lib/pdfrb/content/graphics_state.rb', line 10 def text_state @text_state end |
Instance Method Details
#to_h ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/pdfrb/content/graphics_state.rb', line 50 def to_h { ctm: @ctm, text_state: @text_state, fill_color: @fill_color, stroke_color: @stroke_color, line_width: @line_width, line_cap: @line_cap, line_join: @line_join, miter_limit: @miter_limit, dash_pattern: @dash_pattern, flatness: @flatness, alpha_is_shape: @alpha_is_shape, stroke_alpha: @stroke_alpha, fill_alpha: @fill_alpha, blend_mode: @blend_mode, soft_mask: @soft_mask, overprint: @overprint, overprint_mode: @overprint_mode } end |
#with(**overrides) ⇒ Object
Returns a new GraphicsState with the given overrides (the original is frozen).
46 47 48 |
# File 'lib/pdfrb/content/graphics_state.rb', line 46 def with(**overrides) GraphicsState.new(**to_h.merge(overrides)) end |