Skip to content

Images and Masks

Image functions draw materials, icons, rounded avatars, chamfered images, and texture-masked content.

Facade aliases: MGFX.Image, MGFX.ImageEx, MGFX.Icon, MGFX.IconEx, MGFX.Mask.

Scope

  • Use image for straightforward texture drawing.
  • Use imageEx when you need layout, masks, fill/background, stroke, glow, or backdrop.
  • Circular avatars, chamfered avatars, and texture masks are expressed through style.mask = mgfx.api.mask(...).

This Page

  • image - Simple image helper with optional radius and tint.
  • imageEx - Advanced image drawing path with layout, mask, and effects.
  • icon - Simple icon helper with contain-style behavior.
  • iconEx - Advanced icon path using image-style fields.
  • mask - Create an explicit image mask record.

Function Reference

image

lux
mgfx.api.image(x, y, w, h, source, radius = nil, tint = nil)

Simple image helper.

ParameterDescription
sourceMaterial path string, IMaterial-like object, or texture-like object.
radiusOptional rounded radius.
tintOptional Color tint.

Use imageEx for fit, crop, UVs, masks, backgrounds, strokes, glow, or backdrop.

imageEx

lux
mgfx.api.imageEx(x, y, w, h, source, style)

Advanced image path.

Layout Fields

FieldDescription
fit / objectFit"fill", "stretch", "cover", or "contain".
position{x, y}, {number, number}, or alignment fields.
crop{x, y, w, h}, optionally with pixels = true.
uv{u0, v0, u1, v1} or equivalent coordinate fields.
radiusNumber, true, "circle", percentage string, or px string.
maskMask record, string alias, false, or "none".

Visual Fields

FieldDescription
tint / colorMultiplies source image color.
alphaExtra opacity multiplier, either 0..1 or 0..255.
fill / backgroundOptional background behind transparent or masked pixels.
stroke / strokeWidthOptional mask-aware stroke when supported.
shadowDrop shadow spec.
outerGlowImage or mask-aware outer glow.
backdropFramebuffer blur/tint clipped by the image or mask.

Example

lux
mgfx.api.imageEx(x, y, 72, 72, avatarMat, {
  fit = "cover",
  mask = mgfx.api.mask("circle"),
  outerGlow = { color = Color(80, 170, 255, 70), width = 14 },
})

icon

lux
mgfx.api.icon(x, y, w, h, source, tint = nil)

Simple icon helper. It is intended for small glyph-like images and defaults to aspect-preserving layout through the icon path.

iconEx

lux
mgfx.api.iconEx(x, y, w, h, source, style)

Advanced icon path. It uses image-style fields but defaults to icon-friendly layout.

mask

lux
mgfx.api.mask(kind, spec = nil)

Creates an explicit mask record for imageEx and iconEx.

Kinds

KindMain FieldsResult
"rounded"radiusRounded image coverage. Aliases: round, roundedbox, roundrect.
"chamfer"cutsChamfered image coverage. Alias: bevel.
"circle"noneCircle coverage based on the shorter side.
"capsule"noneCapsule coverage along the longer axis. Alias: pill.
"texture"source, channel, invert, uv, cropUse a second texture as coverage. Aliases: alpha, image.
false / "none"noneDisable mask when used as style.mask.

Texture Mask Fields

FieldDescription
source / material / texture / imageMask texture source.
channel"a", "r", "g", "b", or "luma". Defaults to "a".
invert / inverseInvert mask coverage.
uvMask texture UV rectangle.
cropAlternate source rectangle form.

Example

lux
local textureMask = mgfx.api.mask("texture", {
  source = maskMaterial,
  channel = "a",
  invert = false,
})

mgfx.api.imageEx(x, y, w, h, source, {
  mask = textureMask,
  fit = "cover",
})

Back to detailed API index