Class: Ruby2D::Circle

Inherits:
Object
  • Object
show all
Includes:
Renderable
Defined in:
lib/ruby2d/circle.rb

Instance Attribute Summary collapse

Attributes included from Renderable

#z

Instance Method Summary collapse

Methods included from Renderable

#a, #a=, #add, #b, #b=, #colour, #colour=, #g, #g=, #opacity, #opacity=, #r, #r=, #remove

Constructor Details

#initialize(opts = {}) ⇒ Circle



10
11
12
13
14
15
16
17
18
# File 'lib/ruby2d/circle.rb', line 10

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'
  add
end

Instance Attribute Details

#colorObject

Returns the value of attribute color.



7
8
9
# File 'lib/ruby2d/circle.rb', line 7

def color
  @color
end

#radiusObject

Returns the value of attribute radius.



8
9
10
# File 'lib/ruby2d/circle.rb', line 8

def radius
  @radius
end

#sectorsObject

Returns the value of attribute sectors.



8
9
10
# File 'lib/ruby2d/circle.rb', line 8

def sectors
  @sectors
end

#xObject

Returns the value of attribute x.



8
9
10
# File 'lib/ruby2d/circle.rb', line 8

def x
  @x
end

#yObject

Returns the value of attribute y.



8
9
10
# File 'lib/ruby2d/circle.rb', line 8

def y
  @y
end

Instance Method Details

#contains?(x, y) ⇒ Boolean



24
25
26
# File 'lib/ruby2d/circle.rb', line 24

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