Android Question Canvas.DrawPath with corner radius

Keivan

Member
Hello, I have created a line by drawing on specific points using canvas and draw. I want the created angles to be rounded like the picture below.
Sorry for my bad English.
canv.png
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
1683614989698.png


B4X:
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("MainPage")
    cvs.Initialize(Panel1)
    DrawHorizontal(50dip, 300dip, 50dip)
    DrawVertical(50dip, 300dip, 300dip)
    cvs.Invalidate
End Sub

Private Sub DrawVertical(Top As Int, Bottom As Int, Left As Int)
    Dim r As B4XRect
    r.Initialize(Left - StrokeWidth / 2, Top - StrokeWidth / 2, Left + StrokeWidth / 2, Bottom + StrokeWidth / 2)
    Dim path As B4XPath
    path.InitializeRoundedRect(r, StrokeWidth / 2)
    cvs.DrawPath(path, xui.Color_Red, True, 0)
End Sub

Private Sub DrawHorizontal(Left As Int, Right As Int, Top As Int)
    Dim r As B4XRect
    r.Initialize(Left - StrokeWidth / 2, Top - StrokeWidth / 2, Right + StrokeWidth / 2, Top + StrokeWidth / 2)
    Dim path As B4XPath
    path.InitializeRoundedRect(r, StrokeWidth / 2)
    cvs.DrawPath(path, xui.Color_Red, True, 0)
End Sub

StrokeWidth is a global variable with the value of 60dip
 

Attachments

  • Project.zip
    13.8 KB · Views: 54
Upvote 0
Top