diff --git a/line-colors.csv b/line-colors.csv index 6538cd3..9037667 100644 --- a/line-colors.csv +++ b/line-colors.csv @@ -1316,18 +1316,18 @@ vbb-vip-bus,609,,5-vbbvib-609,#907d32,#ffffff,,pill vbb-vip-bus,612,,5-vbbvib-612,#842a26,#ffffff,,pill vbb-vip-bus,616,,5-vbbvib-616,#0155ae,#ffffff,,pill vbb-vip-bus,638,,5-vbbvib-638,#665fb1,#ffffff,,pill -vbb-vip-bus,639,,5-vbbvib-639,#ffffff,#9e9ace,#9e9ace,pill +vbb-vip-bus,639,,5-vbbvib-639,#f0eef6,#9e9ace,#9e9ace,pill vbb-vip-bus,690,,5-vbbvib-690,#446080,#ffffff,,pill -vbb-vip-bus,691,,5-vbbvib-691,#ffffff,#ff9027,#ff9027,pill +vbb-vip-bus,691,,5-vbbvib-691,#feeedd,#ff9027,#ff9027,pill vbb-vip-bus,692,,5-vbbvib-692,#00b9f2,#ffffff,,pill vbb-vip-bus,693,,5-vbbvib-693,#e36eb5,#ffffff,,pill vbb-vip-bus,694,,5-vbbvib-694,#70a4b8,#ffffff,,pill -vbb-vip-bus,695,,5-vbbvib-695,#bf2a4f,#bf2a4f,,pill +vbb-vip-bus,695,,5-vbbvib-695,#bf2a4f,#ffffff,,pill vbb-vip-bus,696,,5-vbbvib-696,#eb2d4c,#ffffff,,pill vbb-vip-bus,697,,5-vbbvib-697,#772382,#ffffff,,pill vbb-vip-bus,698,,5-vbbvib-698,#117b40,#ffffff,,pill vbb-vip-bus,699,,5-vbbvib-699,#d9992f,#ffffff,,pill -vbb-vip-bus,X5,,5-vbbvib-x5,#ffffff,#b167b3,#b167b3,pill +vbb-vip-bus,X5,,5-vbbvib-x5,#f2e6f1,#b167b3,#b167b3,pill vbb-vip-bus,X15,,5-vbbvib-x15,#ffffff,#49c07d,#49c07d,pill vbb-vip-bus,N14,,5-vbbvib-n14,#ffa32b,#ffffff,,pill vbb-vip-bus,N15,,5-vbbvib-n15,#ff7322,#ffffff,,pill @@ -1338,7 +1338,7 @@ vbb-vip-tram,92,,8-vbbvit-92,#024890,#ffffff,,rectangle vbb-vip-tram,93,,8-vbbvit-93,#ff7322,#ffffff,,rectangle vbb-vip-tram,94,,8-vbbvit-94,#89969e,#ffffff,,rectangle vbb-vip-tram,96,,8-vbbvit-96,#00b098,#ffffff,,rectangle -vbb-vip-tram,98,,8-vbbvit-98,#ffffff,#009edd,#009edd,rectangle +vbb-vip-tram,98,,8-vbbvit-98,#daedf9,#009edd,#009edd,rectangle vbb-vip-tram,99,,8-vbbvit-99,#5fbf49,#ffffff,,rectangle vbg,RB 1,vogtlandbahn-die-landerbahn-gmbh-dlb,3-rd-rb1,#e30613,#ffffff,,rectangle-rounded-corner vbg,RB 2,vogtlandbahn-die-landerbahn-gmbh-dlb,3-rd-rb2,#0067b0,#ffffff,,rectangle-rounded-corner diff --git a/validation/check.php b/validation/check.php index e5c41f3..0dddaa9 100644 --- a/validation/check.php +++ b/validation/check.php @@ -47,6 +47,14 @@ $i++; } + +echo "Checking that the background color isn't the text color" . PHP_EOL; +$i = 2; +foreach ($csv as $line) { + text_color_differs_background($line, $i); + $i++; +} + $sources = json_decode(file_get_contents("../sources.json"), true); $opSources = array_map(fn($op) => $op["shortOperatorName"], $sources); echo "Checking that operators are present in sources.json" . PHP_EOL; diff --git a/validation/common.php b/validation/common.php index 8b1cc17..6f7d614 100644 --- a/validation/common.php +++ b/validation/common.php @@ -21,8 +21,16 @@ function valid_shape($line, $i) { function valid_hex_color($line, $i, $key) { $color = $line[$key]; - + if (!(strlen($color) == 7 && ctype_xdigit(substr($color, 1)) && $color[0] === "#")) { throw new Error("bad $key \"$color\" does not follow #<6 digit hex color> in row $i"); } -} \ No newline at end of file +} + +function text_color_differs_background($line, $i) { + $textColor = $line["textColor"]; + $backgroundColor = $line["backgroundColor"]; + if ($textColor === $backgroundColor) { + throw new Error("bad color combination: text color \"$textColor\" may not be background color \"$backgroundColor\" in row $i"); + } +} diff --git a/validation/test.php b/validation/test.php index 38da0d3..072215a 100644 --- a/validation/test.php +++ b/validation/test.php @@ -86,6 +86,17 @@ function test_throws(string $name, callable $test_case) { valid_hex_color(["test_key" => "abcdefg"], 5, "test_key"); }); +/** + * text_color_differs_background + */ +test_ok("text_color_differs_background for different colors", function() { + text_color_differs_background(["textColor" => "#ffffff", "backgroundColor" => "#000000"], 1); +}); +test_throws("text_color_differs_background with the same data", function() { + $black = "#000000"; + text_color_differs_background(["textColor" => $black, "backgroundColor" => $black], 2); +}); + /** * End of file */