Class: Ruby2D::Rectangle
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from Quad
#c1, #c2, #c3, #c4, #x1, #x2, #x3, #x4, #y1, #y2, #y3, #y4
Attributes included from Renderable
#color, #height, #width, #x, #y, #z
Instance Method Summary collapse
- #height=(h) ⇒ Object
-
#initialize(opts = {}) ⇒ Rectangle
constructor
A new instance of Rectangle.
- #width=(w) ⇒ Object
- #x=(x) ⇒ Object
- #y=(y) ⇒ Object
Methods inherited from Quad
Methods included from Renderable
#a, #a=, #add, #b, #b=, #colour, #colour=, #contains?, #g, #g=, #opacity, #opacity=, #r, #r=, #remove
Constructor Details
#initialize(opts = {}) ⇒ Rectangle
Returns a new instance of Rectangle.
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/ruby2d/rectangle.rb', line 6 def initialize(opts = {}) @x = opts[:x] || 0 @y = opts[:y] || 0 @z = opts[:z] || 0 @width = opts[:width] || 200 @height = opts[:height] || 100 self.color = opts[:color] || 'white' self.opacity = opts[:opacity] if opts[:opacity] update_coords(@x, @y, @width, @height) add end |
Instance Method Details
#height=(h) ⇒ Object
37 38 39 40 |
# File 'lib/ruby2d/rectangle.rb', line 37 def height=(h) @height = h update_coords(@x, @y, @width, h) end |
#width=(w) ⇒ Object
32 33 34 35 |
# File 'lib/ruby2d/rectangle.rb', line 32 def width=(w) @width = w update_coords(@x, @y, w, @height) end |
#x=(x) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/ruby2d/rectangle.rb', line 18 def x=(x) @x = @x1 = x @x2 = x + @width @x3 = x + @width @x4 = x end |
#y=(y) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/ruby2d/rectangle.rb', line 25 def y=(y) @y = @y1 = y @y2 = y @y3 = y + @height @y4 = y + @height end |