Sha256: 8d7ecd61d99cff3599bc2d51f7c32e619d89dac0059092c03478e92dec5d0a0f

Contents?: true

Size: 912 Bytes

Versions: 8

Compression:

Stored size: 912 Bytes

Contents

# encoding: utf-8
#
# Drawing polygons in Prawn is easy, just pass a sequence of points to one of
# the polygon family of methods.
#
# Just like <code>rounded_rectangle</code> we also have
# <code>rounded_polygon</code>. The only difference is the radius param comes
# before the polygon points.
#
require File.expand_path(File.join(File.dirname(__FILE__),
                                   %w[.. example_helper]))

filename = File.basename(__FILE__).gsub('.rb', '.pdf')
Prawn::Example.generate(filename) do
  stroke_axis

  # Triangle
  stroke_polygon [50, 200], [50, 300], [150, 300]
  
  # Hexagon
  fill_polygon [50, 150], [150, 200], [250, 150],
               [250, 50], [150, 0], [50, 50]
  
  # Pentagram
  pentagon_points = [500, 100], [430, 5], [319, 41], [319, 159], [430, 195]
  pentagram_points = [0, 2, 4, 1, 3].map{ |i| pentagon_points[i] }
  
  stroke_rounded_polygon(20, *pentagram_points)
end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
prawn-1.0.0 manual/graphics/polygon.rb
prawn-0.15.0 manual/graphics/polygon.rb
prawn-0.14.0 manual/graphics/polygon.rb
prawn-0.13.2 manual/graphics/polygon.rb
prawn-0.13.1 manual/graphics/polygon.rb
prawn-0.13.0 manual/graphics/polygon.rb
prawn-1.0.0.rc2 manual/graphics/polygon.rb
nurettin-prawn-1.0.0.rc1 manual/graphics/polygon.rb