Skip to content

Instantly share code, notes, and snippets.

@mat813
Created April 18, 2011 17:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mat813/925733 to your computer and use it in GitHub Desktop.
Save mat813/925733 to your computer and use it in GitHub Desktop.
def lines_grid(s1=10, s2=100)
save_graphics_state do
stroke_color('EEEEEE')
fill_color('000000')
stroke do
line_width(0.5)
0.step(bounds.right, s1).each do |i|
line([i, 0], [i, bounds.top]) if (i%s2 != 0)
end
0.step(bounds.top, s1).each do |i|
line([0, i], [bounds.right, i]) if (i%s2 != 0)
end
end
stroke do
stroke_color('CCCCCC')
line_width(0.75)
0.step(bounds.right, s2).each do |i|
line([i, 0], [i, bounds.top])
end
0.step(bounds.top, s2).each do |i|
line([0, i], [bounds.right, i])
end
end
font('Helvetica', :size => 6) do
s1.step(bounds.right, s1).each do |i|
draw_text(i.to_i, :at => [i, 2], :rotate => 90)
end
s1.step(bounds.top, s1).each do |i|
draw_text(i.to_i, :at => [2, i])
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment