Capture the Trig Function from an Option Menu Button
Jim Hurley
jhurley0305 at sbcglobal.net
Mon Dec 10 11:59:11 EST 2012
It turns out that Do is fast enough. Here is the Do script:
(The script might read a litle better by using "x" in the repeat loop instead of "i".)
on mouseUp
put the label of btn "myOptionMenu" into tTrigFunction
--It might be necessary to take care in using the following replacements
replace "sine" with "sin" in tTrigFunction
replace "cosine" with "cos" in tTrigFunction
replace "tangent" with "tan" in tTrigFunction
put round(the width of this card/2) into x0
put round(the height of this card/2) into y0
put 50 into Amp--Amplitude of the trig curve
set the points of grc "myCurve" to empty
wait 0 millisec -- Force a screen refresh on the Mac
repeat with i = 1 to 360--maybe with a step of 2 or 4
put i*pi/180 into tAngle
get "put the " & tTrigFunction & " of " & tAngle & " into y "
do it
put round(Amp*y) into y
put i into x
put x+ x0, y+y0 into tPoint
put tPoint & cr after tPoints
--Uncomment the following to see the curve evolve
--set the points of grc "myCurve" to tPoints
--wait 0 millisec
end repeat
set the points of grc "myCurve" to tPoints
end mouseUp
More information about the use-livecode
mailing list