Android Question BCPath.arcTo implementation

Sorin Pohontu

Member
Licensed User
Longtime User
Hi Erel,

Attached you can find 2 images: the BCPath I want to draw vs the BCPath I did it so far.
This was constructed only with LineTo.

Let me know if you need more info.

Thanks.
 

Attachments

  • BCPath-Want.png
    BCPath-Want.png
    2.2 KB · Views: 117
  • BCPath-Did.png
    BCPath-Did.png
    1.7 KB · Views: 108
Upvote 0

Sorin Pohontu

Member
Licensed User
Longtime User
Hi Erel,

Here is my current code:

B4X:
Dim bc As BitmapCreator
Dim layerPath As BCPath
Dim layerImg As B4XBitmap = xui.LoadBitmapResize(File.DirAssets, "layer_0.png", 100%x, 100%y, True)
Dim layerBrush As BCBrush = bc.CreateBrushFromBitmap(layerImg)

bc.Initialize(100%x, 100%y)
layerPath.Initialize(0, 0).LineTo(0, 16%y).LineTo(20%x, 22%y).LineTo(80%x, 22%y).LineTo(100%x, 16%y).LineTo(100%x, 0).LineTo(0, 0)
bc.DrawPath2(layerPath, layerBrush, True, 0)

Activity.SetBackgroundImage(bc.Bitmap)

Can you give me a hint how to use BC.DrawArc in this context ?
 
Upvote 0

Sorin Pohontu

Member
Licensed User
Longtime User
Hello,

I have attached, but it's just a background layer, you can use any image (PNG, JPG) ...
 

Attachments

  • layer_0.png
    layer_0.png
    51.7 KB · Views: 110
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
B4X:
Sub Activity_Create(FirstTime As Boolean)
    Dim bc As BitmapCreator
    Dim layerPath As BCPath
    Dim layerImg As B4XBitmap = xui.LoadBitmapResize(File.DirAssets, "layer_0.png", 100%x, 100%y, False) 'don't keep aspect ratio or there will be holes in the brush
    bc.Initialize(100%x, 100%y)
    Dim layerBrush As BCBrush = bc.CreateBrushFromBitmap(layerImg)
    layerPath.Initialize(0, 0).LineTo(0, 16%y).LineTo(20%x, 22%y).LineTo(80%x, 22%y).LineTo(100%x, 16%y).LineTo(100%x, 0).LineTo(0, 0)
    bc.DrawPath2(layerPath, layerBrush, True, 0)
    bc.DrawArc(35%x, 22%y, 10%x, xui.Color_Transparent, True, 0, 180, 180)
    bc.DrawArc(65%x, 22%y, 10%x, xui.Color_Transparent, True, 0, 180, 180)
    Activity.SetBackgroundImage(bc.Bitmap)
End Sub
 
Upvote 0

Sorin Pohontu

Member
Licensed User
Longtime User
Thanks Erel.

It seems that I do have one more issue: there are 3 layers created with BCPath, the one with arcs is on top. Creating the arcs as in your code will make all brushes transparent.

Do you have a hint for that ?

Thanks again.
 

Attachments

  • Arc-01.png
    Arc-01.png
    17.7 KB · Views: 118
Last edited:
Upvote 0
Top