### Home Classes Methods

### In Files

- lib/prawn/graphics/dash.rb

### Methods

- #dash
- #dash=
- #dashed?
- #undash

### Class/Module Index

Quicksearch

- Prawn
- Prawn::Configurable
- Prawn::Document
- Prawn::Document::BoundingBox
- Prawn::Document::ColumnBox
- Prawn::Document::GraphicsState
- Prawn::Document::Grid
- Prawn::Document::GridBox
- Prawn::Document::Internals
- Prawn::Document::Security
- Prawn::Document::Snapshot
- Prawn::Encoding
- Prawn::Errors
- Prawn::Font
- Prawn::Font::AFM
- Prawn::Font::DFont
- Prawn::Font::TTF
- Prawn::FontMetricCache
- Prawn::Graphics
- Prawn::Graphics::CapStyle
- Prawn::Graphics::Color
- Prawn::Graphics::Dash
- Prawn::Graphics::JoinStyle
- Prawn::Graphics::Patterns
- Prawn::Graphics::Transformation
- Prawn::Graphics::Transparency
- Prawn::ImageHandler
- Prawn::Images
- Prawn::Images::Image
- Prawn::Images::JPG
- Prawn::Images::PNG
- Prawn::Measurements
- Prawn::SoftMask
- Prawn::Stamp
- Prawn::SynchronizedCache
- Prawn::Table
- Prawn::Table::Cell
- Prawn::Table::Cell::Image
- Prawn::Table::Cell::InTable
- Prawn::Table::Cell::SpanDummy
- Prawn::Table::Cell::Subtable
- Prawn::Table::Cell::Text
- Prawn::Table::Cells
- Prawn::Table::ColumnWidthCalculator
- Prawn::Text
- Prawn::Text::Box
- Prawn::Text::Formatted
- Prawn::Text::Formatted::Box
- Prawn::Text::Formatted::Fragment
- Prawn::Text::Formatted::Parser
- Prawn::ThreadLocalCache
- PDF
- PDF::Core
- PDF::Core::Reference
- PDF::Core::Stream
- Arcfour
- Numeric

No matching classes.

# Prawn::Graphics::Dash

### Public Instance Methods

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

Sets the dash pattern for stroked lines and curves or return the current dash pattern setting if `length` is nil.

There are two ways to set the dash pattern:

- If the parameter `length` is an Integer/Float, it specifies the length of the dash and of the gap. The length of the gap can be customized by setting the :space option.

  Examples:

      length = 3
        3 on, 3 off, 3 on, 3 off, ...
      length = 3, :space =2
        3 on, 2 off, 3 on, 2 off, ...

- If the parameter `length` is an array, it specifies the lengths of alternating dashes and gaps. The :space option is ignored in this case.

  Examples:

      length = [2, 1]
        2 on, 1 off, 2 on, 1 off, ...
      length = [3, 1, 2, 3]
        3 on, 1 off, 2 on, 3 off, 3 on, 1 off, ...

Options may contain the keys :space and :phase

:space | The space between the dashes (only used when `length` is not an array)
:phase | The distance into the dash pattern at which to start the dash. 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 option values. Dash units are in PDF points (1/72 inch).

    # File lib/prawn/graphics/dash.rb, line 54
    def dash(length=nil, options={})
      return current_dash_state if length.nil?

      self.current_dash_state = { :dash  => length,
                :space => length.kind_of?(Array) ? nil : options[:space] || length,
                :phase => options[:phase] || 0 }

      write_stroke_dash
    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 75
    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 68
    def undash
      self.current_dash_state = undashed_setting
      write_stroke_dash
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.