Sub Class_Globals
Private Root As B4XView
Private xui As XUI
Private ImageView1 As B4XView
End Sub
Public Sub Initialize
' B4XPages.GetManager.LogEvents = True
End Sub
'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
Root.LoadLayout("MainPage")
Dim bmp As B4XBitmap = DrawRectRound(ImageView1.Width, ImageView1.Height, 30, xui.Color_White, xui.Color_Blue, 4)
XUIViewsUtils.SetBitmapAndFill(ImageView1, bmp)
End Sub
Private Sub DrawRectRound(Width As Int, Height As Int, Radius As Int, FillColor As Int, StrokeColor As Int, StrokeWidth As Int) As B4XBitmap
Dim r As B4XRect
r.Initialize(5, 5, Width - 10, Height - 10)
Dim bc1, bc2 As BitmapCreator
bc1.Initialize(Width, Height)
bc2.Initialize(Width, Height)
bc1.DrawRectRounded(r, FillColor, True, 0, Radius)
Dim StartAngle = 0, SweepAngle = 6 As Float
Dim cx = r.CenterX, cy = r.CenterY As Float
Dim MaskRadius As Float = Max(r.Width, r.Height) / 2 * 1.5
Do While StartAngle < 360
Dim p As BCPath
p.Initialize(cx, cy)
p.LineTo(cx + MaskRadius * CosD(StartAngle), cy + MaskRadius * SinD(StartAngle))
p.LineTo(cx + MaskRadius * CosD(StartAngle + SweepAngle), cy + MaskRadius * SinD(StartAngle + SweepAngle))
bc2.DrawPath(p, StrokeColor, True, 0)
StartAngle = StartAngle + SweepAngle * 2
Loop
Dim mask As BCBrush = bc1.CreateBrushFromBitmapCreator(bc2)
bc1.DrawRectRounded2(r, mask, False, StrokeWidth, Radius)
Return bc1.Bitmap
End Sub