module Prawn::Graphics::Dash

Public Instance Methods

dash(length=nil, options={}) click to toggle source

Sets the dash pattern for stroked lines and curves

length is the length of the dash. If options is not present,
or options[:space] is nil, then length is also the length of
the space between dashes

options may contain :space and :phase
   :space is the space between the dashes
   :phase is where in the cycle to begin dashing. For
          example, a phase of 0 starts at the beginning of
          the dash; whereas, if the phase is equal to the
          length of the dash, then stroking will begin at
          the beginning of the space. Default is 0

integers or floats may be used for length and the options

dash units are in PDF points ( 1/72 in )
# File lib/prawn/graphics/dash.rb, line 30
def dash(length=nil, options={})        
  return current_dash_state || undash_hash if length.nil?

  self.current_dash_state = { :dash  => length, 
            :space => options[:space] || length, 
            :phase => options[:phase] || 0 }

  write_stroke_dash
end
Also aliased as: dash=
dash=(length=nil, options={})
Alias for: dash
dashed?() click to toggle source

Returns when stroke is dashed, false otherwise

# File lib/prawn/graphics/dash.rb, line 51
def dashed?
  current_dash_state != undashed_setting
end
undash() click to toggle source

Stops dashing, restoring solid stroked lines and curves

# File lib/prawn/graphics/dash.rb, line 44
def undash
  self.current_dash_state = undashed_setting
  write_stroke_dash
end
write_stroke_dash() click to toggle source
# File lib/prawn/graphics/dash.rb, line 55
def write_stroke_dash
  add_content dash_setting
end

Private Instance Methods

current_dash_state() click to toggle source
# File lib/prawn/graphics/dash.rb, line 71
def current_dash_state
  graphic_state.dash
end
current_dash_state=(dash_options) click to toggle source
# File lib/prawn/graphics/dash.rb, line 67
def current_dash_state=(dash_options)  
  graphic_state.dash = dash_options
end
dash_setting() click to toggle source
# File lib/prawn/graphics/dash.rb, line 75
def dash_setting
  graphic_state.dash_setting
end
undashed_setting() click to toggle source
# File lib/prawn/graphics/dash.rb, line 61
def undashed_setting
  { :dash => nil, :space => nil, :phase => 0 }
end