1. #1
    Deleted

    [Lua] Apply border around texture

    Hey there,

    I've been messing around with various approaches of creating icons which have a border. So far I have been using
    Code:
    f.icon:SetTexCoord(.08, .92, .08, .92)
    to remove the default borders which are included in the icon texture. Similiar to ElvUI AddOnSkins I did search for some hints on how they are applying a border around the icon, yet I am having trouble of finding some more information. Basically I want to write a function which takes any frame (like f in this example), gives it a black border which is either 1px or 2px thick and insets an icon of the frame in it.

    Using the code from RealUI I still had some issues because the borders were not 1px thick on every side which seemed pretty inconsistent. This might just be the texture used for this, though. The adapted code is
    Code:
    function CreateBD(frame, alpha)
        frame:SetBackdrop({
            bgFile = [[Interface/AddOns/nAuras/Media/Plain]], 
            edgeFile = [[Interface/AddOns/nAuras/Media/Plain]], 
            edgeSize = 1, 
        })
        frame:SetBackdropColor(0.15, 0.15, 0.15, alpha)
        frame:SetBackdropBorderColor(0, 0, 0)
    end
    
    function CreateBDFrame(frame, alpha)
        local f
        if frame:GetObjectType() == "Texture" then
            f = frame:GetParent()
        else
            f = frame
        end
        local lvl = f:GetFrameLevel()
        local bg = CreateFrame("Frame", nil, f)
        bg:SetParent(f)
        bg:SetPoint("TOPLEFT", f, -1, 1)
        bg:SetPoint("BOTTOMRIGHT", f, 1, -1)
        bg:SetFrameLevel(lvl == 0 and 1 or lvl - 1)
    
        CreateBD(bg, alpha)
    
        return bg
    end
    I did even mess around with the addon rSetBackdrop yet I am stuck with getting this done with a nice approach. Do you have any suggestions how I could achieve what I am looking for?

    EDIT: I have included a sample image which describes my current problem.
    Code:
    i.imgur.com/1YYJXDE.png
    You will notice that the first, fourth and seventh icon are displayed perfectly - the second and fifth icon however have a thick border on their left while the third and sixth icon have them on their right side.

    - - - Updated - - -

    Surprisingly I resolved the issue with a simple fix - changing the parent of my indicators. It seems as if my previous parent frame was causing some issues with the proper positioning. As I don't need it anymore I just deleted it and I'm good to go.
    Last edited by mmoc6896eaa686; 2014-11-05 at 03:27 PM.

  2. #2
    oops, posted some code and then saw you had solved it :P
    Last edited by rijn dael; 2014-11-05 at 09:23 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •