diff --git a/road-colors.yaml b/road-colors.yaml index 78d3188..855b9bb 100644 --- a/road-colors.yaml +++ b/road-colors.yaml @@ -10,7 +10,7 @@ roads: # The starting and ending hue. The range goes from 0 to 360, with 0 and 360 # representing red. -hue: [10, 106] +hue: [37, 53] # The lightness and chroma (also known as saturation) for each type of colour. # Lightness ranges from 0 to 100; dark to bright. @@ -19,20 +19,20 @@ classes: # Colours for output into the MSS file mss: fill: - lightness: [70, 97] - chroma: [35, 29] + lightness: [1, 1] + chroma: [0.55, 0.35] casing: - lightness: [50, 50] - chroma: [70, 55] + lightness: [0.8, 0.6] + chroma: [0.85, 1] low-zoom: - lightness: [62, 92] - chroma: [50, 40] + lightness: [1, 1] + chroma: [0.55, 0.35] low-zoom-casing: - lightness: [50, 70] - chroma: [50, 65] + lightness: [0.8, 0.6] + chroma: [0.85, 1] shield: - lightness: [20, 25] - chroma: [40, 42] + lightness: [0.35, 0.25] + chroma: [1, 1] # Colours used by the road shields script shield: fill: diff --git a/scripts/generate_road_colours.py b/scripts/generate_road_colours.py index e8672ff..76e84ea 100755 --- a/scripts/generate_road_colours.py +++ b/scripts/generate_road_colours.py @@ -3,7 +3,7 @@ # Generates a set of highway colors to be stored in road-colors-generated.mss. from colormath.color_conversions import convert_color -from colormath.color_objects import LabColor, LCHabColor, sRGBColor +from colormath.color_objects import LabColor, LCHabColor, sRGBColor, HSVColor from colormath.color_diff import delta_e_cie2000 import argparse import sys @@ -12,22 +12,22 @@ import yaml from collections import OrderedDict, namedtuple class Color: - """A color in the CIE lch color space.""" + """A color in the HSV color space.""" - def __init__(self, lch_tuple): - self.m_lch = LCHabColor(*lch_tuple) + def __init__(self, hsv_tuple): + self.m_hsv = HSVColor(*hsv_tuple) - def lch(self): - return "Lch({:.0f},{:.0f},{:.0f})".format(*(self.m_lch.get_value_tuple())) + def hsv(self): + return "Hsv({:.0f},{:.0f},{:.0f})".format(*(self.m_hsv.get_value_tuple())) def rgb(self): - rgb = convert_color(self.m_lch, sRGBColor) - if (rgb.rgb_r != rgb.clamped_rgb_r or rgb.rgb_g != rgb.clamped_rgb_g or rgb.rgb_b != rgb.clamped_rgb_b): - raise Exception("Colour {} is outside sRGB".format(self.lch())) + rgb = convert_color(self.m_hsv, sRGBColor) + #if (rgb.rgb_r != rgb.clamped_rgb_r or rgb.rgb_g != rgb.clamped_rgb_g or rgb.rgb_b != rgb.clamped_rgb_b): + # raise Exception("Colour {} is outside sRGB".format(self.hsv())) return rgb.get_rgb_hex() def rgb_error(self): - return delta_e_cie2000(convert_color(self.m_lch, LabColor), + return delta_e_cie2000(convert_color(self.m_hsv, LabColor), convert_color(sRGBColor.new_from_rgb_hex(self.rgb()), LabColor)) def load_settings(): @@ -85,7 +85,7 @@ def generate_colours(settings, section): colours[line_name] = OrderedDict() for name in road_classes: - colours[line_name][name] = Color((l, c, hues[name])) + colours[line_name][name] = Color((hues[name], c, l)) c += delta_c l += delta_l @@ -112,10 +112,10 @@ def main(): for line_name, line_colours in colours.items(): for name, colour in line_colours.items(): if args.verbose: - line = "@{name}-{line_name}: {rgb}; // {lch}, error {delta:.1f}" + line = "@{name}-{line_name}: {rgb}; // {hsv}, error {delta:.1f}" else: line = "@{name}-{line_name}: {rgb};" - print((line.format(name = name, line_name=line_name, rgb = colour.rgb(), lch = colour.lch(), delta = colour.rgb_error()))) + print((line.format(name = name, line_name=line_name, rgb = colour.rgb(), hsv = colour.hsv(), delta = colour.rgb_error()))) if __name__ == "__main__": main()