Drawing a Graphice Segment
hh
hh at livecode.org
Wed Jul 29 05:32:28 EDT 2015
The function below determines for any point (x,y) whether it is within an oval graphic or not. You may add your own criteria like colour or fill/transparency or visibility ...
There is one "uncertainty by default", the border, that is drawn with half of the lineSize outside the object. LC is also sloppy with the rect of objects with large lineSizes.
For a function that covers all seven types of LC graphics objects see the function "hhPointWithinGrc" of my stack #47 ("pointInShape") in
forums.livecode.com/viewtopic.php?f=76&t=19248
function pointWithinOval G, p
-- G is the short name or the number of an *oval* graphic
-- p is a point in local coords, for example the clickloc
if p is not within the rect of grc G then return false
put the loc of grc G into lc
put the width of grc G into w
put the height of grc G into h
put h*(item 1 of p - item 1 of lc) into d1
put w*(item 2 of p - item 2 of lc) into d2
put the arcAngle of grc G into c2
if c2 < 360 then
put the startAngle of grc G into c1
put (c1 + c2) into c3
if d2 < 0 then put 0 - atan2(d2,d1)*180/pi into c
else put 360 - atan2(d2,d1)*180/pi into c
if c3 <= 360 then put ( (c1 <= c) and (c <= c3) ) into cc
else put ( (c1 <= c) or (c <= c3 - 360) ) into cc
return ( ( 4*d1^2 + 4*d2^2 <= w^2*h^2 ) and cc )
else return ( 4*d1^2 + 4*d2^2 <= w^2*h^2 )
end pointWithinOval
Hermann
More information about the Use-livecode
mailing list