Sha256: 58458f842c0874626705e568301358669742055536af58bc6c74d554ab88f83c

Contents?: true

Size: 884 Bytes

Versions: 1

Compression:

Stored size: 884 Bytes

Contents

# frozen_string_literal: true

# 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_relative '../example_helper'

filename = File.basename(__FILE__).gsub('.rb', '.pdf')
Prawn::ManualBuilder::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

1 entries across 1 versions & 1 rubygems

Version Path
prawn-2.3.0 manual/bounding_box/canvas.rb