View Single Post
01-19-14, 09:42 AM   #1
Duugu
Premium Member
 
Duugu's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 851
Help with SetTexCoord()

Today I'm asking you for some help with SetTexCoord().
I'm trying to transform icon textures into a 'trapezoid' form. Unfortunately the results are somewhat unexpected.

Let's consider the following code:

Lua Code:
  1. tFrame = CreateFrame("Frame", UIParent)
  2. tFrame:SetPoint("CENTER", UIParent, "CENTER")
  3. tFrame:SetHeight(100)
  4. tFrame:SetWidth(100)
  5. tFrame:Show()
  6.        
  7. tTex = tFrame:CreateTexture(nil,"OVERLAY")
  8. tTex:SetTexture("Interface\\icons\\ability_ambush")
  9. tTex:SetPoint("CENTER", tFrame, "CENTER")
  10. tTex:SetTexCoord(0,0, -0.25,1, 1,0, 1.25, 1)
  11. tTex:Show()

For your overview:
Texture coordinates are
ULx/y: 0/0 URx/y: 1/0
LLx/y: 0/1 LRx/y: 1/1
And the SetTexCoord parameters are ULx/y, LLx/y, URx/y, LRx/y

The result of the code above should be like the one on the right side (I've made this one with Photoshop ... just to show what I'm expecting) in this image:



But the result is like the left one. Almost like expected ... but somewhat 'distorted' in the lower left corner. :/

I can't see where this 'distortion' comes from. Does anyone has an idea?

btw: If you test my code above the actual result will be like this:

This is as expected and is not related to my problem. I've replace the icon texture by a copy of it with a single transparent pixel at all borders. That's all.

Edit
Tried it with a more 'specific' texture. The left one is original, the right one is transformed. Weird.

Last edited by Duugu : 01-19-14 at 10:01 AM.
  Reply With Quote