Sha256: a92c24c289093b410b0647912a78777c916d46b393cfe293f1ef1f71ee90f717

Contents?: true

Size: 545 Bytes

Versions: 4

Compression:

Stored size: 545 Bytes

Contents

class Prawn::SVG::Elements::Circle < Prawn::SVG::Elements::Base
  USE_NEW_CIRCLE_CALL = Prawn::Document.instance_methods.include?(:circle)

  def parse
    require_attributes 'r'

    @x = x(attributes['cx'] || "0")
    @y = y(attributes['cy'] || "0")
    @r = distance(attributes['r'])

    require_positive_value @r
  end

  def apply
    if USE_NEW_CIRCLE_CALL
      add_call "circle", [@x, @y], @r
    else
      add_call "circle_at", [@x, @y], radius: @r
    end
  end

  def bounding_box
    [@x - @r, @y + @r, @x + @r, @y - @r]
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
prawn-svg-0.24.0 lib/prawn/svg/elements/circle.rb
prawn-svg-0.23.1 lib/prawn/svg/elements/circle.rb
prawn-svg-0.23.0 lib/prawn/svg/elements/circle.rb
prawn-svg-0.22.1 lib/prawn/svg/elements/circle.rb