Android Code Snippet [B4X] [XUI] Canvas Draw Round Rect, Arcs, Ovals

Discussion in 'Code Snippets' started by ivan.tellez, May 16, 2018.

  1. ivan.tellez

    ivan.tellez Active Member Licensed User

    XUI v1.60 introduces a new method: DrawPath

    With this, now we have more options to draw:
    • Arc
    • Oval
    • RoundRect
    • LineTo

    Just consult the documentation of each method of the B4XPath object, Asuming an initialized B4XCanvas (tCanvas) the relevant code is:

    Code:
    Dim tRect As B4XRect
        tRect.Initialize(
    1dip1dip, MyWidth, MyHeight)
        
        
    Dim xPath As B4XPath
        xPath.InitializeRoundedRect(tRect, 
    10dip)
        
        tCanvas.DrawPath(xPath, 
    Colors.DarkGray, False5)


    XUI v1.60:
    https://www.b4x.com/android/forum/threads/updates-to-internal-libraries.59340/#post-587118



    I just have a question to @Erel ; Why to have another object and not only add DrawRoundRect or DrawArc to the B4XCanvas?
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    Path is more powerful. You can make more complex shapes and more importantly you can clip the drawings based on the path.
     
    Johan Hormaza likes this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice