Class: Ruby2D::Triangle

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(x1 = 50, y1 = 0, x2 = 100, y2 = 100, x3 = 0, y3 = 100, c = 'white') ⇒ Triangle

Returns a new instance of Triangle.



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/ruby2d/triangle.rb', line 11

def initialize(x1=50, y1=0, x2=100, y2=100, x3=0, y3=100, c='white')
  @type_id = 1
  @x1, @y1 = x1, y1
  @x2, @y2 = x2, y2
  @x3, @y3 = x3, y3
  @color = c
  update_color(c)
  
  if defined? Ruby2D::DSL
    Ruby2D::Application.add(self)
  end
end

Instance Attribute Details

#c1Object

Returns the value of attribute c1.



6
7
8
# File 'lib/ruby2d/triangle.rb', line 6

def c1
  @c1
end

#c2Object

Returns the value of attribute c2.



6
7
8
# File 'lib/ruby2d/triangle.rb', line 6

def c2
  @c2
end

#c3Object

Returns the value of attribute c3.



6
7
8
# File 'lib/ruby2d/triangle.rb', line 6

def c3
  @c3
end

#colorObject

Returns the value of attribute color.



9
10
11
# File 'lib/ruby2d/triangle.rb', line 9

def color
  @color
end

#x1Object

Returns the value of attribute x1.



6
7
8
# File 'lib/ruby2d/triangle.rb', line 6

def x1
  @x1
end

#x2Object

Returns the value of attribute x2.



6
7
8
# File 'lib/ruby2d/triangle.rb', line 6

def x2
  @x2
end

#x3Object

Returns the value of attribute x3.



6
7
8
# File 'lib/ruby2d/triangle.rb', line 6

def x3
  @x3
end

#y1Object

Returns the value of attribute y1.



6
7
8
# File 'lib/ruby2d/triangle.rb', line 6

def y1
  @y1
end

#y2Object

Returns the value of attribute y2.



6
7
8
# File 'lib/ruby2d/triangle.rb', line 6

def y2
  @y2
end

#y3Object

Returns the value of attribute y3.



6
7
8
# File 'lib/ruby2d/triangle.rb', line 6

def y3
  @y3
end

Instance Method Details

#removeObject



29
30
31
32
33
# File 'lib/ruby2d/triangle.rb', line 29

def remove
  if defined? Ruby2D::DSL
    Ruby2D::Application.remove(self)
  end
end