From 69d8836a2247689849ceee80e4fcda2a039883ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johan=20Fiti=C3=A9?= Date: Thu, 18 Jun 2020 10:10:07 +0000 Subject: Script --- navit/navit_layout_car_convertrgbfordark.sh | 7 - navit/navit_layout_car_dark_shipped.xml | 413 +++++++++++++++------------- navit/navit_layout_car_generatedarkxml.sh | 90 ++++++ 3 files changed, 313 insertions(+), 197 deletions(-) delete mode 100755 navit/navit_layout_car_convertrgbfordark.sh create mode 100755 navit/navit_layout_car_generatedarkxml.sh diff --git a/navit/navit_layout_car_convertrgbfordark.sh b/navit/navit_layout_car_convertrgbfordark.sh deleted file mode 100755 index 3d4e5daf6..000000000 --- a/navit/navit_layout_car_convertrgbfordark.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash -if [[ $1 =~ ^[0-9a-fA-F]{6}$ ]]; then - echo Light: $1 - echo Dark:\ $(printf '%02x' $(echo $(printf "%d" 0x${1:0:2})/34 | bc))$(printf '%02x' $(echo $(printf "%d" 0x${1:2:2})/8 | bc))$(printf '%02x' $(echo $(printf "%d" 0x${1:4:2})/9 | bc)) -else - echo Usage: $0 RRGGBB -fi diff --git a/navit/navit_layout_car_dark_shipped.xml b/navit/navit_layout_car_dark_shipped.xml index f1eeca27d..445203b20 100644 --- a/navit/navit_layout_car_dark_shipped.xml +++ b/navit/navit_layout_car_dark_shipped.xml @@ -67,435 +67,468 @@ - - - - - - - + - + + - - + + - - - - - + - - - - + - - - - - - - - - - - - - + - + - + - + - + - + - + - + - + - + - + - - + + - + - - + + - + - + - + - + - - - + + + - - + + - + - + - + - + - - - - - + - + - + - - + + - + - + - + - + - - + + - + - - + + - + - - - + + + - - + + - - - + + + - - + + - - + + + + + - - + + + - - - - + + + + - - - + + + - - - + + + - - + + - + + + - - + + + - - + + + - - + + + - - + + + - - + + + - - + + + - - + + + - - - - - + + + - - + + - - + + - + + - + + - + + - - + + - - + + - - + + - - + + - - + + - - + + - + + + + + + - - + + + - + + - - + + - + - + - - + + - - + + - - + + - + - - + + - - + + - - + + - + - - + + - - + + - + - + - + - + - + - - + + - + - - - + + + - - - + + + - - - + + + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/navit/navit_layout_car_generatedarkxml.sh b/navit/navit_layout_car_generatedarkxml.sh new file mode 100755 index 000000000..f3dda2f33 --- /dev/null +++ b/navit/navit_layout_car_generatedarkxml.sh @@ -0,0 +1,90 @@ +#!/bin/bash + +# This script automatically converts the rgb colors used for the polygons in the +# navit_layout_car_shipped.xml to the values appropriate for the dark layout in +# navit_layout_car_dark_shipped.xml. +# It's a bit of a mess, but gets the job done. + +IFS='' # Keep whitespace + +# Light and dark input files +ifl=navit_layout_car_shipped.xml +ifd=navit_layout_car_dark_shipped.xml + +# Temporary dark output file +ofd=$ifd.new + +# Create new temporary dark output file +[ -f $ofd ] && rm -f $ofd +touch $ofd + +# Init: not in polygons layer +inpolygons=false +getpolygons=false + +# Read dark input file +while read l +do + + # Check to see if inside polygons layer - open tag + if [[ $l =~ .*\.* ]]; then + inpolygons=true + getpolygons=true + fi + + # Check to see if inside polygons layer - close tag + if [[ $l =~ .*\.* ]]; then + inpolygons=false + fi + + # Trigger once when polygons open tag found in dark input file + if [ $getpolygons == true ]; then + + getpolygons=false # Just triggered + inpolygons=false # Now used for light input file + + # Insert data from light input file + while read l + do + + # Check to see if inside polygons layer + if [[ $l =~ .*\.* ]]; then + inpolygons=true + fi + + if [[ $l =~ .*\.* ]]; then + inpolygons=false + fi + + # Inside polygons layer + if [ $inpolygons == true ]; then + + if [[ $l =~ .*color=\"#[0-9a-fA-F]{6}.* ]]; then # Line contains rgb(a) color + coll=$(echo $l | cut -d# -f2 | cut -c-6) # Get rgb color and convert + cold=$(printf '%02x' $(echo $(printf "%d" 0x${coll:0:2})/16+16 | bc)) # rr + cold=$cold$(printf '%02x' $(echo $(printf "%d" 0x${coll:2:2})/10+14 | bc)) # gg + cold=$cold$(printf '%02x' $(echo $(printf "%d" 0x${coll:4:2})/8+12 | bc)) # bb + l=$(echo $l | sed "s/#$coll/#$cold/") # Replace color + l="$l" # Add comment + fi + + echo $l >> $ofd # (Modified) line from light input file to dark output file + + fi + + done < $ifl # Read light input file + inpolygons=true # Done inserting, still in polygons layer in dark input file + + else + + # Outside polygons layer + if [ $inpolygons == false ]; then + echo $l >> $ofd # Just copy as-is to dark output file + fi + + fi + +done < $ifd # Read dark input file + +cp $ofd $ifd # Replace +rm -f $ofd # Clean up -- cgit v1.2.1