Ok, yes thanks, I was just about coming to the conclusion that this was the only way to achieve this. I looked at the "within" function/keyword which works on points, seems like it would be good to make this work with two objects, so you could write:

 if within("UserRect","BoundingRect") then
.........................
end if


I alsso looked at "intersect" which sort of does what I want, but doesn't make sure the whole Rect is within another Rect.


Guess it works just as well as a defined function tho, thanks a lot. I am playing with this now,

Thanks a lot
Dave

sez [EMAIL PROTECTED]:
Given I have a "BoundingRect" and "UserRect", how can I check that
"UserRect" is inside "BoundingRect"? If it overlaps I want to either
clip the rectangle or stop it from moving outside of the BoundingRect
in the first place.
Well, a rect is a four-number list, right? If UserRect is wholly contained
within BoundingRect, the "left" value for UserRect will be equal to, or
greater than, the "left" value for BoundingRect; similarly, the "down" value for
UserRect will be less than, or equal to, the "down" value for BoundingRect; and
so on. Thus, what you want can be done by a function like this:


function ItsInside UserRect, BoundRect
  if item 1 of UserRect => item 1 of BoundRect then return false
  if item 2 of UserRect => item 2 of BoundRect then return false
  if item 3 of UserRect <= item 3 of BoundRect then return false
  if item 4 of UserRect <= item 4 of BoundRect then return false
  return true
end ItsInside

   If you wanted to, you could turn this handler's code into a one-liner by
combining the four comparisons, like so:

on ItsInside Ru, Rb
  # mind the line-wrap!
  return ((item 1 of Ru => item 1 of Rb) and (item 2 of Ru => item 2 of Rb)
and (item 3 of Ru <= item 3 of Rb) and (item 4 of Ru <= item 4 of Rb))
end ItsInside

   Hope this helps...
_______________________________________________
use-revolution mailing list
[email protected]
http://lists.runrev.com/mailman/listinfo/use-revolution

_______________________________________________ use-revolution mailing list [email protected] http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to