Einfache Formen lassen sich recht gut darstellen.
Lösung für einen Quader: (die Variablen werden zum Test per GET gefüllt)
PHP-Code:
$width = $_GET['width'];
$height = $_GET['height'];
$depth = ($_GET['depth']);
$filename = 'zeichnung.svg';
$data='<?xml version="1.0" standalone="no" ?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg width="400" height="400" xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Hinten -->
<rect x="'.$depth.'" y="0" width="'.$width.'" height="'.$height.'" style="fill:red;" />
<!-- Vorne -->
<rect x="0" y="'.$depth.'" width="'.$width.'" height="'.$height.'" style="fill:red;" />
<!-- Oben Links -->
<line x1="0" y1="'.$depth.'" x2="'.$depth.'" y2="0" style="stroke:black; stroke-width:5px;" />
<polygon fill="red" points="'.$depth.' 0, 0 '.$depth.', '.$depth.' '.$depth.'"/>
<!-- Oben Rechts -->
<line x1="'.$width.'" y1="'.$depth.'" x2="'.($depth+$width).'" y2="0" style="stroke:black; stroke-width:5px;" />
<!-- Unten Rechts -->
<line x1="'.$width.'" y1="'.($depth+$height).'" x2="'.($depth+$width).'" y2="'.$height.'" style="stroke:black; stroke-width:5px;" />
<polygon fill="red" points="'.$width.' '.($depth+$height).', '.($depth+$width).' '.$height.', '.$width.' '.$height.'"/>
<!-- Border -->
<!-- Hintergrund -->
<line x1="'.$depth.'" y1="0" x2="'.$depth.'" y2="'.$height.'" style="stroke:grey; stroke-width:5px;" stroke-dasharray="8,6" stroke-opacity="0.5"/>
<line x1="0" y1="'.($depth+$height).'" x2="'.$depth.'" y2="'.$height.'" style="stroke:grey; stroke-width:5px;" stroke-dasharray="8,6" stroke-opacity="0.5"/>
<line x1="'.$depth.'" y1="'.$height.'" x2="'.($width+$depth).'" y2="'.$height.'" style="stroke:grey; stroke-width:5px;" stroke-dasharray="8,6" stroke-opacity="0.5"/>
<!-- Vordergrund -->
<line x1="'.$depth.'" y1="0" x2="'.($depth+$width).'" y2="0" style="stroke:black; stroke-width:5px;" />
<line x1="0" y1="'.$depth.'" x2="0" y2="'.($depth+$height).'" style="stroke:black; stroke-width:5px;" />
<line x1="0" y1="'.$depth.'" x2="'.$width.'" y2="'.$depth.'" style="stroke:black; stroke-width:5px;" />
<line x1="0" y1="'.($depth+$height).'" x2="'.$width.'" y2="'.($depth+$height).'" style="stroke:black; stroke-width:5px;" />
<line x1="'.$width.'" y1="'.$depth.'" x2="'.$width.'" y2="'.($depth+$height).'" style="stroke:black; stroke-width:5px;" />
<line x1="'.($width+$depth).'" y1="0" x2="'.($width+$depth).'" y2="'.$height.'" style="stroke:black; stroke-width:5px;" />
</svg>
';
file_put_contents($filename,$data);
?>
<html>
<head>
</head>
<body>
<img src="pfad/zur/Datei/zeichnung.svg" />
</body>
</html>
Also Danke nochmal.
Einen Kommentar schreiben: