'returns the graphic name
Private Sub CreateCircleForBall (Shape As B2Shape) As String
Dim ballsize As B2Vec2 = X2.GetShapeWidthAndHeight(Shape)
'we could have used B4XCanvas here instead of BitmapCreator.
Dim bc As BitmapCreator
bc.Initialize(X2.MetersToBCPixels(ballsize.X), X2.MetersToBCPixels(ballsize.Y))
'inner circle
bc.DrawCircle(bc.TargetRect.CenterX, bc.TargetRect.CenterY, bc.mWidth / 2 - 2, Rnd(0xff000000, -1), True, 0)
'outer circle
bc.DrawCircle(bc.TargetRect.CenterX, bc.TargetRect.CenterY, bc.mWidth / 2, xui.Color_Black, False, 2)
Dim sb As X2ScaledBitmap
sb.Scale = 1
sb.Bmp = bc.Bitmap
'add to cache
Dim gname As String = X2.GraphicCache.GetTempName
'the balls are simple circles so there is no reason to "rotate" them. Setting AngleInterval to 360 disables rotation.
X2.GraphicCache.PutGraphic2(gname, Array(sb), True, 360)
Return gname
End Sub