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 31
31:       def dash(length=nil, options={})
32:         return @dash || undash_hash if length.nil?
33: 
34:         @dash = { :dash  => length, 
35:                   :space => options[:space] || length, 
36:                   :phase => options[:phase] || 0 }
37: 
38:         write_stroke_dash
39:       end
Also aliased as: dash=
dash=(length=nil, options={}) click to toggle source
Alias for: dash
dashed?() click to toggle source

Returns when stroke is dashed, false otherwise

    # File lib/prawn/graphics/dash.rb, line 52
52:       def dashed?
53:         dash != undash_hash
54:       end
undash() click to toggle source

Stops dashing, restoring solid stroked lines and curves

    # File lib/prawn/graphics/dash.rb, line 45
45:       def undash
46:         @dash = undash_hash
47:         write_stroke_dash
48:       end

Private Instance Methods

undash_hash() click to toggle source
    # File lib/prawn/graphics/dash.rb, line 58
58:       def undash_hash
59:         { :dash => nil, :space => nil, :phase => 0 }
60:       end
write_stroke_dash() click to toggle source
    # File lib/prawn/graphics/dash.rb, line 62
62:       def write_stroke_dash
63:         if @dash[:dash].nil?
64:           add_content "[] 0 d"
65:           return
66:         end
67:         add_content "[#{@dash[:dash]} #{@dash[:space]}] #{@dash[:phase]} d"
68:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.