Class: Triangle

Inherits:
Object
  • Object
show all
Defined in:
lib/r2d/triangle.rb

Overview

triangle.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(x1, y1, x2, y2, x3, y3, c = "white", visible = true) ⇒ Triangle

Returns a new instance of Triangle.



10
11
12
13
14
15
16
17
# File 'lib/r2d/triangle.rb', line 10

def initialize(x1, y1, x2, y2, x3, y3, c="white", visible=true)
  @x1, @y1 = x1, y1
  @x2, @y2 = x2, y2
  @x3, @y3 = x3, y3
  @color = c
  update_color(c)
  if visible then add end
end

Instance Attribute Details

#c1Object

Returns the value of attribute c1.



5
6
7
# File 'lib/r2d/triangle.rb', line 5

def c1
  @c1
end

#c2Object

Returns the value of attribute c2.



5
6
7
# File 'lib/r2d/triangle.rb', line 5

def c2
  @c2
end

#c3Object

Returns the value of attribute c3.



5
6
7
# File 'lib/r2d/triangle.rb', line 5

def c3
  @c3
end

#colorObject

Returns the value of attribute color.



8
9
10
# File 'lib/r2d/triangle.rb', line 8

def color
  @color
end

#x1Object

Returns the value of attribute x1.



5
6
7
# File 'lib/r2d/triangle.rb', line 5

def x1
  @x1
end

#x2Object

Returns the value of attribute x2.



5
6
7
# File 'lib/r2d/triangle.rb', line 5

def x2
  @x2
end

#x3Object

Returns the value of attribute x3.



5
6
7
# File 'lib/r2d/triangle.rb', line 5

def x3
  @x3
end

#y1Object

Returns the value of attribute y1.



5
6
7
# File 'lib/r2d/triangle.rb', line 5

def y1
  @y1
end

#y2Object

Returns the value of attribute y2.



5
6
7
# File 'lib/r2d/triangle.rb', line 5

def y2
  @y2
end

#y3Object

Returns the value of attribute y3.



5
6
7
# File 'lib/r2d/triangle.rb', line 5

def y3
  @y3
end

Instance Method Details

#addObject



24
25
26
# File 'lib/r2d/triangle.rb', line 24

def add
  R2D::Window.add(self)
end

#removeObject



28
29
30
# File 'lib/r2d/triangle.rb', line 28

def remove
  R2D::Window.remove(self)
end