Sha256: 76466c75b4321b45d5d7747fb4adc4630b1b9a3202f7c0690ba0d5f7eb4b6b1b

Contents?: true

Size: 941 Bytes

Versions: 8

Compression:

Stored size: 941 Bytes

Contents

# encoding: utf-8
# 
# The origin example already mentions that a new document already comes with
# a margin box whose bottom left corner is used as the origin for calculating
# coordinates.
#
# What has not been told is that there is one helper for "bypassing" the margin
# box: <code>canvas</code>. This method is a shortcut for creating a bounding
# box mapped to the absolute coordinates and evaluating the code inside it.
#
# The following snippet draws a circle on each of the four absolute corners.
#
require File.expand_path(File.join(File.dirname(__FILE__),
                                   %w[.. example_helper]))

filename = File.basename(__FILE__).gsub('.rb', '.pdf')
Prawn::Example.generate(filename) do
  canvas do
    fill_circle [bounds.left, bounds.top],     30
    fill_circle [bounds.right, bounds.top],    30
    fill_circle [bounds.right, bounds.bottom], 30
    fill_circle [0, 0],                        30
  end
end

Version data entries

8 entries across 8 versions & 2 rubygems

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