Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
test color mixing in sRGB
def sRGB_to_linear(c):
a = 0.055
if c <= 0.04045:
return c / 12.92
else:
return ((c + a) / (1+a)) ** 2.4
def linear_to_sRGB(c):
a = 0.055
if c <= 0.0031308:
return 12.92 * c
else:
return (1 + a)*(c ** (1/2.4)) - a
def mix_srgb(x, y):
s = (sRGB_to_linear(x) + sRGB_to_linear(y))/2.0
return linear_to_sRGB(s)
print mix_srgb(0, 248 / 255.0) * 255.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.