Method: GuiGeo::Rectangle#bound

Defined in:
lib/gui_geometry/rectangle.rb

#bound(val) ⇒ Object

val can be a Rectangle or Point returns a Rectangle or Point that is within this Rectangle For Rectangles, the size is only changed if it has to be



33
34
35
36
37
38
39
40
41
42
43
# File 'lib/gui_geometry/rectangle.rb', line 33

def bound(val)
  case val
  when Rectangle then
    r = val.clone
    r.size = r.size.min(size)
    r.loc = r.loc.bound(loc, loc + size - val.size)
    r
  when Point then (val-loc).bound(point, size) + loc
  else raise ArgumentError.new("wrong type: (#{val.class}) - Rectangle or Point expected")
  end
end