Android Question Need Advise how to make smooth arc scroll

Similar threads

B4A Code Snippet Mathemetics Pendulum
B4A Code Snippet Geo-Zone Determination (Point in Polygon)
B4A Question 🐢 B4XTurtle - Reference
B4A Code Snippet Get panel touch direction
B4A Code Snippet Bicubic curves


Well-Known Member
Licensed User
the codes below draws an arc in xGauges. I am trying to find ways to make the arc scroll (Draws) smoothly. I have failed on many attempts which the codes are not shown. For example, the needle can be scrolled smoothly using pnl.SetRotationAnimated but cannot figure out this DrawArc routine.

Private Sub DrawArc(CenterX As Int, CenterY As Int, Radius As Int, StartAngle As Int, SweepAngle As Int, Color As Int, Strokewidth As Int)
    Private Angle, x1, y1, x2, y2 As Float
    Private i As Int

    Angle = StartAngle
    x1 = CenterX + Radius * CosD(Angle)
    y1 = CenterY + Radius * SinD(Angle)

    For i = StartAngle + 1 To StartAngle + SweepAngle
        Angle = Angle + 1
        x2 = CenterX + Radius * CosD(Angle)
        y2 = CenterY + Radius * SinD(Angle)
        cvsGauge.DrawLine(x1, y1, x2, y2, Color, Strokewidth)
        x1 = x2
        y1 = y2
End Sub


Well-Known Member
Licensed User
Thanks Erel. It works really well with the Drawarc. I might even consider using this for my needles instead of SetRotationAnimated. I will compare the smoothness. Also the Text label can be updated with the newvalue which SetRotationAnimated cannot do.