Intersect Function

Richmond Mathewson richmondmathewson at gmail.com
Mon Sep 24 12:24:34 EDT 2018


I found THIS in the User contributed notes in the 7.1.4 documentation 
from 2009:

"The intersect() command takes two objects as inputs. In some 
situations, it may be useful to find the intersect of a point and a 
rectangle. The custom function below may be used in those cases:

function pointIntersect pPoint,pRect
    split pPoint by comma
    split pRect by comma
    return ((pRect[1] <= pPoint[1]) and (pPoint[1] <= pRect[3]) and 
(pRect[2] <= pPoint[2]) and (pPoint[2] <= pRect[4]))
end pointIntersect

Examples:
pointIntersect(the mouseLoc, the rectangle of stack "MyStack")
pointIntersect(the clickLoc, the rect of img "Splash")

Use the pointIntersect function to determine whether a point is within a 
specified rectangle.

Parameters:
The pPoint is an expression that evaluates to a point.
The pRect is a rectangle consisting of four integers separated by commas.

Value:
The pointIntersect function returns true or false.

Comments:
The pointIntersect function does not differentiate between screen 
coordinates and window coordinations.
This means that if the point is screen-relative, such as a mouseLoc, and 
the rectangle is window-relative,
such as an object's rectangle, the pointIntersect function does not 
return a reliable result."

This is NOT mine, so I can take no credit for it.

Richmond.




More information about the use-livecode mailing list