Class: Rectangle

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

Overview

rectangle.rb

Direct Known Subclasses

Square

Instance Attribute Summary collapse

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

#add, #remove

Constructor Details

#initialize(x, y, w, h, c = "white", visible = true) ⇒ Rectangle

Returns a new instance of Rectangle.



7
8
9
10
11
12
# File 'lib/r2d/rectangle.rb', line 7

def initialize(x, y, w, h, c="white", visible=true)
  @x, @y, @width, @height, @color = x, y, w, h, c
  update_coords(x, y, w, h)
  update_color(c)
  if visible then add end
end

Instance Attribute Details

#heightObject

Returns the value of attribute height.



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

def height
  @height
end

#widthObject

Returns the value of attribute width.



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

def width
  @width
end

#xObject

Returns the value of attribute x.



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

def x
  @x
end

#yObject

Returns the value of attribute y.



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

def y
  @y
end

Instance Method Details

#gradient=(g) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/r2d/rectangle.rb', line 38

def gradient=(g)
  if g[:top]
    # r, g, b, a = R2D::Color.rgba(g[:top])
    # @c1 = @c2 = R2D::Window.get_color(r, g, b, a)
  end
  
  p g.class
  
  # if g[:bottom]
  #   r, g, b, a = R2D::Color.rgba(g[:bottom])
  #   @c3 = @c4 = R2D::Window.get_color(r, g, b, a)
  # end
  
  # if g[:left]
  #   r, g, b, a = R2D::Color.rgba(g[:left])
  #   @c1 = @c3 = R2D::Window.get_color(r, g, b, a)
  # end
  
  # if g[:right]
  #   r, g, b, a = R2D::Color.rgba(g[:right])
  #   @c2 = @c4 = R2D::Window.get_color(r, g, b, a)
  # end
  
  # if g[:top_left]
  #   r, g, b, a = R2D::Color.rgba(g[:top_left])
  #   @c1 = R2D::Window.get_color(r, g, b, a)
  # end
  
  # if g[:top_right]
  #   r, g, b, a = R2D::Color.rgba(g[:top_right])
  #   @c2 = R2D::Window.get_color(r, g, b, a)
  # end
  
  # if g[:bottom_left]
  #   r, g, b, a = R2D::Color.rgba(g[:bottom_left])
  #   @c3 = R2D::Window.get_color(r, g, b, a)
  # end
  
  # if g[:bottom_right]
  #   r, g, b, a = R2D::Color.rgba(g[:bottom_right])
  #   @c4 = R2D::Window.get_color(r, g, b, a)
  # end
end