Skip to content

Instantly share code, notes, and snippets.

@practicingruby
Created June 8, 2010 15:07
Show Gist options
  • Select an option

  • Save practicingruby/430155 to your computer and use it in GitHub Desktop.

Select an option

Save practicingruby/430155 to your computer and use it in GitHub Desktop.
def paint(canvas, filename)
doc = Prawn::Document.new
doc.add_content(canvas.to_pdf)
doc.render_file(filename)
end
canvas = Prawn::Canvas.new
canvas.line(:point1 => [100,100], :point2 => [150,175])
canvas.move_to(:point => [100,100])
canvas.curve_to(:point => [50,50], :bounds => [[60,90], [60,90]])
canvas.stroke
paint(canvas, "x.pdf")
canvas.find_chunks(:command => :line).first[:point2] = [150, 300]
paint(canvas, "y.pdf")
`open x.pdf y.pdf`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment