API Texture SetTexCoord

From Wowpedia
Jump to: navigation, search

Modifies the region of a texture drawn by the Texture widget.

tex:SetTexCoord(left, right, top, bottom)
tex:SetTexCoord(ULx,ULy,LLx,LLy,URx,URy,LRx,LRy)

Arguments

(left, right, top, bottom)
Number - coordinates of the four (transformed) image edges in the original image.
(ULx,ULy, LLx,LLy, URx,URy, LRx,LRy)
Number - coordinates of four (transformed) image corners in the original image.

Details

  • The four-coordinate version of this function is well-suited to cropping textures. The eight-coordinate version can perform affine transformations, i.e. scaling, translating, shearing and rotating the source image.
  • The coordinates used by this function are normalized and vertically reversed compared to traditional WoW frame rectangles: (0,0) is the top-left corner of the image; (1,1) is the bottom right corner.
  • You may supply coordinates outside the [0, 1] range; the behavior varies depending on the texture displayed by the texture widget, as well as whether tiling is enabled.
    • Interface\ICONS textures are loaded into composite textures by the client; you cannot tile them, and other icons may appear outside the [0,1] coordinate region.
    • When tiling is enabled, the image is repeated outside the [0,1] texture coordinates.
    • When tiling is disabled, the outermost pixels of the source image are repeated indefinitely outside the [0,1] texture coordinates.
  • Texture:SetTexture does not clear the transformation. Call texture:SetTexCoord(0,1,0,1) to display the original image if necessary.

Example

Displays the bottom-left quarter of the image.

texture:SetTexCoord(0, 0.5, 0.5, 1);

See also