Widget API ← Texture < SetTexCoord

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


Parameters Edit

Arguments Edit

left, right, top, bottom - number
side coordinates; top left corner of the image is (0, 0); bottom right corner is (1, 1).
ULx, ULy, LLx, LLy, URx, URy, LRx, LRy - number
point coordinates; top left corner of the image is (0, 0); bottom right corner is (1, 1).

Returns Edit


Details Edit

The function can be used to cut a sub-region out of the texture to display in game.

Example Edit

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

Displays the bottom-left quarter of the image.

local ULx,ULy,LLx,LLy,URx,URy,LRx,LRy = texture:GetTexCoord()
local w = texture:GetWidth();
texture:SetWidth(w * 0.5)

Change the "view" of a texture to the right, to one half, while maintaining aspect ratio and scale.

Notes Edit

  • the coordinates are normalized, and that the origin is the top left corner.
  • Tested in patch 2.0.6, and the origin is in fact in the top left, and not the bottom left as was previously stated
  • Unless you want to do rotations, use the (left,right,top,bottom) notation.
  • The more complex 8-argument form allows for arbitrary affine transformations, and transformations based on previous values.

See also Edit

Ad blocker interference detected!

Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.