Skip to content

Instantly share code, notes, and snippets.

@Ethosa
Last active April 13, 2020 09:20
Show Gist options
  • Save Ethosa/ad983ae3174023e9b06bcabd73cbb08d to your computer and use it in GitHub Desktop.
Save Ethosa/ad983ae3174023e9b06bcabd73cbb08d to your computer and use it in GitHub Desktop.
finish = 187
# current color: Color(0.0, 0.3, 0.8)
old_r = 0.0
old_g = 0.3
old_b = 0.8
# target color: Color(0.9, 0.08, 0.2)
target_r = 0.9
target_g = 0.08
target_b = 0.2
# calculate difference
r_smooth = target_r - old_r
g_smooth = target_g - old_g
b_smooth = target_b - old_b
def get_color_by_step(step):
r = old_r + (r_smooth * step / finish)
g = old_g + (g_smooth * step / finish)
b = old_b + (b_smooth * step / finish)
return r, g, b
for step in range(finish):
print("Color(%f, %f, %f)" % get_color_by_step(step))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment