hilarious math crashes my gmod. Some Help?

Hey, I want my color to turn red, let’s say my Color is
[lua]
Color(50,240,240,255)
[/lua]

If I damage it, the color should turn red.
I made
[lua]
local Clr = Color(((1 - (hp/45)) * (255 - r)) + r, g - ((1-(hp/45)) * g), b - ((1-(hp/45)) * b), a) – BAHAHA
[/lua]
for that.
It is a pain for teh eyes.

BUT

It is the right math-function. My math-crapulator does it right and that thing costs 150€ (189,9 US$)
The most people would just make the Color red, without considering my Color from above in the math-function
by just doing (1 - (hp/45)) * 255
… which could end up being like this: Color(50,250,250) -> Color(30,250,250)
RED went darker as before, because our starting RED wasn’t considered in the math function.

My function from above takes this into account:

  • Considering Color from before.
  • Considering Max ( 255 ) and Min ( 0 )

I’ll cut the math-function into peaces for better understanding:
[LUA]
local c = self.Color2
local r,g,b,a = c.r, c.g, c.b, c.a
local hp = health

		local red1 = 1 - (hp/45) -- Calculates the gain in RED under 45 of Health.
		local red2 = 255 - r -- Consideres the Max 255 and the difference left 'til.
		local red3 = red1 * red2 + r -- Calculates the gain in RED still under the Max while including the difference from before to our starting RED.

		local green1 = (1-(hp/45)) * g
		local green2 = g - green1 -- The same, but backward, so it slowly decreases GREEN until 0

		local blue1 = (1-(hp/45)) * b
		local blue2 = b - blue1 -- The same, but backward, so it slowly decreases BLUE until 0

		local Clr = Color(red3, green2, blue2, a)

[/LUA]
Now why does it crash my Garry’s Mod? :v:

Should I make a warning you could get cancer in the eyes?
Editline:[/Editline]
Screw that, kept crashing, I use LerpVec now and it works fine.