Private Sub Draw (State As Float)
bc.DrawRect2(bc.TargetRect, transparent, True, 0)
Dim r As Float = Round(bc.mHeight / 2)
Dim cx As Float = r - 1 * Scale + (bc.mWidth - 2 * r) * State
If State = 0 Then
cx = r
Else If State = 1 Then
cx = Round(bc.mWidth - 1 * Scale - r)
End If
Dim cy As Int = bc.mHeight / 2
Dim smallrect As B4XRect
Dim w As Float = State * bc.mWidth
Dim h As Float = State * bc.mHeight
If State < 1 Then bc.DrawRectRounded2(bc.TargetRect, OffColor, True, 2 * Scale, r)
smallrect.Initialize(bc.mWidth / 2 - w / 2, cy - h / 2, bc.mWidth / 2 + w / 2, cy + h / 2)
If State > 0 Then bc.DrawRectRounded2(smallrect, OnColor, True, 2 * Scale, smallrect.Height / 2)
If mEnabled Then ' <-------------------------------------------------------------------------------------------
bc.DrawCircle2(cx, cy, r - 2 * Scale, ThumbColor, True, 0)
End If
bc.SetBitmapToImageView(bc.Bitmap, iv)
End Sub