Think of linear interpolation as this: you have a straight line. There are two points on this line, representing two colors, say red and blue:

-------------- red ---------------------------------------- blue ----------------

Now any point on the line between red and blue corresponds to some gradient of red and blue. We can give each point on this line a scalar value, call it t:

t = 0 corresponds to red

t = 1 corresponds to blue

t between 0 and 1 corresponds to some point between red and blue, for instance t = 0.5 is exactly halfway, t = 1/3 is two thirds red, one third blue, and so on.

(t below 0 and above 1 are also possible but are less useful)

Now the formula to calculate the exact color depending on the scalar t is:

color = blue * t + red * (1 - t)

This is basically saying, take a proportion t of blue, and make the rest (1 - t) red, and add them to obtain the final color. We can rewrite this as:

color = red + (blue - red) * t

Which is really the equation of a line (thus the name linear interpolation). More broadly:

interpolated value = start value + (end value - start value) * scalar

Now if you wanted to make a color darker, you would want to interpolate between your color and black, and to make a color lighter you want to interpolate between your color and white.

Of course this isn't the only way to lighten or darken colors, even though it makes the most sense in general. You could also just add or subtract X to each component of the color until it becomes 0 or 255. It depends on your constraints/requirements and the specific effect you wish to obtain.

**Edited by Bacterius, 27 April 2013 - 08:08 PM.**