summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/colour.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/colour.py b/src/colour.py
index b71f325..ee61c59 100644
--- a/src/colour.py
+++ b/src/colour.py
@@ -25,6 +25,7 @@ def linear_to_standard(*colour):
'''
return [12.92 * c if c <= 0.0031308 else (1 + 0.055) * c ** (1 / 2.4) - 0.055 for c in colour]
+
def standard_to_linear(*colour):
'''
Convert [0, 1] sRGB to linear [0, 1] RGB
@@ -34,6 +35,7 @@ def standard_to_linear(*colour):
'''
return [c / 12.92 if c <= 0.04045 else ((c + 0.055) / (1 + 0.055)) ** 2.4 for c in colour]
+
def ciexyy_to_ciexyz(x, y, Y):
'''
Convert CIE xyY to CIE XYZ
@@ -45,6 +47,7 @@ def ciexyy_to_ciexyz(x, y, Y):
'''
return [Y * x / y, Y, Y * (1 - x - y) / y]
+
def ciexyz_to_ciexyy(X, Y, Z):
'''
Convert CIE XYZ to CIE xyY
@@ -60,6 +63,7 @@ def ciexyz_to_ciexyy(X, Y, Z):
x = X * y / Y
return [x, y, Y]
+
def ciexyz_to_linear(X, Y, Z):
'''
Convert CIE XYZ to [0, 1] linear RGB
@@ -74,6 +78,7 @@ def ciexyz_to_linear(X, Y, Z):
b = 0.0557 * X - 0.2040 * Y + 1.0570 * Z
return [r, g, b]
+
def linear_to_ciexyz(r, g, b):
'''
Convert [0, 1] linear RGB to CIE XYZ
@@ -88,6 +93,7 @@ def linear_to_ciexyz(r, g, b):
Z = 0.0193 * r + 0.1192 * g + 1.9502 * b
return [X, Y, Z]
+
def srgb_to_ciexyy(r, g, b):
'''
Convert [0, 1] sRGB to CIE xyY
@@ -101,6 +107,7 @@ def srgb_to_ciexyy(r, g, b):
(X, Y, Z) = linear_to_ciexyz(r, g, b)
return ciexyz_to_ciexyy(X, Y, Z)
+
def ciexyy_to_srgb(x, y, Y):
'''
Convert CIE xyY to [0, 1] sRGB