Android Question Fill circle based on slider value

GJREDITOR

Member
I am trying to get a water filling effect in a circle. For half filled (slider value =50), I can do this . However I am unable to figure out how to do that for any other slider value. :
water fill 50% of circle:
Dim bc,bc2 As BitmapCreator
    bc.Initialize(ImageView1.Width, ImageView1.Height)
    bc2.Initialize(bc.mWidth, bc.mHeight)
    bc2.FillGradient(Array As Int(xui.Color_ARGB(0,255,255,255), xui.Color_Blue), bc2.TargetRect, "BOTTOM_TOP")
    Dim Brush2 As BCBrush = bc.CreateBrushFromBitmapCreator(bc2)
    Do While True
        Brush2.SrcOffsetY = Brush2.SrcOffsetY - 1dip
        bc.DrawArc2(ImageView1.Width/2,ImageView1.Height/2,ImageView1.Width/2-2,Brush2, True, 1dip,0,180)           
        bc.SetBitmapToImageView(bc.Bitmap, ImageView1)
        Sleep(15)
    Loop
If there is no solution I will use SD liquid progress but I want to avoid using proprietary code.
 

Attachments

  • waterfill.gif
    waterfill.gif
    88 KB · Views: 64
Solution
Here you are.
It is a B4XProject with a CustomView xWaterFill.
Tested on all three platforms.
It is more like a demonstrator program rather than a final product, but shows what could be done.
You can use it, improve it and also make a b4xlib.

It has three properties:
- FillColor
- AlphaMin, the gradient for the fill color
- Shape, currently three shapes ELLIPSE, RECTANGLE, TRIANGLE. These are Paths



1692540002649.png

klaus

Expert
Licensed User
Longtime User
Here you are.
It is a B4XProject with a CustomView xWaterFill.
Tested on all three platforms.
It is more like a demonstrator program rather than a final product, but shows what could be done.
You can use it, improve it and also make a b4xlib.

It has three properties:
- FillColor
- AlphaMin, the gradient for the fill color
- Shape, currently three shapes ELLIPSE, RECTANGLE, TRIANGLE. These are Paths



1692540002649.png
 

Attachments

  • WaterFill.zip
    17.2 KB · Views: 61
Upvote 3
Solution
Top