Run Rev's within() function--Was: Problem with mask
James Hurley
jhurley0305 at sbcglobal.net
Sat Oct 25 10:47:28 EDT 2008
Wilhelm,
I think the following script, placed in the card of a new stack,
gives the clearest idea of what the problem is. As you mouse around
the graphic you can see the mouse corrdinates as well as the results
of the user-defined within function and Run Rev's within() function.
You can easily see precisely how the Run Rev within() function works.
It definitely excludes the right and bottom edges of a square, but
includes the top and left edges. Whatever happens when using the
within() funciton to construct a mask (or for whatever purpose) has
to be reconciled to these basic results.
Jim Hurley
local myname, X0, Y0
on mouseDown
if there is not grc "myTest" then
create grc "myTest"
set the style of grc "myTest" to rect
set the opaque of grc "myTest" to true
set the width of grc "myTest" to 100
set the height of grc "myTest" to 100
set the loc of grc "myTest" to 50,50
end if
put the name of the target into myName
put the topleft of myName into tXY
put item 1 of tXY into X0
put item 2 of tXY into Y0
end mouseDOwn
on mouseUP
put "" into myName
end mouseUP
on mouseMove u,v
if myName is "" or the number of graphics = 0 then exit mouseMove
put u,v into tPt
--Get displacement from upper left corner
put u - x0 into dx
put v - y0 into dy
--User defined "within" function
if dx > -1 and dx < 101 and dy > -1 and dy < 101 then
put true into myWithin
else
put false into myWithin
end if
--Built-in within() function
if within(myName, tPt) then
put true into runRevWithin
else
put false into runRevWithin
end if
put u,v & cr & "myWIthin is " & myWithin & cr & "RR within is " &
runRevWIthin into msg box
end mouseMove
More information about the use-livecode
mailing list