WoW:API Texture SetTexCoord: Difference between revisions

From AddOn Studio
Jump to navigation Jump to search
mNo edit summary
m (Move page script moved page API Texture SetTexCoord to API Texture SetTexCoord without leaving a redirect)
 
(9 intermediate revisions by 8 users not shown)
Line 1: Line 1:
<center>'''SetTexCoord''' ''-Documentation by [[user:tcxxs|tcxxs]]-''</center>
{{widgetmethod}}
Sets the region of a texture drawn by the {{api|Texture|t=w}} widget.


Limit the region of a texture drawn by the Texture widget.
  obj:SetTexCoord(left,right,top,bottom)
 
  obj:SetTexCoord(ULx,ULy,LLx,LLy,URx,URy,LRx,LRy)
<!-- List return values and arguments as well as function name, follow Blizzard usage convention for args -->
  obj:SetTexCoord(left,right,top,bottom);
  obj:SetTexCoord(ULx,ULy,LLx,LLy,URx,URy,LRx,LRy);


== Parameters ==
== Parameters ==
=== Arguments ===
=== Arguments ===
:(left,right,top,bottom)
:;left, right, top, bottom - number
: Number - (range: 0-1)
:: 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);
:;ULx, ULy, LLx, LLy, URx, URy, LRx, LRy - number
: Number - (range: 0-1)
:: point coordinates; top left corner of the image is (0, 0); bottom right corner is (1, 1).


=== Returns ===
:none
== Details ==
The function can be used to cut a sub-region out of the texture to display in game.


== Note ==
:The function cut a sub-region,use the new TopLeftPoint is (left,top),new BottomRight is (right,bottom),so you can use the function to rotate the texture or sub-region.  The more complex 8-argument form allows for arbitrary affine transformations, see [[SetTexCoord Transformations]] for details.
== Example ==
== Example ==
  getglobal("MyAddOnTexture" .. id):SetTexCoord(0, 0.5, 0.5, 1);
  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()
texture:SetTexCoord(ULx*0.5,ULy,LLx*0.5,LLy,URx,URy,LRx,LRy)
local w = texture:GetWidth();
texture:SetWidth(w * 0.5)


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


: Use this function to select a sub-region of a texture for display in a Texture widget.  Note that the coordinates are normalised, and that the origin is the ''bottom'' left corner.
== Notes ==
* 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 ==
__NOTOC__
* {{api|Texture:GetTexCoord|t=w}}()
{{Template:WoW API}}
* [[SetTexCoord Transformations]]

Latest revision as of 04:47, 15 August 2023

Widget API ← Texture < SetTexCoord

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

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

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]

none

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()
texture:SetTexCoord(ULx*0.5,ULy,LLx*0.5,LLy,URx,URy,LRx,LRy)
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]