class Gosling::Rect
A Rect
is a Polygon
with exactly four vertices, defined by a width and height, with sides at right angles to one another. The width and height can be modified at runtime; all vertices will be updated automatically.
Attributes
height[R]
width[R]
Public Class Methods
new(window)
click to toggle source
Creates a new Rect
with a width and height of 1.
Calls superclass method
Gosling::Polygon::new
# File lib/gosling/rect.rb, line 14 def initialize(window) super(window) @width = 1 @height = 1 rebuild_vertices end
Public Instance Methods
height=(val)
click to toggle source
# File lib/gosling/rect.rb, line 27 def height=(val) raise ArgumentError.new("set_height() expects a positive, non-zero number") if val <= 0 @height = val rebuild_vertices end
width=(val)
click to toggle source
# File lib/gosling/rect.rb, line 21 def width=(val) raise ArgumentError.new("set_width() expects a positive, non-zero number") if val <= 0 @width = val rebuild_vertices end
Private Instance Methods
rebuild_vertices()
click to toggle source
# File lib/gosling/rect.rb, line 35 def rebuild_vertices set_vertices_rect(@width, @height) end