View Single Post
11-29-10, 01:20 AM   #38
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,327
It's the same order as texture:SetTexCoord(). The numbers are in order of Left, Right, Top, and Bottom. These numbers are expressed as a decimal in the range of 0-1. If you look at your image as a coordinate system, the origin is in the upper left corner, top left is (0,0). The coordinates approach (1,1) as you move toward the lower right corner.

Now, to move the top in 150 pixels, you need to set Top to 150/256, Bottom needs to remain at 1. If you're not cropping left/right, leave those values at 0 and 1 respectively. There are also two things you should modify as well, when you do this, the rendered texture is no longer 256px, it'll be more like 106px. You should change the frame and initial texture object heights to reflect this, and don't forget to use the same coordinates to set the background's texcoord or it'll look a but funky.



An example of applying this texcoord to the render function.
Code:
addon:SetBarValue(self.ManaBar,0,mppcnt,true,false,0,1,150/256,1);


Be sure to do this to the background texture too.
Code:
texture:SetTexCoord(0,1,150/256,1);


Edit:
Oh, right... and when you set the texcoord on the background, be sure to flip the first two values if the bar is to be flipped.
Code:
texture:SetTexCoord(1,0,150/256,1);


Originally Posted by Grimsin View Post
i only need to set the cropy1 or cropy2 right? and 1 and 2 stands for the top of the texture and the bottom?
In all honesty, the function was written to not allow you to flip the texture from the crop coordinates. So for the xy pairs, it would select the lowest from the x pair for left, the highest for right. From the y pair, the lowest would be selected for top and highest for bottom. Although, if you pass nil to any coordinate value, it would substitute for what would be the default for that position. For example, x1 is sent nil while x2 is sent 0.5, the pair result would be 0 and 0.5. If x1 was 0.5 and x2 was nil, the pair would result as 0.5 and 1. The same would happen for y1 and y2.
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)

Last edited by SDPhantom : 11-29-10 at 02:21 AM.
  Reply With Quote