Class: Ruby2D::Square

Inherits:
Rectangle show all
Defined in:
lib/ruby2d/square.rb

Instance Attribute Summary collapse

Attributes inherited from Rectangle

#height, #width, #x, #y

Attributes inherited from Quad

#c1, #c2, #c3, #c4, #color, #x1, #x2, #x3, #x4, #y1, #y2, #y3, #y4

Instance Method Summary collapse

Methods inherited from Quad

#remove

Constructor Details

#initialize(x = 0, y = 0, s = 100, c = 'white') ⇒ Square

Returns a new instance of Square.



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

def initialize(x=0, y=0, s=100, c='white')
  @type_id = 2
  @x, @y, @color = x, y, c
  @width = @height = @size = s
  update_coords(x, y, s, s)
  update_color(c)
  
  if defined? Ruby2D::DSL
    Ruby2D::Application.add(self)
  end
end

Instance Attribute Details

#sizeObject

Returns the value of attribute size.



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

def size
  @size
end