Quantcast
Pulsing background? - WoWInterface
 
Thread Tools Display Modes
09-08-20, 09:14 PM   #1
thatrickguy
A Murloc Raider
Join Date: Sep 2020
Posts: 5
Pulsing background?

Trying to make the background of my frame pulsing red, but it takes a couple of big steps from black to bright red, but then never comes back down to black. I can see the value of r climb from 0 to 1 and back down to 0, but the frame color never changes after it hits red. Thoughts?

Code:
local seconds = 0.5
local total = 0

local r = 0
local rud = 0.2

SPHowFrame:SetScript("OnUpdate", function(self, elapsed)
	total = total + elapsed
	if total > seconds then
      local r = getRedColor()
      print (r)
      self.texture = nil
      self.texture = self:CreateTexture(nil,"BACKGROUND")
      self.texture:SetColorTexture(r, 0, 0)
      self.texture:SetAllPoints(self)
      self.texture = t
      total = 0
	end
end)


function getRedColor()
   r = r + rud
   if r > 1 then
      rud = rud * -1
      r=1
   end 
   if r < 0 then 
      rud = rud * -1
      r=0
   end 
   
   return r
end

Last edited by thatrickguy : 09-08-20 at 09:20 PM.
  Reply With Quote
09-08-20, 09:54 PM   #2
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,292
For this example, you're creating a new texture every update. Create it once when you create the frame and adjust that texture.

Lua Code:
  1. local SPHowFrame = CreateFrame("Frame", nil, UIParent)
  2. SPHowFrame:SetSize(50, 50)
  3. SPHowFrame:SetPoint("CENTER")
  4. SPHowFrame.texture = SPHowFrame:CreateTexture()
  5. SPHowFrame.texture:SetAllPoints()
  6. SPHowFrame.texture:SetTexture("Interface/Buttons/WHITE8X8")
  7.  
  8. local seconds = 0.5
  9. local total = 0
  10.  
  11. local r = 0
  12. local rud = 0.2
  13.  
  14. SPHowFrame:SetScript("OnUpdate", function(self, elapsed)
  15.     total = total + elapsed
  16.     if total > seconds then
  17.       local r = getRedColor()
  18.       print (r)
  19.       self.texture:SetColorTexture(r, 0, 0)
  20.       total = 0
  21.     end
  22. end)
  23.  
  24.  
  25. function getRedColor()
  26.    r = r + rud
  27.    if r > 1 then
  28.       rud = rud * -1
  29.       r=1
  30.    end
  31.    if r < 0 then
  32.       rud = rud * -1
  33.       r=0
  34.    end
  35.    
  36.    return r
  37. end
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 09-08-20 at 09:57 PM.
  Reply With Quote
09-08-20, 10:34 PM   #3
thatrickguy
A Murloc Raider
Join Date: Sep 2020
Posts: 5
Perfect, thanks!
  Reply With Quote

WoWInterface » Developer Discussions » Graphics Help » Pulsing background?

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