Drawing a Graphice Segment
Terence Heaford
t.heaford at icloud.com
Tue Jul 28 03:28:03 EDT 2015
> On 27 Jul 2015, at 22:27, Scott Rossi <scott at tactilemedia.com> wrote:
>
> Just to beat the horse a bit more,
And another based on mathematics.
When you create the pie chart segments you know the start angle and end angle, so save them with the segment.
In my case I use uStartAngle and uEndAngle.
Then apply using:
---------------------
on mouseMove
lock screen
put the mouseH into tMouseX
put the mouseV into tMouseY
put chartLeft() + chartWidth()/2 into tCentreX
put chartTop() + chartHeight()/2 into tCentreY
put tMouseX - tCentreX into tDeltaX
put tMouseY - tCentreY into tDeltaY
put atan2InDegrees(tDeltaY,tDeltaX) into tAngle
if tAngle < 0 then
put round(abs(tAngle)) into tAngle
else
put round(360 - tAngle) into tAngle
end if
repeat for each line tID in the childControlIDs of me
if the customKeys of control id tID contains "uStartAngle" then
put the uStartAngle of control id tID into tStartAngle
put the uEndAngle of control id tID into tEndAngle
put tAngle && "," && tStartAngle && "," && tEndAngle & return after tResult - - just to monitor what’s happening
if tAngle >= tStartAngle and tAngle <= tEndAngle then
set the backgroundcolor of control id tID to green
else
set the backgroundcolor of control id tID to the uColor of control id tID
end if
end if
end repeat
unlock screen
put tResult
end mouseMove
---------------------
function atan2InDegrees firstArg,secondArg
return atan2(firstArg,secondArg) * 180 / pi
end atan2InDegrees
——————————
I just need to add a section to monitor whether tMouseX and tMouseY is in the diameter of the pie.
All the best
Terry
More information about the use-livecode
mailing list