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.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User


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: 153
Upvote 0

Keivan

Member
Thank you very much Erel, please look at the example below and guide me
 

Attachments

  • projectex.rar
    226.2 KB · Views: 137
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…