Share My Creation [B4X] B4XMeshGradient Engine.

A modern engine for generating mesh gradients; it allows for generating gradients directly within the application or using the resulting bitmap. Size, colors, and shapes (points) are fully parametric.

It also offers the option to create an animated mesh gradient using a JSON file containing the animation data.

It is part of a mesh gradient editor that I will be releasing soon.

The following gradient examples are generated using four points as parameters; it is possible to define additional points and colors, as well as the type of algorithm to be used.

Simple use of the mesh gradient engine:
B4X:
Private Sub Button1_Click
    Dim MeshGradient As B4XMeshGradient
    MeshGradient.Initialize
 
    Dim Width As Int = B4XImageView1.mBase.Width
    Dim Height As Int = B4XImageView1.mBase.Height
 
    MeshGradient.AddPoint(Width * 0.20, Height * 0.25, RandomColor)
    MeshGradient.AddPoint(Width * 0.75, Height * 0.20, RandomColor)
    MeshGradient.AddPoint(Width * 0.80, Height * 0.80, RandomColor)
    MeshGradient.AddPoint(Width * 0.15, Height * 0.85, RandomColor)

    Dim MeshBitmap As B4XBitmap = MeshGradient.Generate(Width, Height)
 
    B4XImageView1.Clear
    B4XImageView1.Bitmap = MeshBitmap
    B4XImageView1.CornersRadius = 16
    B4XImageView1.Update
End Sub


Ex. dark colors:

1791405962204.png


Ex: Windows Colors.

1791406199088.png


EX. Light pastel colors
1791406392416.png


Bitmap:
1.jpg
2.jpg
3.jpg



References:

Ref. Animation:

Important:
Remember that I do not use external libraries, only b4X code (cross-platform).


Note:
This class or engine was developed in accordance with what was requested or required here.

Regards.
 
Last edited:

TILogistic

Expert
Licensed User
Longtime User
Top