Class: PDF::Core::GraphicState

Inherits:
Object
  • Object
show all
Defined in:
lib/pdf/core/graphics_state.rb

Overview

NOTE: This class may be a good candidate for a copy-on-write hash.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(previous_state = nil) ⇒ GraphicState

Returns a new instance of GraphicState.



51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/pdf/core/graphics_state.rb', line 51

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_styleObject

Returns the value of attribute cap_style.



48
49
50
# File 'lib/pdf/core/graphics_state.rb', line 48

def cap_style
  @cap_style
end

#color_spaceObject

Returns the value of attribute color_space.



48
49
50
# File 'lib/pdf/core/graphics_state.rb', line 48

def color_space
  @color_space
end

#dashObject

Returns the value of attribute dash.



48
49
50
# File 'lib/pdf/core/graphics_state.rb', line 48

def dash
  @dash
end

#fill_colorObject

Returns the value of attribute fill_color.



48
49
50
# File 'lib/pdf/core/graphics_state.rb', line 48

def fill_color
  @fill_color
end

#join_styleObject

Returns the value of attribute join_style.



48
49
50
# File 'lib/pdf/core/graphics_state.rb', line 48

def join_style
  @join_style
end

#line_widthObject

Returns the value of attribute line_width.



48
49
50
# File 'lib/pdf/core/graphics_state.rb', line 48

def line_width
  @line_width
end

#stroke_colorObject

Returns the value of attribute stroke_color.



48
49
50
# File 'lib/pdf/core/graphics_state.rb', line 48

def stroke_color
  @stroke_color
end

Instance Method Details

#dash_settingObject



65
66
67
68
69
70
71
# File 'lib/pdf/core/graphics_state.rb', line 65

def dash_setting
  if @dash[:dash].kind_of?(Array)
    "[#{@dash[:dash].join(' ')}] #{@dash[:phase]} d"
  else
    "[#{@dash[:dash]} #{@dash[:space]}] #{@dash[:phase]} d"
  end
end