Thread Tools Display Modes
08-21-21, 05:42 AM   #1
Zax
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Aug 2006
Posts: 147
Texture Coordinates problem.

I'm trying to display a progress bar made with a texture file in a frame. The goal is to set the width of this texture according to a given parameter: let's say from 0 (no visible texture) to 1 (texture fills all the frame's width). At 0.5, the left side of the bar must be filled with the texture.

At this time, I have:
Lua Code:
  1. myFrame.texture:SetTexture(pathToMyTGAfile)
  2.         myFrame.texture:SetTexCoord(0, 0.5, 1, 0.5)
  3.         myFrame.texture:SetAlpha(1)
Whatever the values of SetTexCoord(), the texture fills all the frame's width.
The bar size is 100 (w) x 15 (h) px. The TGA file is 8 (w) x 16 (h) px.

I know it would be easier to create a child frame inside the "bar" frame, fill it with texture and then set the width of the child frame, but in my case, it will lead to others problem. So I would prefer to manage the texture coordinates... If it is possible.

Thank you.
__________________
Zax - Addons List, not all maintained.
  Reply With Quote
08-21-21, 12:16 PM   #2
Billtopia
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Apr 2009
Posts: 110
SetTexCoord sets a subsection of the texture file to show as the texture like the minimap pips are all in one file and they pull each pip out by its coordinates.

https://wowpedia.fandom.com/wiki/API_Texture_SetTexCoord
perhaps a statusbar would work better. You could use your texture for the fill, have a background or not, set colors, have it mouse interactable or not... and more

Last edited by Billtopia : 08-21-21 at 12:19 PM.
  Reply With Quote
08-21-21, 12:29 PM   #3
Billtopia
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Apr 2009
Posts: 110
something like this

lua Code:
  1. local statusbar = CreateFrame("StatusBar", nil, UIParent)
  2. statusbar:SetPoint("CENTER", UIParent, "CENTER", 0, -250)
  3. statusbar:SetStatusBarTexture("Path to your texture file")
  4. statusbar:GetStatusBarTexture():SetHorizTile(false)
  5. statusbar:GetStatusBarTexture():SetVertTile(false)
  6. statusbar:SetStatusBarColor(0, 1, 0)
  7.  
  8. statusbar:SetMinMaxValues(0, 100) -- 0 - 100 bar
  9. statusbar:SetValue(50) -- half full
  Reply With Quote
08-22-21, 01:32 AM   #4
Zax
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Aug 2006
Posts: 147
Though initially I didn't want to create another frame/object, your solution is fine (just added SetSize()).
Thank you Billtopia
__________________
Zax - Addons List, not all maintained.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Texture Coordinates problem.

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off