Files
t2000-steckerpruefer/alt/stecker.php
2026-01-02 20:52:43 +01:00

120 lines
4.0 KiB
PHP

<?php
// Setze den Content-Type-Header für SVG
header('Content-Type: image/svg+xml');
echo '<?xml version="1.0" encoding="UTF-8"?>';
?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="500" height="100">
<defs>
<style>
@font-face {
font-family: LexendDecaBold;
src: url(http://192.168.37.103/vendor/fonts/LexendDeca-Bold.ttf);
}
* {
font-family: LexendDecaBold;
font-size: 14px;
}
</style>
</defs>
<text x="30" y="5" fill="black" text-anchor="middle" transform="translate(50,50) rotate(-90)">30</text>
<text x="-30" y="5" fill="black" text-anchor="middle" transform="translate(50,50) rotate(-90)">10</text>
<text x="30" y="405" fill="black" text-anchor="middle" transform="translate(50,50) rotate(-90)">31</text>
<text x="-30" y="405" fill="black" text-anchor="middle" transform="translate(50,50) rotate(-90)">11</text>
<path d="M500 0 L50 0" style="stroke:black;stroke-width:5; fill:none;" />
<path d="M50 0 L0 25" style="stroke:black;stroke-width:3; fill:none;" />
<path d="M0 25 L0 75" style="stroke:black;stroke-width:5; fill:none;" />
<path d="M0 75 L50 100" style="stroke:black;stroke-width:3; fill:none;" />
<path d="M50 100 L500 100" style="stroke:black;stroke-width:5; fill:none;" />
<path d="M500 100 L500 0" style="stroke:black;stroke-width:5; fill:none;" />
<rect width="35" height="35" x="452" y="32" rx="5" ry="5" style="stroke:black;stroke-width:3;fill:none" />
<circle r="8" cx="470" cy="50" fill="none" style="stroke:black;stroke-width:3;" />
<rect width="35" height="35" x="13" y="32" rx="5" ry="5" style="stroke:black;stroke-width:3;fill:none" />
<circle r="8" cx="30" cy="50" fill="none" style="stroke:black;stroke-width:3;" />
<rect width="380" height="80" x="60" y="10" rx="5" ry="5" style="stroke:black;stroke-width:3;fill:none" />
<?php
$pin_coordinates = [
10 => [70, 68],
20 => [70, 44],
30 => [70, 20],
11 => [405, 68],
12 => [370, 68],
13 => [335, 68],
14 => [300, 68],
15 => [265, 68],
16 => [230, 68],
17 => [195, 68],
18 => [160, 68],
19 => [125, 68],
21 => [405, 44],
22 => [370, 44],
23 => [335, 44],
24 => [300, 44],
25 => [265, 44],
26 => [220, 44],
27 => [185, 44],
28 => [150, 44],
29 => [115, 44],
31 => [405, 20],
32 => [370, 20],
33 => [335, 20],
34 => [300, 20],
35 => [265, 20],
36 => [230, 20],
37 => [195, 20],
38 => [160, 20],
39 => [125, 20],
];
foreach ($pin_coordinates as $coordinates) {
echo '<rect width="25" height="10" x="' . $coordinates[0] . '" y="' . $coordinates[1] . '" rx="1" ry="1" style="stroke:black;stroke-width:3;fill:none" />';
}
if (empty($_GET['data'])) {
print "</svg>";
die();
}
$inputArray = json_decode($_GET['data'], true); // JSON in ein PHP-Array umwandeln
// Neues Array mit übersetzten Koordinaten
$translatedArray = array_map(function ($pair) use ($pin_coordinates) {
return [
$pin_coordinates[$pair[0]], // Übersetze den ersten Wert
$pin_coordinates[$pair[1]], // Übersetze den zweiten Wert
];
}, $inputArray);
$colors = ["#1a5fb4", "#26a269", "#e5a50a", "#c64600", "#a51d2d", "#613583", "#63452c", "#3d3846"];
// Schleife durch das übersetzte Array
$colorNumber = 0;
foreach ($translatedArray as $line) {
$point1 = $line[0]; // Erster Punkt [x, y]
$point2 = $line[1]; // Zweiter Punkt [x, y]
$point1x = $point1[0] + 10;
$point1y = $point1[1] + 5;
$point2x = $point2[0] + 10;
$point2y = $point2[1] + 5;
// Ausgabe eines Pfades (Linie zwischen zwei Punkten)
echo '<path d="M' . $point1x . " " . $point1y . " L" . $point2x . " " . $point2y . '" style="stroke:' . $colors[$colorNumber] . ';stroke-width:3; fill:none;" />';
$colorNumber++;
if ($colorNumber > 7) {
$colorNumber = 0;
}
}
?>
</svg>