I want to create a function $f : [0,255]^3 \rightarrow [0,255]^3$ over the integers such that if you pass in three RGB color values, a triple with a darker or lighter color will be returned, and I want the values to increase in some sort of proportion to how dark or light they are already; lightness and darkness being determined by, say, taking the average of the values.
Is there a relatively simple function that will do this? If not, is there a way to emulate it?