Paint, Patterns, Transforms, and Capabilities
Paint helpers create explicit records for colors, gradients, procedural patterns, visual transforms, and capability queries.
Facade aliases include MGFX.Solid, MGFX.LinearGradient, MGFX.LinearGradientStops, MGFX.RadialGradient, MGFX.ConicGradient, MGFX.RingRadialGradient, MGFX.SectorRadialGradient, MGFX.ShapeAngularGradient, MGFX.RingAngularGradient, MGFX.ArcAngularGradient, MGFX.SectorAngularGradient, MGFX.StripePattern, MGFX.SmokePattern, MGFX.Transform, MGFX.PointerTilt, MGFX.ProjectedQuad, MGFX.PushTransform, MGFX.PopTransform, MGFX.TransformPoint, MGFX.UntransformPoint, MGFX.GetCapabilities, and MGFX.Supports.
Scope
- Linear, radial, conic, ring/sector radial, and shape/ring/arc/sector angular gradients all support stop tables through the same LUT pipeline.
- Patterns are shader paint slots; do not expand them into many line draws.
- 2.5D visual tilt uses
style.transform,pushTransform, orpointerTilt. Do not add primitive-specificProjectedXXXAPIs.
This Page
- solid
- linearGradient
- linearGradientStops
- radialGradient
- ringRadialGradient
- sectorRadialGradient
- conicGradient
- shapeAngularGradient
- ringAngularGradient
- arcAngularGradient
- sectorAngularGradient
- stripePattern
- smokePattern
- transform
- pointerTilt
- projectedQuad
- pushTransform
- popTransform
- transformPoint
- untransformPoint
- get
- supports
Function Reference
solid
mgfx.api.solid(color)Creates a solid paint record. Most APIs also accept Color directly; solid is useful when you want an explicit paint record.
linearGradient
mgfx.api.linearGradient(x1, y1, x2, y2, colorA, colorB)
mgfx.api.linearGradient(x1, y1, x2, y2, stops)Creates a linear gradient in primitive-local normalized space. Passing a stop table is equivalent to linearGradientStops.
linearGradientStops
mgfx.api.linearGradientStops(x1, y1, x2, y2, stops)Creates a multi-stop linear gradient. Stops are sorted and completed at 0 and 1 when needed.
Stop forms:
local stops = {
Color(80, 170, 255),
{0.35, Color(90, 220, 180)},
{pos = 0.70, color = Color(255, 210, 110)},
{offset = 1, color = Color(255, 96, 78, 0)},
}radialGradient
mgfx.api.radialGradient(cx, cy, radius, colorA, colorB)
mgfx.api.radialGradient(cx, cy, radius, stops)Creates a radial gradient record. The shader path samples the shared gradient LUT after computing radial t.
ringRadialGradient
mgfx.api.ringRadialGradient(stopsOrColorA, colorB = nil)Creates a ring-local radial gradient. In ring/arc/sector shaders:
t = (r - innerRadius) / (outerRadius - innerRadius)sectorRadialGradient
mgfx.api.sectorRadialGradient(stopsOrColorA, colorB = nil)Creates a sector-local radial gradient using the same local radial space as ringRadialGradient.
conicGradient
mgfx.api.conicGradient(cx, cy, rotationDeg, colorA, colorB)
mgfx.api.conicGradient(cx, cy, rotationDeg, stops)Creates a full 360-degree angular gradient around the normalized center. This is not the same as shape-local angular gradients used by arc/sector spans.
shapeAngularGradient
mgfx.api.shapeAngularGradient(stopsOrColorA, colorB = nil, rotation = nil)Creates a local angular gradient over the current ring/arc/sector angular range.
ringAngularGradient
mgfx.api.ringAngularGradient(stopsOrColorA, colorB = nil, rotation = 0)Alias for ring-local angular paint.
arcAngularGradient
mgfx.api.arcAngularGradient(stopsOrColorA, colorB = nil, rotation = 0)Creates an angular gradient over startDeg..endDeg for arc drawing.
sectorAngularGradient
mgfx.api.sectorAngularGradient(stopsOrColorA, colorB = nil, rotation = 0)Creates an angular gradient over startDeg..endDeg for sector drawing.
stripePattern
mgfx.api.stripePattern(color, spacing = 12, width = 2, angle = 135, offset = 0)Creates a procedural stripe pattern record. Use it as style.pattern, trackPattern, or fillPattern rather than drawing many individual lines.
smokePattern
mgfx.api.smokePattern(color, scale = 140, density = 0.48, softness = 0.3, angle = 135, offset = 0, seed = 0)Creates a procedural smoke/noise pattern record.
transform
mgfx.api.transform(spec = nil)Copies a CSS-like draw transform record for use as style.transform.
Common fields:
| Field | Description |
|---|---|
origin | "50% 50%", {x, y}, or equivalent. |
perspective | Perspective distance. |
rotateX / rotateY / rotate | Rotation in degrees. |
scale | Uniform scale or scale record. |
translate | Visual translation. |
skewX / skewY | Skew in degrees. |
steps | Quad subdivision steps for projected drawing. |
pointerTilt
mgfx.api.pointerTilt(x, y, spec = nil)Creates a pointer-driven 2.5D transform record. It is useful for panels, wheel items, and cards that visually tilt toward the mouse.
projectedQuad
mgfx.api.projectedQuad(spec = nil)Creates an expert projected-quad transform. Prefer pointerTilt or transform for normal UI work.
pushTransform
mgfx.api.pushTransform(spec, x = nil, y = nil, w = nil, h = nil)Pushes a draw-phase transform for multiple immediate draws. Returns a truthy value when the transform was pushed.
popTransform
mgfx.api.popTransform()Pops the active draw transform.
transformPoint
mgfx.api.transformPoint(x, y)Maps a point through the current transform.
untransformPoint
mgfx.api.untransformPoint(sx, sy)Approximately maps a transformed point back to local space. Use for visual alignment helpers only; layout and hit testing remain caller-owned.
get
mgfx.api.getCapabilities(target)Returns implemented render slots and metadata for a target. The installed facade name is MGFX.GetCapabilities.
Common targets include:
mgfx.capabilities.TARGET.ROUNDED_BOX
mgfx.capabilities.TARGET.CHAMFER_BOX
mgfx.capabilities.TARGET.POLY
mgfx.capabilities.TARGET.LINE
mgfx.capabilities.TARGET.RING
mgfx.capabilities.TARGET.ARC
mgfx.capabilities.TARGET.SECTOR
mgfx.capabilities.TARGET.IMAGE
mgfx.capabilities.TARGET.PROGRESS_BAR
mgfx.capabilities.TARGET.SEGMENT_BAR
mgfx.capabilities.TARGET.TEXTsupports
mgfx.api.supports(target, key)Checks whether a target supports a public render slot.
if mgfx.api.supports(mgfx.capabilities.TARGET.RING, "outerGlow") {
mgfx.api.ringEx(cx, cy, 36, 6, {
fill = Color(80, 170, 255),
outerGlow = { width = 14 },
})
}