Class: Ruby2D::Quad

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

Direct Known Subclasses

Rectangle

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(x1 = 0, y1 = 0, x2 = 100, y2 = 0, x3 = 100, y3 = 100, x4 = 100, y4 = 100, c = 'white') ⇒ Quad

Returns a new instance of Quad.



17
18
19
20
21
22
23
# File 'lib/ruby2d/quad.rb', line 17

def initialize(x1=0, y1=0, x2=100, y2=0, x3=100, y3=100, x4=100, y4=100, c='white')
  @type_id = 2
  @x1, @y1, @x2, @y2, @x3, @y3, @x4, @y4 = x1, y1, x2, y2, x3, y3, x4, y4
  @color = c
  update_color(c)
  add
end

Instance Attribute Details

#c1Object

Coordinates in clockwise order, starting at top left: x1,y1 == top left x2,y2 == top right x3,y3 == bottom right x4,y4 == bottom left



10
11
12
# File 'lib/ruby2d/quad.rb', line 10

def c1
  @c1
end

#c2Object

Coordinates in clockwise order, starting at top left: x1,y1 == top left x2,y2 == top right x3,y3 == bottom right x4,y4 == bottom left



10
11
12
# File 'lib/ruby2d/quad.rb', line 10

def c2
  @c2
end

#c3Object

Coordinates in clockwise order, starting at top left: x1,y1 == top left x2,y2 == top right x3,y3 == bottom right x4,y4 == bottom left



10
11
12
# File 'lib/ruby2d/quad.rb', line 10

def c3
  @c3
end

#c4Object

Coordinates in clockwise order, starting at top left: x1,y1 == top left x2,y2 == top right x3,y3 == bottom right x4,y4 == bottom left



10
11
12
# File 'lib/ruby2d/quad.rb', line 10

def c4
  @c4
end

#colorObject

Returns the value of attribute color.



15
16
17
# File 'lib/ruby2d/quad.rb', line 15

def color
  @color
end

#x1Object

Coordinates in clockwise order, starting at top left: x1,y1 == top left x2,y2 == top right x3,y3 == bottom right x4,y4 == bottom left



10
11
12
# File 'lib/ruby2d/quad.rb', line 10

def x1
  @x1
end

#x2Object

Coordinates in clockwise order, starting at top left: x1,y1 == top left x2,y2 == top right x3,y3 == bottom right x4,y4 == bottom left



10
11
12
# File 'lib/ruby2d/quad.rb', line 10

def x2
  @x2
end

#x3Object

Coordinates in clockwise order, starting at top left: x1,y1 == top left x2,y2 == top right x3,y3 == bottom right x4,y4 == bottom left



10
11
12
# File 'lib/ruby2d/quad.rb', line 10

def x3
  @x3
end

#x4Object

Coordinates in clockwise order, starting at top left: x1,y1 == top left x2,y2 == top right x3,y3 == bottom right x4,y4 == bottom left



10
11
12
# File 'lib/ruby2d/quad.rb', line 10

def x4
  @x4
end

#y1Object

Coordinates in clockwise order, starting at top left: x1,y1 == top left x2,y2 == top right x3,y3 == bottom right x4,y4 == bottom left



10
11
12
# File 'lib/ruby2d/quad.rb', line 10

def y1
  @y1
end

#y2Object

Coordinates in clockwise order, starting at top left: x1,y1 == top left x2,y2 == top right x3,y3 == bottom right x4,y4 == bottom left



10
11
12
# File 'lib/ruby2d/quad.rb', line 10

def y2
  @y2
end

#y3Object

Coordinates in clockwise order, starting at top left: x1,y1 == top left x2,y2 == top right x3,y3 == bottom right x4,y4 == bottom left



10
11
12
# File 'lib/ruby2d/quad.rb', line 10

def y3
  @y3
end

#y4Object

Coordinates in clockwise order, starting at top left: x1,y1 == top left x2,y2 == top right x3,y3 == bottom right x4,y4 == bottom left



10
11
12
# File 'lib/ruby2d/quad.rb', line 10

def y4
  @y4
end

Instance Method Details

#addObject



30
31
32
33
34
# File 'lib/ruby2d/quad.rb', line 30

def add
  if Module.const_defined? :DSL
    Application.add(self)
  end
end

#removeObject



36
37
38
39
40
# File 'lib/ruby2d/quad.rb', line 36

def remove
  if Module.const_defined? :DSL
    Application.remove(self)
  end
end