Sub DrawArc(CVS As B4XCanvas,CenterPoint As Point,Radius As Float,StartAngle As Float, EndAngle As Float,StrokeWidth As Float,Color As Int)
Dim ArcAngle As Float = EndAngle - StartAngle
Dim ArcLength As Float = (ArcAngle/360) * (2 * (cPI * Radius))
Dim PixelPerDegree As Int = Round(ArcLength / ArcAngle) +1
Dim OuterPoint360 As Point
Dim InnerPoint360 As Point
OuterPoint360.Initialize(CenterPoint.XCoord - Radius,CenterPoint.YCoord)
InnerPoint360.Initialize(OuterPoint360.XCoord - StrokeWidth,OuterPoint360.YCoord)
Dim Degrees As Float = StartAngle
Do While Degrees <= EndAngle
Dim Pts As List
Pts.Initialize
For Cntr = 1 To PixelPerDegree
Dim P As Point = RotatePoint(OuterPoint360,CenterPoint,Degrees + ((1/PixelPerDegree) * Cntr))
Dim P2 As Point = RotatePoint(InnerPoint360,CenterPoint,Degrees + ((1/PixelPerDegree) * Cntr))
CVS.DrawLine(P.XCoord,P.YCoord,P2.XCoord,P2.YCoord,Color,1)
Next
Degrees = Degrees + 1
Loop
End Sub
Sub RotatePoint(PointToRotate As Point, CenterPoint As Point, AngleInDegrees As Double) As Point
Dim angleInRadians As Double = AngleInDegrees * (cPI / 180)
Dim CosTheta As Double = Cos(angleInRadians)
Dim SinTheta As Double = Sin(angleInRadians)
Dim P As Point
P.Initialize(-1,-1)
P.XCoord = (CosTheta * (PointToRotate.XCoord - CenterPoint.XCoord) - SinTheta * (PointToRotate.YCoord - CenterPoint.YCoord) + CenterPoint.XCoord)
P.YCoord = (SinTheta * (PointToRotate.XCoord - CenterPoint.XCoord) + CosTheta * (PointToRotate.YCoord - CenterPoint.YCoord) + CenterPoint.YCoord)
Return P
End Sub