I'm working on a project that allows you to "animate" VGUI elements, or basically mess with their attributes like size and position and make it look real smooth. It's working well, but I'm having a bit of an issue.
Here's a snippet:
[lua]local rate = sec/math.abs(v) -- v is the amount to change, seconds is the time to change it, rate is how often the timer is called
if k == "width" then
timer.Create("AnimateWide",rate,sec/rate,function()
panel:SetWide(panel:GetWide()+v/(sec^2/rate)) -- Panel is the derma object
end)[/lua]
As I said, it works fine, but the problem is when you set both width and height at the same time with largely different values. The farther away the two values get, once you do the animation the smaller value runs for less time than the other. This becomes very noticeable once you reach a difference of > 400. Is there something I can do to fix this?
Also, another question: how do you get the color of a panel?
[code]r , g , b , a = panel:GetColor()
[/code]
I think. It's not valid on some vgui elements, and is on others.
Edit: It's inherited from dlabel. It might work, it might not.
It's a lot easier if you pace your code out. It's hard for other people trying to read your code for two reasons:
1) Everything is on one line
2) There are many variables that are not described
[QUOTE=Gbps;17121853]It's a lot easier if you pace your code out. It's hard for other people trying to read your code for two reasons:
1) Everything is on one line
2) There are many variables that are not described[/QUOTE]
Ok, thanks. It's kind of tough to spread it out since it's just a big equation, but I explained the variables.
[QUOTE=|FlapJack|;17120963][code]r , g , b , a = panel:GetColor()
[/code]
I think. It's not valid on some vgui elements, and is on others.
Edit: It's inherited from dlabel. It might work, it might not.[/QUOTE]
Alas, I've tried this and it doesn't work. It returns an "attempt to call method" error. After looking over the list of clientside functions, I saw stuff like SetFGColor and SetBGColor, except there's no GetFGColor so that won't work.
Sort of like [url=http://www.garry.tv/?p=552]this[/url]? I don't know if anyone ever used it.
Mahalis you ninja, you linked to this page.
Edit: Before I posted mkai.
[QUOTE=Da Big Man;17127405]Mahalis you ninja, you linked to this page.[/QUOTE]
Links to garrys blog, not this page... Unless im not getting some wierd joke you 2 are in on or some crap like that.
Huh. Well, thanks for taking out the wind beneath my sails, mahalis. :P
I've never messed with sprites (they can be 2d? I thought they existed in the world...). So the SizeTo and the MoveTo work just like mine, but the ColorTo doesn't seem to.
Sorry, you need to Log In to post a reply to this thread.