diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/python/transit/transit_color_palette.py | 5 | ||||
-rwxr-xr-x | tools/python/transit/transit_colors_export.py | 34 | ||||
-rwxr-xr-x | tools/unix/generate_drules.sh | 4 |
3 files changed, 41 insertions, 2 deletions
diff --git a/tools/python/transit/transit_color_palette.py b/tools/python/transit/transit_color_palette.py index df44ce69bf..29c4ba6657 100644 --- a/tools/python/transit/transit_color_palette.py +++ b/tools/python/transit/transit_color_palette.py @@ -112,8 +112,9 @@ class Palette: bluish = is_bluish(color) for name, palette_color in self.colors.iteritems(): - if name in excluded_names: - continue + # Uncomment if you want to exclude duplicates. + #if name in excluded_names: + # continue if bluish: diff = lum_distance(palette_color, color) else: diff --git a/tools/python/transit/transit_colors_export.py b/tools/python/transit/transit_colors_export.py new file mode 100755 index 0000000000..333cf28bd0 --- /dev/null +++ b/tools/python/transit/transit_colors_export.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python2.7 +# It exports all transits colors to colors.txt file. +import argparse +import json +import os.path + +if __name__ == '__main__': + parser = argparse.ArgumentParser() + default_colors_path = os.path.dirname(os.path.abspath(__file__)) + '/../../../data/colors.txt' + parser.add_argument('in_out_file', nargs='?', type=str, default=default_colors_path, + help='path to colors.txt file') + default_transits_colors_path = os.path.dirname(os.path.abspath(__file__)) + '/../../../data/transit_colors.txt' + parser.add_argument('-c', '--colors', nargs='?', type=str, default=default_transits_colors_path, + help='path to transit_colors.txt file') + + args = parser.parse_args() + + colors = set() + with open(args.in_out_file, 'r') as in_file: + lines = in_file.readlines() + for l in lines: + colors.add(int(l)) + + fields = ['clear', 'night', 'text', 'text_night'] + with open(args.colors, 'r') as colors_file: + tr_colors = json.load(colors_file) + for name, color_info in tr_colors['colors'].iteritems(): + for field in fields: + if field in color_info: + colors.add(int(color_info[field], 16)) + + with open(args.in_out_file, 'w') as out_file: + for c in sorted(colors): + out_file.write(str(c) + os.linesep) diff --git a/tools/unix/generate_drules.sh b/tools/unix/generate_drules.sh index 766b524bdb..1ffd7ae13c 100755 --- a/tools/unix/generate_drules.sh +++ b/tools/unix/generate_drules.sh @@ -36,6 +36,10 @@ BuildDrawingRules vehicle night _vehicle_dark # In designer mode we use drules_proto_design file instead of standard ones cp $OMIM_PATH/data/drules_proto_clear.bin $OMIM_PATH/data/drules_proto_design.bin +echo "Exporting transit colors" +python "$OMIM_PATH/tools/python/transit/transit_colors_export.py" \ + "$DATA_PATH/colors.txt" > /dev/null + echo "Merging default and vehicle styles" python "$OMIM_PATH/tools/python/stylesheet/drules_merge.py" \ "$DATA_PATH/drules_proto_clear.bin" "$DATA_PATH/drules_proto_vehicle_clear.bin" \ |