lib/prawn/svg/parser.rb in prawn-svg-0.9.1.10 vs lib/prawn/svg/parser.rb in prawn-svg-0.9.1.11

- old
+ new

@@ -57,10 +57,13 @@ "circle" => %w(r), "ellipse" => %w(rx ry), "rect" => %w(width height), "path" => %w(d) } + + USE_NEW_CIRCLE_CALL = Prawn::Document.new.respond_to?(:circle) + USE_NEW_ELLIPSE_CALL = Prawn::Document.new.respond_to?(:ellipse) def parse_element(element) attrs = element.attributes if required_attributes = REQUIRED_ATTRIBUTES[element.name] @@ -104,14 +107,19 @@ [x(x), y(y)] end element.add_call "polygon", *points when 'circle' - element.add_call "circle_at", - [x(attrs['cx'] || "0"), y(attrs['cy'] || "0")], :radius => distance(attrs['r']) - + if USE_NEW_CIRCLE_CALL + element.add_call "circle", + [x(attrs['cx'] || "0"), y(attrs['cy'] || "0")], distance(attrs['r']) + else + element.add_call "circle_at", + [x(attrs['cx'] || "0"), y(attrs['cy'] || "0")], :radius => distance(attrs['r']) + end + when 'ellipse' - element.add_call "ellipse_at", + element.add_call USE_NEW_ELLIPSE_CALL ? "ellipse" : "ellipse_at", [x(attrs['cx'] || "0"), y(attrs['cy'] || "0")], distance(attrs['rx']), distance(attrs['ry']) when 'rect' radius = distance(attrs['rx'] || attrs['ry']) args = [[x(attrs['x'] || '0'), y(attrs['y'] || '0')], distance(attrs['width']), distance(attrs['height'])]