Thread Tools Display Modes
Prev Previous Post   Next Post Next
04-30-14, 02:37 PM   #1
Malakahh
An Aku'mai Servant
AddOn Author - Click to view addons
Join Date: Jun 2009
Posts: 30
SetPortraitToTexture and SetTexCoord

Hi

I'm in the process of creating a casting bar, and I'm currently working with the icon of the spell currently being cast.

The icon I plan to use is the one returned by UnitCastingInfo(). This icon however, is square with a border, I want a circular icon.

I have tried using SetPortraitToTexture() and it does indeed make it fit inside a circle, this however leaves some of the border present in the icon image still visible, so I thought, hey, let's crop these out using SetTexCoord()! This does remove the border, however, the image is no longer circular. This has the same effect no matter the call order of these two.

This is the relevant code (from my OnEvent handler)
Lua Code:
  1. if event == "UNIT_SPELLCAST_START" then
  2.     local name, _, _, texture, startTime, endTime = UnitCastingInfo(this.unit)
  3.  
  4.     if not name then
  5.         this.Hide()
  6.         return
  7.     end
  8.  
  9.     SetPortraitToTexture(centerContentTexture, texture)
  10.     centerContentTexture:SetTexCoord(0.1, 0.9, 0.1, 0.9)
  11.  
  12.     this.casting = 1
  13.     this.startTime = startTime
  14.     this.endTime = endTime
  15.  
  16.     this.Show()
  17. end

An an example of what this looks like:


I don't know how to achieve what I want, a circular image where no pieces of the border are left. Any help is greatly appreciated =)

*EDIT*
So, 2 minutes after posting this, I realized that it was actually circular, my numbers in SetTexCoord() where just wrong. So it has now removed some of the border, while maintaining being circular. I can't get it perfect though, which is unfortunate, but this leaves me to think that I'm going about this the wrong way. Is there a way to crop the picture, and use this cropped instance with SetPortraitToTexture()?

Last edited by Malakahh : 04-30-14 at 02:46 PM.
  Reply With Quote
 

WoWInterface » Developer Discussions » Lua/XML Help » SetPortraitToTexture and SetTexCoord


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