I have been trying to convert the following into B4X code today which I found on the forum in a project (sorry can't remember the original author), but with little success. I have only just started with the drawing canvas/rect functions, so still learning!
I know it would seem simple but the logic has eluded me so far. I have tried various drawpath options but with little luck.
Any help appreciated.
B4X:
Private Sub DrawValue2(View As View, cvs As Canvas, Value As Float)
Dim clr As Int = Colors.White
cvs.DrawColor(Colors.Transparent)
Dim strokewidth As Int = 2dip
Dim cx = View.Width / 2, cy = View.Height / 2 As Float
Dim r As Rect
r.Initialize(-100dip, -100dip, View.Width + 200dip, View.Height + 200dip)
Dim ArcRect As JavaObject
ArcRect.InitializeNewInstance("android.graphics.RectF", Array(r))
Dim p As Path
p.Initialize(cx, cy)
Dim jo As JavaObject = p
Dim start As Float = -90
jo.RunMethod("arcTo", Array(ArcRect, start, Value))
If Value < 360 Then cvs.ClipPath(p)
DrawRoundRect2(cvs, 1dip, 1dip, View.Width - 2dip, View.Height - 2dip, 10dip, clr, False, strokewidth)
If Value < 360 Then cvs.RemoveClip
View.Invalidate
End Sub
I know it would seem simple but the logic has eluded me so far. I have tried various drawpath options but with little luck.
Any help appreciated.