Skip to content

API Reference

This page summarizes the main public configuration options documented in the GradientMesh README.

Module import

lua
local GradientMesh = require "GradientMesh"

or, if the file is placed under src/:

lua
local GradientMesh = require "src/gradient_mesh"

Constructor

lua
local mesh = GradientMesh.new()

Rectangle gradient

lua
mesh:rectangle({
    color = {0x0f2027, 0x203a43, 0x2c5364},
    alpha = {1, 1, 1},
    dimension = {320, 180},
    anchor = {0.5, 0.5},
    position = {160, 240},
    way = "lr"
})

Circle gradient

lua
mesh:circle({
    radius = 180,
    edges = 96,
    color = {0x833ab4, 0xfd1d1d, 0xfcb045},
    position = {240, 240},
    way = "co",
    jaggedFree = true
})

Regular polygon gradient

lua
mesh:regularPolygon({
    edges = 6,
    radius = 160,
    color = {0x4776e6, 0x8e54e9},
    position = {240, 240},
    scalePolygon = {1, 1},
    rotationMesh = 0,
    jaggedFree = true
})

Configuration options

OptionDescription
colorList of colors assigned to gradient stops.
alphaOptional alpha values per color stop.
dimensionWidth and height for rectangular gradients.
radiusRadius for circles and regular polygons.
edgesNumber of polygon edges. Higher values create smoother circles.
positionMesh position on stage.
anchorAnchor point for rectangular gradients.
wayGradient direction: tb, bt, lr, rl, co, oc.
holeEnables an inner hole for radial shapes.
rInInner radius when hole is enabled.
scalePolygonDeforms polygon or circle proportions.
rotationRotates the full mesh object.
rotationMeshRotates only the mesh vertices.
textureOptional texture configuration.
jaggedFreeAdds a soft transparent ring to reduce jagged edges.
colorOnEnables or disables mesh color assignment.

Direction values

ValueMeaning
tbTop to bottom.
btBottom to top.
lrLeft to right.
rlRight to left.
coCenter to outside.
ocOutside to center.

Notes

When hole = true, the radial mesh starts from an inner radius instead of the center.

The center is not filled by mesh triangles, so the hole remains transparent and shows whatever is behind it.

Built with VitePress and deployed with GitHub Pages.