forked from practicingruby/prawn-layout
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added grid examples from AndrewO/prawn_grid. Closes practicingruby#6
- Loading branch information
1 parent
3c0253b
commit 30e4f83
Showing
3 changed files
with
85 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# encoding: utf-8 | ||
|
||
require "#{File.dirname(__FILE__)}/../example_helper.rb" | ||
|
||
Prawn::Document.generate('bounding_box_grid.pdf') do |p| | ||
p.define_grid(:columns => 5, :rows => 8, :gutter => 10) | ||
|
||
p.stroke_color = "ff0000" | ||
|
||
p.grid.rows.times do |i| | ||
p.grid.columns.times do |j| | ||
p.grid(i,j).bounding_box do | ||
p.text p.grid(i,j).name | ||
p.stroke do | ||
p.rectangle(p.bounds.top_left, p.bounds.width, p.bounds.height) | ||
end | ||
end | ||
end | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# encoding: utf-8 | ||
|
||
require "#{File.dirname(__FILE__)}/../example_helper.rb" | ||
|
||
Prawn::Document.generate('multi_boxes.pdf') do |p| | ||
p.define_grid(:columns => 5, :rows => 8, :gutter => 10) | ||
|
||
p.grid.rows.times do |i| | ||
p.grid.columns.times do |j| | ||
p.grid(i,j).bounding_box do | ||
p.text p.grid(i,j).name | ||
p.stroke_color = "cccccc" | ||
p.stroke do | ||
p.rectangle(p.bounds.top_left, p.bounds.width, p.bounds.height) | ||
end | ||
end | ||
end | ||
end | ||
|
||
g = p.grid([0,0], [1,1]) | ||
g.bounding_box do | ||
p.move_down 12 | ||
p.text g.name | ||
p.stroke_color = "333333" | ||
p.stroke do | ||
p.rectangle(p.bounds.top_left, p.bounds.width, p.bounds.height) | ||
end | ||
end | ||
|
||
g = p.grid([3,0], [3,3]) | ||
g.bounding_box do | ||
p.move_down 12 | ||
p.text g.name | ||
p.stroke_color = "333333" | ||
p.stroke do | ||
p.rectangle(p.bounds.top_left, p.bounds.width, p.bounds.height) | ||
end | ||
end | ||
|
||
g = p.grid([4,0], [5,1]) | ||
g.bounding_box do | ||
p.move_down 12 | ||
p.text g.name | ||
p.stroke_color = "333333" | ||
p.stroke do | ||
p.rectangle(p.bounds.top_left, p.bounds.width, p.bounds.height) | ||
end | ||
end | ||
|
||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# encoding: utf-8 | ||
|
||
require "#{File.dirname(__FILE__)}/../example_helper.rb" | ||
|
||
Prawn::Document.generate('show_grid.pdf') do |p| | ||
p.define_grid(:columns => 5, :rows => 8, :gutter => 10) | ||
|
||
p.grid.show_all | ||
|
||
p.grid(2,4).show("FF0000") | ||
p.grid([3,0], [5,3]).show("0000FF") | ||
end | ||
|