SetTexCoord help

90 Night Elf Hunter
6620
Hi, I have a status bar whose texture I would like to cut in half, preserving the right side, but keeping the right side anchored to the right side of a background texture I have, similar to a reverse filling of a status bar. However, no matter what attempts I make, it always takes the right side of the image and stretches it over the left side, or moves it around. Any ideas?
Reply Quote
100 Gnome Warrior
13350
We'd need to see the code. A simple example is:
local f=CreateFrame("Frame","TcT",UIParent)
f:SetSize(36,36)
f:SetPoint("CENTER")
f.texture=f:CreateTexture(nil,"ARTWORK")
f.texture:SetHeight(36)
f.texture:SetPoint("RIGHT")
f.texture:SetTexture("Interface\\Icons\\INV_Misc_QuestionMark")
f.value = 0
f:SetScript("OnUpdate",function(self,elapsed)
self.value = (self.value + 1)%100
local width = (100-self.value)/100
self.texture:SetWidth(36*width)
self.texture:SetTexCoord(1-width,1,0,1)
end)
Edited by Ro on 12/8/2012 10:49 PM PST
Reply Quote
90 Night Elf Hunter
6620
http://imgur.com/D6EJg

Is an image of what I have already coded. The frame on the left is finished, as a status bar that operates under the unit health event with a plaer conditional. The one on the right is giving me problems. See how the angle on the right side of the frame is squished, while the background texture isnt? I've been looking for a way to just shear off a percentage of the overlay frame while preserving that angle. Is that possible?

My initial code for editing the frame goes something like:

/script stat_texture:SetTexCoord(percent, 1, 0, 1)
/script stat_texture:SetWidth(percent*background_texture:getWidth())


and when the percentage is o.3, it gives the picture linked above.

edit: Figured it out (i think).

/script stat_texture:SetTexCoord(percent, 1, 0, 1)
/script stat_texture:SetWidth(1-percent*background_texture:getWidth())
Edited by Arazon on 12/9/2012 1:38 AM PST
Reply Quote
100 Gnome Warrior
13350
Careful of order of operation:

If percent is .75 and width is 100

(1-percent)*background_texture:getWidth() = 25

1-percent*background_texture:getWidth() = -74
Edited by Ro on 12/9/2012 3:27 AM PST
Reply Quote
90 Night Elf Hunter
6620
make that Stat_Texture:SetTexCoord((1-percent), 1, 0, 1)
Stat_Texture:SetWidth((percent)*BG_Texture:GetWidth())
target_arrow:SetPoint("BOTTOM", Stat_Texture, "TOPLEFT", 10/250*Stat_Texture:GetWidth(), -5)


But when I do that, I use these input values, and get this result- it's rather confusing.
Imagine your health dips to 90%, or 0.9. In that case, the left coordinate should move back by a factor of 0.1, and the width should be 0.9* whatever the original width was.

http://imgur.com/xsiVu
Reply Quote
90 Night Elf Hunter
6620
It appears as if my width of my textures are actually larger than what they appear, and the extra part is not showing...the arrow is anchored to the end of my overlay texture (grey) and when it's resting at 0, 0 in the upper left hand corner it extends 40 pixels out, I have to set its point in 40 to make it line up.
Reply Quote
90 Night Elf Hunter
6620
Here's the code I've been running on, the XML initializes most of the frames, and the scripts give them their attributes, so the XML is not really needed.

http://pastebin.com/yvrEpE9X
Reply Quote
90 Night Elf Hunter
6620
Fixed: It was the textures themselves. Chunk of canvas space in the .tga, didn't see them until I opened them.
Reply Quote

Please report any Code of Conduct violations, including:

Threats of violence. We take these seriously and will alert the proper authorities.

Posts containing personal information about other players. This includes physical addresses, e-mail addresses, phone numbers, and inappropriate photos and/or videos.

Harassing or discriminatory language. This will not be tolerated.

Forums Code of Conduct

Report Post # written by

Reason
Explain (256 characters max)
Submit Cancel

Reported!

[Close]