Skip to content

Commit

Permalink
tcolour: Add support for achromatic centroid from YAML
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasWilshaw committed Sep 21, 2024
1 parent c21ca04 commit b46b7fc
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion tcolour/tcolour.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand All @@ -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"]
Expand Down

0 comments on commit b46b7fc

Please sign in to comment.