WoW:API Texture SetTexCoord: Difference between revisions

From AddOn Studio
Jump to navigation Jump to search
(Changed origin from bottom left to top left)
Line 18: Line 18:


== Note ==
== 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.
:The function cuts a sub-region out of the texture to display ingame.
:*Unless you want to do rotations, use the ''(left,right,top,bottom)'' notation.
:*The more complex 8-argument form allows for arbitrary affine transformations, see [[SetTexCoord Transformations]] for details.<BR>Basically the four points you specify still have to form a rectangle, but you can rotate and place it more freely.<BR>Experience with matrices is recommended since they can help you find the final coordinates of your points.
 
:The example below cuts out the lower left quarter of the texture file.
 
== Example ==
== Example ==
  getglobal("MyAddOnTexture" .. id):SetTexCoord(0, 0.5, 0.5, 1);
  getglobal("MyAddOnTexture" .. id):SetTexCoord(0, 0.5, 0.5, 1);

Revision as of 07:31, 14 September 2007

Widget API ← Texture < SetTexCoord

SetTexCoord -Documentation by tcxxs-

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);

Parameters

Arguments

(left,right,top,bottom)
Number - 0 -- 1   - actually, not bounded, but 0-1 is the texture's actual area
(ULx,ULy,LLx,LLy,URx,URy,LRx,LRy);
Number - 0 -- 1   - actually, not bounded, but 0-1 is the texture's actual area

Note

The function cuts a sub-region out of the texture to display ingame.
  • Unless you want to do rotations, use the (left,right,top,bottom) notation.
  • The more complex 8-argument form allows for arbitrary affine transformations, see SetTexCoord Transformations for details.
    Basically the four points you specify still have to form a rectangle, but you can rotate and place it more freely.
    Experience with matrices is recommended since they can help you find the final coordinates of your points.
The example below cuts out the lower left quarter of the texture file.

Example

getglobal("MyAddOnTexture" .. id):SetTexCoord(0, 0.5, 0.5, 1);

Details

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 top left corner. (Note: 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)