Sha256: fe7701d1538d7c07ffbf23bc2d17cbb9d2ffd09255988a42049223dedddfd56d

Contents?: true

Size: 1.01 KB

Versions: 20

Compression:

Stored size: 1.01 KB

Contents

# encoding: utf-8
#
# Stroke dashing can be applied to any line or curve

require "#{File.dirname(__FILE__)}/../example_helper.rb"

Prawn::Document.generate("stroke_dash.pdf") do
  self.line_width = 1
  base_y = bounds.top

  100.times do |i|
    length = i / 4 + 1
    # space between dashes same length as dash
    space = length
    # start with dash
    phase = 0
    case i % 4
    when 0
      base_y -= 10
    when 1
      # start with space between dashes
      phase = length
    when 2
      base_y -= 10
      # space between dashes half as long as dash
      space = length * 0.5
    when 3
      # space between dashes half as long as dash
      space = length * 0.5
      # start with space between dashes
      phase = length
    end
    dash(length, :space => space, :phase => phase)
    points = [bounds.left, base_y - 2 * i, bounds.right, base_y - 2 * i]
    stroke_line(points)
  end
  i = 100
  base_y -= 10
  undash
  points = [bounds.left, base_y - 2 * i, bounds.right, base_y - 2 * i]
  stroke_line(points)
end

Version data entries

20 entries across 20 versions & 7 rubygems

Version Path
piglop-prawn-0.10.2.3 examples/graphics/stroke_dash.rb
piglop-prawn-0.10.2.2 examples/graphics/stroke_dash.rb
piglop-prawn-0.10.2.1 examples/graphics/stroke_dash.rb
prawn-0.11.1.pre examples/graphics/stroke_dash.rb
goodwill-prawn-edge-0.10.0 examples/graphics/stroke_dash.rb
alphasights-prawn-0.10.4 examples/graphics/stroke_dash.rb
alphasights-prawn-0.10.3 examples/graphics/stroke_dash.rb
alphasights-prawn-0.10.2 examples/graphics/stroke_dash.rb
alphasights-prawn-0.10.1 examples/graphics/stroke_dash.rb
alphasights-prawn-0.10.0 examples/graphics/stroke_dash.rb
prawn-core-0.8.4 examples/graphics/stroke_dash.rb
prawn-graph-0.0.2 vendor/prawn-core/examples/graphics/stroke_dash.rb
prawn-graph-0.0.1 vendor/prawn-core/examples/graphics/stroke_dash.rb
prawn-core-0.7.2 examples/graphics/stroke_dash.rb
prawn-core-0.7.1 examples/graphics/stroke_dash.rb
prawn-layout-0.3.2 vendor/prawn-core/examples/graphics/stroke_dash.rb
prawn-core-0.6.3 examples/graphics/stroke_dash.rb
prawn-core-0.6.2 examples/graphics/stroke_dash.rb
prawn-layout-0.3.1 vendor/prawn-core/examples/graphics/stroke_dash.rb
prawn-core-0.6.1 examples/graphics/stroke_dash.rb