DFrame Lerp?

I am trying to understand Lerp but alas I just don’t get it… I have made this code in hopes to have a DFrame slide in from outside of the screen to the center. Alas nothing happens, no animation. Instead the DFrame just sits at ScrW()/0.

function client_radio()

local tuner = vgui.Create( "DFrame" )
local posx = Lerp(0.5,ScrW()/0,ScrW()/2.5)
tuner:SetPos( posx, ScrH()/2.5)
tuner:SetSize( 230, 100 )
tuner:SetTitle( "Twisted TTT | Web radio" )
tuner:SetVisible( true )
tuner:SetDraggable( true )
tuner:ShowCloseButton( true )
concommand.Add( "radio_tuner", client_radio )

Probably because you’re dividing by 0 in your lerp statement

You can use panel:MoveTo to move it to a position.

I changed that to ScrW()/1 but still no difference.

Tried it but that looks really bad… and it starts at 0,0.

I want to use Lerp to make the DFrame move like the F1 menu in DarkRP but do not know how to Lerp.

Lol ScrW()/1 = ScrW()

MoveTo looks as bad as you make it.

If you want to move it in from the side or something, set it’s position off screen, then move it to the position?

Just go look at DarkRP code??

function PANEL:AnimationThink()
self.progress = self.progress or 1
self.progress = self.slideRight and math.max(0, self.progress - FrameTime()/self.slideInTime) or math.min(1, self.progress + FrameTime())

    local x, y = self:GetPos()
    self:SetPos(-self:GetWide() * self.progress, y)


Everything you need is there

[editline]23rd December 2013[/editline]

Refer to his repository for more information on the topic.

You use SetPos first to choose where it starts and then use MoveTo. MoveTo has non-linear interpolation so it’s only bad looking if you make it bad looking.