I would like to fade the color of a pixel out toward white, but obviously maintain the same color. If I have a pixel (200,120,40)
, will adding 10 to each value to m
Simply linearly interpolate between your color and white:
def lerp(a, b, t):
return a*(1 - t) + b*t
import numpy as np
white = np.array([255, 255, 255])
my_color = np.array([...])
lightened25 = lerp(my_color, white, 0.25)
Or without numpy:
lightened25 = [lerp(c, w, 0.25) for c, w in zip(my_color, white)]