From b46b7fce7a66d1a0b514b508ebcc5505361998a2 Mon Sep 17 00:00:00 2001 From: Thomas Wilshaw Date: Sat, 21 Sep 2024 16:38:20 +0100 Subject: [PATCH] tcolour: Add support for achromatic centroid from YAML --- tcolour/tcolour.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tcolour/tcolour.py b/tcolour/tcolour.py index 1391b7c..99b1d9c 100644 --- a/tcolour/tcolour.py +++ b/tcolour/tcolour.py @@ -20,6 +20,12 @@ def RGBPrimaries_from_YAML(self, yaml_input) -> Colourimetry.RGBPrimaries: except KeyError as e: print("YAML ERROR: ", e) + def achromatic_centroid_from_YAML(self, yaml_input): + try: + return [yaml_input["x"], yaml_input["y"]] + except KeyError as e: + print("YAML ERROR: ", e) + def parse_data(self, data:list): """Parse the YAML data""" @@ -38,7 +44,11 @@ def parse_data(self, data:list): new_colourimetry_set.primaries = primaries if "Achromatic Centroid" in colour_space: - new_colourimetry_set.achromatic = colour_space["Achromatic Centroid"] + achromatic_centroid = colour_space["Achromatic Centroid"] + if type(achromatic_centroid) is dict: + new_colourimetry_set.achromatic = self.achromatic_centroid_from_YAML(achromatic_centroid) + else: + new_colourimetry_set.achromatic = achromatic_centroid if "Transfer Characteristic" in colour_space: new_colourimetry_set.transfer_characteristic = colour_space["Transfer Characteristic"]