final class UIGradient
package smidr
A linear or radial gradient fill, the richer opt-in alternative to a flat UIFill. Hold one on
a widget that supports it (e.g. UIPanel.gradient) and it overrides the flat fill.
Colours are ordinary 0xAARRGGBB stops (alpha per stop is honoured). paint/fillRect build
the gradient box matrix and call Graphics.beginGradientFill — decomposing the ARGB stops into
OpenFL's separate RGB + alpha arrays through reused static buffers, so a steady-state repaint
allocates nothing. Because these stops are fixed colours they do NOT follow theme swaps; derive
them from UITheme values at build time (and rebuild on UITheme.onChanged) if you need them to.
Static methods
staticinlinehorizontal(left:Int, right:Int):UIGradient
A two-stop left→right linear gradient.
Parameters:
left | the left colour (ARGB) |
|---|---|
right | the right colour (ARGB) |
Returns:
the gradient
staticlinear(colors:Array<Int>, angle:Float = 90, ?ratios:Array<Int>):UIGradient
A linear gradient across colors.
Parameters:
colors | the ARGB stops (2+) |
|---|---|
angle | direction in degrees (0 = left→right, 90 = top→bottom) |
ratios | optional per-stop positions 0..255 (evenly spread when omitted) |
Returns:
the gradient
staticradial(colors:Array<Int>, ?ratios:Array<Int>):UIGradient
A radial gradient from the centre outward.
Parameters:
colors | the ARGB stops (centre first) |
|---|---|
ratios | optional per-stop positions 0..255 (evenly spread when omitted) |
Returns:
the gradient
staticinlinevertical(top:Int, bottom:Int):UIGradient
A two-stop top→bottom linear gradient.
Parameters:
top | the top colour (ARGB) |
|---|---|
bottom | the bottom colour (ARGB) |
Returns:
the gradient
Variables
Methods
beginFill(graphics:Graphics, x:Float, y:Float, width:Float, height:Float):Void
Opens the gradient fill on graphics (the caller then draws the shape and endFills). Use
for non-rectangular shapes; fillRect covers the common rectangle case.
Parameters:
graphics | the target graphics |
|---|---|
x | the fill box left |
y | the fill box top |
width | the fill box width |
height | the fill box height |
fillRect(graphics:Graphics, x:Float, y:Float, width:Float, height:Float, corner:Float = 0):Void
Fills a rectangle (optionally rounded) with the gradient.
Parameters:
graphics | the target graphics |
|---|---|
x | the rect left |
y | the rect top |
width | the rect width |
height | the rect height |
corner | corner radius in pixels (0 = square) |