Public Sub DrawTexts(Pn As B4XView, lstTexts As List, FontSize As Float, lstColors As List, Radius As Int, StrokeWidth As Int, CircleColor As Int)
Dim xCanvas As B4XCanvas
xCanvas.Initialize(Pn)
Dim NumOfSectors As Int = lstTexts.Size
Dim SectorsOffset As Double = 360 / NumOfSectors
Dim CenterX, CenterY As Float
CenterX = Pn.Width / 2
CenterY = Pn.Height / 2
Dim Angle As Float
Dim xFont As B4XFont = xui.CreateDefaultFont(FontSize)
Dim Text As String
For i = 0 To NumOfSectors - 1
Text = lstTexts.Get(i)
Angle = 270 + i * SectorsOffset + SectorsOffset / 2
Dim r As B4XRect = xCanvas.MeasureText(Text, xFont)
Dim BaseLine As Int = CenterY - r.Height / 2 - r.Top
xCanvas.DrawTextRotated(Text, CenterX + 100dip * CosD(Angle), BaseLine + 100dip * SinD(Angle), xFont, xui.Color_Black, "CENTER", Angle)
Next
End Sub
Better, not perfect:
I'm using it.Sorry but why don't you follow Erel's advice to use B4XCanvas?
I know, this is why I wrote:The result doesn't look great
Just two more months and I'll be able to do it ?
Yes, I have also encountered this problem. It is not aligned but I solved it. I don't remember how.
Yes, I have also encountered this problem. It is not aligned but I solved it. I don't remember how.
I had already tried, even trying to calculate how much that increase must be.Try adding a degree to the text rotation. Or bring back the rotation of the wheel with respect to the written.
I looked at my code and didn't understand anything about it.I had already tried, even trying to calculate how much that increase must be.
I'm attaching the project (some things need to be changed; it is not correct that the number of sectors is deduced from the list of colors provided - and other stuff to change/remove, added just for tests)
xRect = xCanvas.MeasureText(Sector.Text, xFont)
X = CenterX + HalfRadius * CosD(MiddleAngle) + SinD(MiddleAngle) * xRect.CenterY
Y = CenterY + HalfRadius * SinD(MiddleAngle) - CosD(MiddleAngle) * xRect.CenterY
xCanvas.DrawTextRotated(Sector.Text, X, Y, xFont, Sector.TextColor, "CENTER", MiddleAngle)
No, I was just waiting... for your intervention. I knew you would solve it!Are you expecting for this?