Well, I'm updating BalancePowerTracker and I decided to create a nice translation animation (somewhat like a cast bar) instead of having a frame move itself via a throttled OnUpdate handler, and thus leaving all the animation CPU usage to the game.
So I code it that way in a old laptop with 1024x768 resolution and it works fine, nice and shinny.
My surprise is when I get home, I upload my addon to the desktop (brand new 1920x1080) and the moving spark is now free!, unbounded by the awful bar borders (it was never bounded, but it stayed in like a good boy)
I check and recheck... all the calculations are right, the animation offset is what and where it should be, so nearly becoming bald from picking on my own hair, I decide to try again in the old laptop, and it works fine...
You can imagine my hopelessness... so I change the screen resolution settings in my desktop and it works FOUND YA!, and now my problem is that with some resolutions it works fine, and others it flees.
After this story, my question is: Does anybody know the relation between this elements? I tried with screen ratio and screen width, without finding it. Here are my results:
800x600 - fine (animation ends at the end of the bar)
1024x768 - fine (animation ends at the end of the bar)
1152x864 - escapes (the animation ends at ~1.125 * barLength)
1280x600 - fine (animation ends at the end of the bar)
1280x720 - fine (it it falls short, I can't see it)
1280x768 - fine (it it falls short, I can't see it)
1280x800 - escapes (the animation ends at ~1.065 * barLength)
1280x960 - escapes (the animation ends at ~1.166 * barLength)
1280x1024 - escapes (the animation ends at ~1.2 * barLength)
1360x768 - fine (animation ends at the end of the bar)
1366x768 - fine (it it falls short, I can't see it)
1400x1050 - escapes (the animation ends at ~1.25 * barLength)
1440x900 - escapes (the animation ends at ~1.125 * barLength)
1600x900 - escapes (the animation ends at ~1.125 * barLength)
1680x1050 - escapes (the animation ends at ~1.2 * barLength)
1920x1080 - escapes (the animation ends at ~1.25 * barLength)
And the relevant parts of the code:
Lua Code:
local spellCast, _, _, _, startTime, endTime = UnitCastingInfo("player")
local progress = max((GetTime()*1000 - startTime)/(endTime - startTime),0) --[0,1]
local duration = (endTime - max(GetTime()*1000,startTime))/1000
local origin = (-.5 + progress)*width
local dest = .5*width
local offset = (dest - origin)
me.spark:ClearAllPoints();
me.spark:SetPoint("CENTER",origin,0)
me.sparkTranslation:SetOffset(offset,0)
me.sparkTranslation:SetDuration(duration)
me.spark:Show()
me.sparkAnimationGroup:Play()
Thank you!!!