Dim p As B4XPath
Dim angle1 As Int = (mValue1 - mMin) / (mMax - mMin) * 360
Dim angle2 As Int = (mValue2 - mMin) / (mMax - mMin) * 360
If TouchedPanel1 = True Then
p.InitializeArc(CircleRect.CenterX, CircleRect.CenterY, mBase.Width/2, angle2-90,angle1-angle2)
Else
p.InitializeArc(CircleRect.CenterX, CircleRect.CenterY, mBase.Width/2, angle1-90,angle2-angle1)
End If
cvs.DrawPath(p, mReachedColor, True, 40dip)
comes the following behavior:
Every time a button enters the top point, the direction of the line is changed, how to prevent this?
The problem comes from the calculation of of angle1 and angle2 based on mValue1 and mValue2.
When you calculate mValue you set its limits to 0 = 0° and 100 = 360°.
When you move over the top, the angle you calculate goes from positive values to negative values, no jump.
But then, when you calculate mValue, the small negative angle is converted to a value just below 100 which means a bit less than 360° in the calculaton of the angles for the arc.
When you move over the top, the left part means negative values, but you do not allow negative values.
So, what value do you expect ?
You need to check this in the SetValueBasedOn and the Draw routines and depending on the mRollOver property.
Maybe, instead of checking which thumb was activated, check only the two values and draw the thumbs accordingly to these and always roll over
Which two points ?
You could memorize the angles, between 0 and 259°, of the two thumbs.
Then when you move, you calculate, in the SetValueBasedOn routine, the angle of the cursor.
Then you can check if the cursor angle is closer to angle1 or angle2 and set it to the cursor angle.
Then check if angle1 > angle2, and if yes, swap the two values.
Just some thoughts.