![]() log scale meter code snippet | show it | return | |
on needle theAngle
global gDegtoRad, gOrigin, gMeterPivot
-- swings the line to the angle passed as input
-- NW/SE line orientation
if theAngle > 90 then
set the memberNum of sprite 2 = the number of member "line1"
set theAngle = 180 - theAngle
set vMeter = gRadius * sin( gDegtoRad * theAngle )
set hMeter = gRadius * cos( gDegtoRad * theAngle )
set pointMeter = gOrigin - point(hMeter, vMeter)
set the rect of sprite 2 = rect(pointMeter, gMeterPivot)
else
-- NE/SW line orientation
set the memberNum of sprite 2 = the number of member "line2"
set vMeter = - gRadius * sin( gDegtoRad * theAngle )
set hMeter = gRadius * cos( gDegtoRad * theAngle )
set pointMeter = gOrigin + point(hMeter, vMeter)
set the rect of sprite 2 = rect(the locH of gMeterPivot, the locV of pointMeter, the locH of pointMeter, the locV of gMeterPivot)
end if
updateStage
end
on meter x
-- this is te kludge! Look up the value in a property list and
-- find the angle closest
if x <=2 then
set finalValue = getAt(gRangeList, findPosNear(gRangeList, x) )
else
set finalValue = 119.4
end if
-- sweep the needle from its max to its final value
repeat with i = 122 down to integer(finalValue)
needle(i)
needle(finalValue)
end
|
| The trick here was a way to take the value the needle should point to (represented by a log scale along an arc) and use lingo to roate a line sprite to the corresponding value. In the end, the trick was to create a property list of angles and associated meter values, and sue list functions to back calculate the angle for any arbitrary needle value.
lingo era = v5.0 |