Class · inherits UIComponent
UIGradient
Applies a color and transparency gradient to the parent GuiObject.
About UIGradient
UIGradient applies a color and transparency gradient to the parent
GuiObject. The appearance of the gradient is configurable through its
Color, Transparency,
Offset, Rotation,
Scale, TileMode, and
Type.
UIGradient will not apply to child or descendant
GuiObjects. In order to apply the same gradient to multiple
objects, you will need multiple gradient instances.
See also appearance modifiers
for more information on the UIGradient modifier and how it works.
Supported Objects
You can apply UIGradient modifiers to Frame, TextLabel,
TextButton, ImageLabel, ImageButton, Path2D,
and ViewportFrame. However, ScrollingFrame and TextBox
are not currently supported.
Performance Considerations
In order to efficiently use a UIGradient, follow these principles:
Avoid using more than 6 color stops on the
Colorsequence.Avoid using a
UIGradienton any object that applies a text stroke (TextStrokeColor3), as the gradient will try to blend with strokes and borders, and may cause performance issues.Avoid setting
ColorandTransparencyfrequently: this causes the sequence of colors to rebuild often, which is expensive. If possible, set these properties only once and try to animate theOffsetorRotationproperties to achieve a similar effect. Alternatively, you can change the color of the parentGuiObjectusing such properties asBackgroundColor3,ImageColor3, orTextColor3.When applying an unchanging gradient on a UI element whose state changes a lot, there is a tradeoff between using a
UIGradient(processing time) and a static gradient image (memory).
Properties 8
Color
: ColorSequenceDetermines the color blended with the parentGuiObjectalong the length of the gradient.This property describes the color to blend with the parent
GuiObjectalong the providedColorSequence. This property works in a similar manner toBeam.ColororTrail.Color, except that it applies over a distance determined by theOffsetandRotation.Enabled
: booleanWhether the gradient is enabled or not.Offset
: Vector2Determines the scalar translation of the gradient from the center of the parentGuiObject.This property determines the scalar translation of the gradient from the center of the parent
GuiObject. It is a scalar translation, meaning that the actual pixel offset is determined by theAbsoluteSizeof the parentGuiObject. For example, a value of(1, 0)shifts the gradient horizontally to the right by a distance equal to the parent object's size. Depending on theRotation, this may cause the gradient to be partially visible or not visible at all.Also see
Rotationwhich also affects the geometry of the applied gradient.Rotation
: floatDetermines the clockwise rotation in degrees of the gradient starting from left to right.Scale
: floatMultiplies the extent of the gradient, controlling how much of the color/transparency sequence is visible within the element.This property multiplies the extent of the gradient, controlling how much of the color/transparency sequence is visible within the parent
GuiObject.A value of
1(default) means the full sequence spans the element exactly once.Values less than
1compress the gradient so that the full sequence fits in a smaller region. The remaining area is determined byTileMode. Note thatScaleis clamped to a minimum of0.001to avoid degenerate gradients.Values greater than
1stretch the gradient beyond the element bounds so that only a portion of the sequence is visible.
The effect of
Scalealso depends on the gradient'sType:GradientType.Linear—Scaleaffects the distance between the start and end control points.GradientType.Radial—Scaleaffects the radius of the radial gradient.GradientType.Elliptical—Scaleaffects both radii of the elliptical gradient.GradientType.Conical—Scaleaffects the angular sweep, clamped so that the sweep does not exceed a full revolution.
See also
TileModewhich determines how the gradient repeats whenScalecauses it to not fill the entire element.TileMode
: GradientTileModeDetermines how the gradient repeats.This property determines what happens when the gradient
Scaleis less than1or whenOffsetshifts the gradient so that it does not fully cover the element. SeeGradientTileModefor possible values and their effect.See also
Scalewhich controls how much of the color/transparency sequence is visible.Transparency
: NumberSequenceDetermines how much the parentGuiObjectcan be seen through along the length of the gradient.This property describes how opaque the parent UI element will be along the provided
NumberSequence. This property works in a similar manner toBeam.TransparencyorTrail.Transparency, except that it applies over a distance determined by theOffsetandRotation.Note that the envelope values of the
NumberSequenceKeypointsare ignored.Type
: GradientTypeDetermines the shape of the gradient as linear, radial, elliptical, or conical.This property determines how the gradient varies across the parent
GuiObject. SeeGradientTypefor possible values and their effect.See also
Scalewhich controls how much of the color/transparency sequence is visible, andTileModewhich determines repetition behavior.
UIGradient also has every member of UIComponent. Deprecated and Roblox-only members are hidden.
Reference text from the Roblox Creator Documentation, licensed CC BY 4.0, reorganized by rbxtoolshub.com · Studio 0.743.0.7431133.