require 'cairo' format = Cairo::FORMAT_ARGB32 width = 300 height = 200 radius = height / 3 # 半径 # surface = Cairo::ImageSurface.new(format, width, height) surface = Cairo::SVGSurface.new("japan6.svg", width, height) context = Cairo::Context.new(surface) # 背景と枠 context.set_source_rgb(1, 1, 1) # 白 context.rectangle(0, 0, width, height) context.fill context.set_source_rgb(0.5,0.5,0.5) # 灰 context.rectangle(0, 0, width, height) context.stroke # 赤丸 context.set_source_rgb(1, 0, 0) # 赤 context.arc(width / 2, height / 2, radius, 0, 2 * Math::PI) context.fill surface.write_to_png("japan6.png")