Sha256: c3d243029173b11a32906c12c4f4b8ed40ec29340fcbb02def3e8c30b9559c9b

Contents?: true

Size: 502 Bytes

Versions: 1

Compression:

Stored size: 502 Bytes

Contents

# Ruby2D::Circle

module Ruby2D
  class Circle
    include Renderable

    attr_accessor :radius, :sectors

    def initialize(opts = {})
      @x = opts[:x] || 25
      @y = opts[:y] || 25
      @z = opts[:z] || 0
      @radius = opts[:radius] || 25
      @sectors = opts[:sectors] || 20
      self.color = opts[:color] || 'white'
      self.opacity = opts[:opacity] if opts[:opacity]
      add
    end

    def contains?(x, y)
      Math.sqrt((x - @x)**2 + (y - @y)**2) <= @radius
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ruby2d-0.8.0 lib/ruby2d/circle.rb