Sha256: 24c78cd037e47c2f9d1558748112124e17cf757d94b8536abf5edc633b6a35c9
Contents?: true
Size: 1.58 KB
Versions: 13
Compression:
Stored size: 1.58 KB
Contents
# encoding: utf-8 # # Demonstrates transformations # require "#{File.dirname(__FILE__)}/../example_helper.rb" Prawn::Document.generate "transformations.pdf" do |pdf| width = 50 height = 100 # ROTATION x = 50 y = pdf.bounds.top - 50 pdf.stroke_rectangle([x, y], width, height) pdf.draw_text("reference rectangle", :at => [x + width, y - height]) pdf.rotate(30, :origin => [x, y]) do pdf.stroke_rectangle([x, y], width, height) pdf.draw_text("rectangle rotated around upper-left corner", :at => [x + width, y - height]) end x = 50 y = pdf.bounds.top - 200 pdf.stroke_rectangle([x, y], width, height) pdf.draw_text("reference rectangle", :at => [x + width, y - height]) pdf.rotate(30, :origin => [x + width / 2, y - height / 2]) do pdf.stroke_rectangle([x, y], width, height) pdf.draw_text("rectangle rotated around center", :at => [x + width, y - height]) end # SCALE x = 0 y = pdf.bounds.top - 500 pdf.stroke_rectangle([x, y], width, height) pdf.draw_text("reference rectangle", :at => [x + width, y - height]) pdf.scale(2, :origin => [x, y]) do pdf.stroke_rectangle([x, y], width, height) pdf.draw_text("rectangle scaled from upper-left corner", :at => [x + width, y - height]) end x = 150 y = pdf.bounds.top - 400 pdf.stroke_rectangle([x, y], width, height) pdf.draw_text("reference rectangle", :at => [x + width, y - height]) pdf.scale(2, :origin => [x + width / 2, y - height / 2]) do pdf.stroke_rectangle([x, y], width, height) pdf.draw_text("rectangle scaled from center", :at => [x + width, y - height]) end end
Version data entries
13 entries across 13 versions & 6 rubygems