Quantcast
WoWInterface - View Single Post - How to add a thin border to a frame?
View Single Post
12-16-20, 09:52 AM   #17
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,348
Again, the same as Kanegasi but slightly different in order to bake the border colouring into your created frames:

Lua Code:
  1. local function ColorBorders(self, r, g, b, a)
  2.     for i=1, 4 do
  3.         self.borders[i]:SetColorTexture(r, g, b, a and a or 1)
  4.     end    
  5. end
  6.  
  7. local function CreateBorderFrame(name, thickness)
  8.     local f = CreateFrame("Frame", name)
  9.     f:SetSize(40, 40)
  10.     f.bg = f:CreateTexture()
  11.     f.bg:SetAllPoints()
  12.     f.bg:SetTexture("Interface/BUTTONS/WHITE8X8")
  13.     f.bg:SetVertexColor(0, 0, 0)
  14.     f:SetResizable(true)
  15.     f:EnableMouse(true)
  16.     f:RegisterForDrag("LeftButton")
  17.     f:SetScript("OnDragStart", function(self)
  18.         self:StartSizing("BOTTOMRIGHT")
  19.     end)
  20.     f:SetScript("OnDragStop", function(self)
  21.         self:StopMovingOrSizing()
  22.     end)
  23.     f.SetBorderColor = ColorBorders
  24.     f.borders = {}
  25.     local offset = (thickness/2)
  26.     for i=1, 4 do
  27.         f.borders[i] = f:CreateLine(nil, "BACKGROUND", nil, 0)
  28.         local l = f.borders[i]
  29.         l:SetThickness(thickness)
  30.         l:SetColorTexture(1, 1, 0, 1)
  31.         if i==1 then
  32.             l:SetStartPoint("TOPLEFT", -offset, 0)
  33.             l:SetEndPoint("TOPRIGHT", offset, 0)
  34.         elseif i==2 then
  35.             l:SetStartPoint("TOPRIGHT", 0, offset)
  36.             l:SetEndPoint("BOTTOMRIGHT", 0, -offset)
  37.         elseif i==3 then
  38.             l:SetStartPoint("BOTTOMRIGHT", offset, 0)
  39.             l:SetEndPoint("BOTTOMLEFT", -offset, 0)
  40.         else
  41.             l:SetStartPoint("BOTTOMLEFT", 0, -offset)
  42.             l:SetEndPoint("TOPLEFT", 0, offset)
  43.         end
  44.     end
  45.     return f
  46. end
  47.  
  48. local f = CreateBorderFrame("ZaxFrame1", 1)
  49. f:SetPoint("RIGHT", UIParent, "CENTER", -20, 0)
  50. f = CreateBorderFrame("ZaxFrame2", 18)
  51. f:SetPoint("LEFT", UIParent, "CENTER", 20, 0)
  52. ZaxFrame2:SetBorderColor(0.2, 0.5, 0.8)
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 12-16-20 at 09:57 AM.
  Reply With Quote