TextureBase:SetGradient

From Warcraft Wiki
Jump to navigation Jump to search

Sets a gradient color shading for the texture.

TextureBase:SetGradient(orientation, minColor, maxColor)

Arguments

orientation
string
  HORIZONTAL - Start color on the left, end color on the right.
  VERTICAL - Start color at the bottom, end color at the top.
minColor
ColorMixin🔗 - The starting color; requires alpha.
maxColor
ColorMixin🔗 - The ending color; requires alpha.

Details

  • Gradient color shading does not change the underlying color of the texture image, but acts as a filter; see Region:SetVertexColor for details.

Example

Sets the gradient vertically (bottom to top) from yellow to blue.

API TextureBase SetGradient 02.png
local tex = UIParent:CreateTexture()
tex:SetPoint("CENTER")
tex:SetSize(64, 64)
tex:SetTexture("Interface/Buttons/WHITE8x8")
tex:SetGradient("VERTICAL", CreateColor(1, 1, 0, 1), CreateColor(0, 0, 1, 1))

Sets the gradient horizontally (left to right) from yellow to blue.

API TextureBase SetGradient 01.png
local tex = UIParent:CreateTexture()
tex:SetPoint("CENTER")
tex:SetTexture("interface/icons/inv_mushroom_11")
tex:SetGradient("HORIZONTAL", CreateColor(1, 1, 0, 1), CreateColor(0, 0, 1, 1))

Patch changes

Dragonflight Patch 10.0.0 (2022-10-25): Changed args to ColorMixin; merged Texture:SetGradientAlpha.