Rectangle Problem
Frank D. Engel, Jr.
fde101 at fjrhome.net
Wed Apr 6 10:03:08 EDT 2005
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Untested:
if intersect(rect1, rect2) then
put the rect of rect1 into bigrect
put the rect of rect2 into smallrect
if item 1 of smallrect < item 1 of bigrect then put item 1 of bigrect
into item 1 of smallrect
if item 2 of smallrect < item 2 of bigrect then put item 2 of bigrect
into item 2 of smallrect
if item 3 of smallrect > item 3 of bigrect then put item 3 of bigrect
into item 3 of smallrect
if item 4 of smallrect > item 4 of bigrect then put item 4 of bigrect
into item 4 of smallrect
set the rect of rect2 to smallrect
end if
On Apr 6, 2005, at 6:16 AM, David Burgun wrote:
> 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 dburgun at dsl.pipex.com:
>>> 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
>> use-revolution at lists.runrev.com
>> http://lists.runrev.com/mailman/listinfo/use-revolution
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution
>
>
- -----------------------------------------------------------
Frank D. Engel, Jr. <fde101 at fjrhome.net>
$ ln -s /usr/share/kjvbible /usr/manual
$ true | cat /usr/manual | grep "John 3:16"
John 3:16 For God so loved the world, that he gave his only begotten
Son, that whosoever believeth in him should not perish, but have
everlasting life.
$
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (Darwin)
iD8DBQFCU+wc7aqtWrR9cZoRAqW9AJ0W9B5xhtuzyZsdjJm5WEkaht3B/QCfaZ5q
wnPAfSFbsap+n/gAZim8OM0=
=LZAu
-----END PGP SIGNATURE-----
___________________________________________________________
$0 Web Hosting with up to 200MB web space, 1000 MB Transfer
10 Personalized POP and Web E-mail Accounts, and much more.
Signup at www.doteasy.com
More information about the use-livecode
mailing list