API Texture SetTexture

From Wowpedia
Jump to: navigation, search

Changes the texture of a Texture widget.

texture:SetTexture("filename" or fileID[, "horizWrap"[, "vertWrap"[, "filterMode"]]])

Arguments

filename 
String - Path to a texture image.
fileID 
Number (fileID) - ID number specifying a Blizzard texture file. Returned by various API functions.
horizWrap 
String - Wrap behavior specifying what should appear when sampling pixels with an x coordinate outside the (0, 1) region of the texture coordinate space. The following wrap modes may be specified:
Mode Behavior
"CLAMP" (default) The edges of the texture are repeated infinitely.
"CLAMPTOBLACK" Fills the rest of the texture coordinate space with black.
"CLAMPTOBLACKADDITIVE" Fills the rest of the texture coordinate space with a transparent black.
"CLAMPTOWHITE" Fills the rest of the texture coordinate space with white.
"REPEAT" (or true) The texture is repeated (in its entirety) infinitely.
"MIRROR" The texture is repeated (in its entirety) infinitely, with adjacent instances mirrored.
vertWrap 
String - Wrap behavior specifying what should appear when sampling pixels with a y coordinate outside the (0, 1) region of the texture coordinate space.
NOTE: As of 7.3.5.26972, this parameter is ignored, and the vertical wrapping mode is usually set to the value passed for horizWrap.
filterMode 
String - Texture filtering mode to use, one of: "LINEAR" (default; bilinear filtering), "TRILINEAR" (also sampling mipmaps), or "NEAREST" (nearest-neighbor filtering).

Details

  • Pixels outside the (0,0)--(1,1) square in the texture coordinate space (which contains the full original texture) may be sampled when texture coordinates are explicitly modified by Texture:SetTexCoord, or implicitly modified by the tiling mechanism when the size of the texture widget is greater than the default size of the supplied texture file.
  • Custom images must be in BLP or TGA format, and must have power-of-two dimensions. TGA images may have 8, 24, or 32 bits per pixel for grayscale, RGB, and RGBA images respectively; RLE is supported.
  • The game will only display image files that existed when it was started, so you may need to restart the game for newly-added custom textures to appear.
  • Textures are loaded asynchronously, the initial value of texture:GetSize() will be 0,0 until texture:IsObjectLoaded() becomes true, after which it will be the native size of the texture (e.g. 64x64). See also TextureLoadingGroupMixin:IsFullyLoaded()

Patch changes

  • Battle for Azeroth Patch 8.0.1 (2018-07-17): Added filterMode to change how the texture is sampled.
  • Legion Patch 7.0.3 (2016-07-19): No longer possible to set a color with SetTexture, a new function Texture:SetColorTexture(r, g, b[, a]) has been added which sets the color.
  • Cataclysm Patch 4.0.3a (2010-11-23): No longer provides a proper return for if the given texture was valid or not.

See also