WoW:API Frame CreateTexture: Difference between revisions

From AddOn Studio
Jump to navigation Jump to search
mNo edit summary
m (Move page script moved page API Frame CreateTexture to API Frame CreateTexture without leaving a redirect)
 
(5 intermediate revisions by 5 users not shown)
Line 1: Line 1:
{{Stub/API}}
{{widgetmethod}}
{{widgetmethod}}
Good for solid color backgrounds instead of using the SetBackdrop function.
 
'''CreateTexture''' is a method on [[UIObject_Frame|Frame]] objects that creates and returns a new [[UIObject_Texture|Texture]]. CreateTexture allows Lua to create textures that would otherwise only be available to XML. This method also lets developers the option to reuse virtual textures declared in XML.
 
  Frame:CreateTexture(["textureName"[, "layer"]][, "inheritsFrom"])
 
== Parameters ==
 
:;textureName : String - Name of the newly created texture. If nil, no name is assigned. The function will also set a global variable of this name to point to newly created texture.
:;layer : String - The [[layer]] to use.
:;inheritsFrom : String - a comma-delimited list of names of virtual frames to inherit from (the same as in XML). If nil, no frames will be inherited. These frames cannot be frames that were created using this function, they must be created using XML with '''virtual="true"''' in the tag.
 
== Usage ==
Generally, either use the [[API Frame SetBackdrop|SetBackdrop]] function or use code similar to the following to set a solid color background:


  FRAME.texture = FRAME:CreateTexture()
  FRAME.texture = FRAME:CreateTexture()
  texture:SetAllPoints(FRAME)
  FRAME.texture:[[API Frame SetAllPoints|SetAllPoints]](FRAME)
  texture:SetTexture(r,g,b[,a])
  FRAME.texture:[[API Texture SetTexture|SetTexture]](r,g,b[,a])
 
The game will not find image files that did not exist when it was started, so you may need to restart the game for the texture to appear.

Latest revision as of 04:45, 15 August 2023

Widget API ← Frame < CreateTexture

CreateTexture is a method on Frame objects that creates and returns a new Texture. CreateTexture allows Lua to create textures that would otherwise only be available to XML. This method also lets developers the option to reuse virtual textures declared in XML.

 Frame:CreateTexture(["textureName"[, "layer"]][, "inheritsFrom"])

Parameters[edit]

textureName
String - Name of the newly created texture. If nil, no name is assigned. The function will also set a global variable of this name to point to newly created texture.
layer
String - The layer to use.
inheritsFrom
String - a comma-delimited list of names of virtual frames to inherit from (the same as in XML). If nil, no frames will be inherited. These frames cannot be frames that were created using this function, they must be created using XML with virtual="true" in the tag.

Usage[edit]

Generally, either use the SetBackdrop function or use code similar to the following to set a solid color background:

FRAME.texture = FRAME:CreateTexture()
FRAME.texture:SetAllPoints(FRAME)
FRAME.texture:SetTexture(r,g,b[,a])

The game will not find image files that did not exist when it was started, so you may need to restart the game for the texture to appear.