Module: Prawn::Graphics::Dash
- Included in:
- Prawn::Graphics
- Defined in:
- lib/prawn/graphics/dash.rb
Instance Method Summary collapse
-
#dash(length = nil, options = {}) ⇒ Object
(also: #dash=)
Sets the dash pattern for stroked lines and curves.
-
#dashed? ⇒ Boolean
Returns when stroke is dashed, false otherwise.
-
#undash ⇒ Object
Stops dashing, restoring solid stroked lines and curves.
- #write_stroke_dash ⇒ Object
Instance Method Details
#dash(length = nil, options = {}) ⇒ Object Also known as: dash=
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 )
31 32 33 34 35 36 37 38 39 |
# File 'lib/prawn/graphics/dash.rb', line 31 def dash(length=nil, ={}) return current_dash_state || undash_hash if length.nil? self.current_dash_state = { :dash => length, :space => [:space] || length, :phase => [:phase] || 0 } write_stroke_dash end |
#dashed? ⇒ Boolean
Returns when stroke is dashed, false otherwise
52 53 54 |
# File 'lib/prawn/graphics/dash.rb', line 52 def dashed? current_dash_state != undashed_setting end |
#undash ⇒ Object
Stops dashing, restoring solid stroked lines and curves
45 46 47 48 |
# File 'lib/prawn/graphics/dash.rb', line 45 def undash self.current_dash_state = undashed_setting write_stroke_dash end |
#write_stroke_dash ⇒ Object
56 57 58 |
# File 'lib/prawn/graphics/dash.rb', line 56 def write_stroke_dash add_content dash_setting end |