samples/text-on-path.rb in cairo-1.4.1 vs samples/text-on-path.rb in cairo-1.5.0
- old
+ new
@@ -7,11 +7,11 @@
require 'cairo'
require 'pango'
def render_background(cr)
- cr.set_source_rgba(1.0, 1.0, 1.0)
+ cr.set_source_color(:white)
cr.paint
end
def make_layout(cr, text)
layout = cr.create_pango_layout
@@ -26,11 +26,11 @@
cr = Cairo::Context.new(surface)
render_background(cr)
- cr.set_source_rgba(1, 0, 0, 1)
+ cr.set_source_color(:red)
cr.move_to(25, 350)
cr.line_to(150, 375)
cr.curve_to(275, 400, 450, 350, 450, 200)
cr.curve_to(450, 0, 300, 150, 50, 50)
cr.stroke_preserve
@@ -46,16 +46,15 @@
cr.fill_preserve
cr.set_source_rgba(0.1, 0.1, 0.1)
cr.stroke
cr.show_page
-
- cr
end
def output
- surface = Cairo::ImageSurface.new(500, 500)
- render(surface)
- surface.write_to_png("text-on-path.png")
+ Cairo::ImageSurface.new(500, 500) do |surface|
+ render(surface)
+ surface.write_to_png("text-on-path.png")
+ end
end
output