Android Question Triangle with curve line

BarryW

Active Member
Licensed User
Longtime User
Hi. How can I achive this kind of drawing using canvas or b4xpath. The yellow one is just a rectangle and the two blue shape is my need
Capture.PNG
 
Last edited:

klaus

Expert
Licensed User
Longtime User
Upvote 0

Brian Dean

Well-Known Member
Licensed User
Longtime User
Here is something that you could start with. There are people around the forum who specialise in this sort of thing and can do a better job.
B4X:
Sub Class_Globals
    Private Root As B4XView
    Private xui As XUI
    Dim cvsCanvas As B4XCanvas
End Sub

Public Sub Initialize
    
End Sub

Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    cvsCanvas.Initialize(Root)
    drawCurve(5.0, 1.8)   
End Sub

Sub drawCurve(XStep As Float, YFactor As Float)
    Dim path As B4XPath
    path.Initialize(0, 0)
    Dim x As Float = 0.0
    Dim y As Float = Root.Height
    Do While (y > 0.001)
        x = x + XStep
        y = y - (y / YFactor)
        path.LineTo(x, Root.height - y)
    Loop
    path.LineTo(0, Root.Height)
    path.LineTo(0,0)
    cvsCanvas.DrawPath(path, xui.Color_Red, True, 0)
End Sub
Here is the result for one side of the panel - you will need to add the right hand side. Change the values for XStep and YFactor to shape the curve.

Curve.png
 
Upvote 0
Top