How to Reverse Lerp?

Now I have tried many things, but I am making a health bar that declines animation towards the center. (The left bar doesnt want to work)
HP & HP1 are defined and so are the config vars.


      if HP == ply:Health() then HP = HP else HP = Lerp( 0.01, HP, ply:Health() ) end
		if HP1 == ply:Health() then HP1 = HP1 else HP1 = Lerp( 0.01, HP1, ply:Health() ) end -- Left Bar

		draw.RoundedBox(5,ScrW()/2,y,math.Clamp(HP, 0, 100)*6.25,sy,config.BG)
		draw.RoundedBox(0,ScrW()/2,y,math.Clamp(HP, 0, 100)*6.25 - 10,sy,config.HPBar)

		draw.RoundedBox(5,x,y,math.Clamp(HP1, 0, 100)*6.25,sy,config.BG) -- Left Bar
		draw.RoundedBox(0,x + 10,y,math.Clamp(HP1, 0, 100)*6.25,sy,config.HPBar) -- Left Bar

The right bar declines into the center no problem, how do I make the left bar decline to the center? (By center I mean the opposite direction to what it is currently going)
Please help, thanks.

[editline]15th September 2017[/editline]

Like how would I make the bar start from the middle and expand left?

Multiply by a negative would be the easiest solution.

Just make sure your value your multiplying also isn’t a negative or else he’ll get a positive.

Given he’s clamping the value from 0 to 100, that’s not a problem.

I tried multiplying by a Negative, all it did was go backwards. Like not start from the middle and expand out to the left, it just go from left to nothing ?

Swap HP1 and ply:Health().

You’re wanting the box to become smaller from the left side - if you think about this technically, what you’re really wanting is for the box to become smaller period, and move it to the right simultaneously.

So change the x position of your box from an absolute value to (center point - box width).

So to do this, I move it forward whilst making the box smaller? So make X larger and then reduce size gradually using lerp? including health? how might I do that?

[lua]local leftwidth = math.Clamp(HP1, 0, 100) * 6.25 – Left Bar
draw.RoundedBox(5, ScrW() / 2 - leftwidth, y, leftwidth, sy, config.BG) – Left Bar
draw.RoundedBox(0, ScrW() / 2 - leftwidth + 10, y, leftwidth - 10, sy, config.HPBar) – Left Bar[/lua]

Untested, should work though