';
$v = ($_GET['v'] ?? 50)/100;
$a = $_GET['a'];
$a1 = ($_GET['a1'] ?? $a ?? 50)/100;
$a2 = ($_GET['a2'] ?? $a ?? 50)/100;
$d = ($_GET['d'] ?? 50)/100;
$c = ($_GET['c'] ?? 0)/100;
$g = ($_GET['g'] ?? 0)/100;
$o = $_GET['o'];
if (!is_null($o)) {
$a = ($a1+$a2)/2;
$a1 = $a + $o/100 - 0.5;
$a2 = $a - $o/100 + 0.5;
}
$size = $_GET['size'];
if ($size) {
$template = preg_replace('/100%/', $size, $template, 2);
}
function dotprod($X, $Y) {
$value = 0;
for ($j = 0; $j < count($Y); $j++) {
$value += $Y[$j] * $X[$j];
}
return $value;
}
$V= [1, 2*$v-1, $a1, $a2, 2*$d-1, $g, $c];
$index = 0;
$svg = preg_replace_callback('/\?/', function() use (&$index, $V, $data) {
return dotprod($V, $data[$index++]);
}, $template);
// experimental inclusion of love
$l = ($_GET['l'] ?? 0)/100;
if ($l > 0) {
$data= array(
array(0, 1),
array(0.5, -0.2),
array(0, 1));
$V= [1, $l];
$index=0;
$template= '';
$love = preg_replace_callback('/\?/', function() use (&$index, $V, $data) {
return dotprod($V, $data[$index++]);
}, $template);
$svg = preg_replace('/(?=)/', '' , $svg, 1);
}
if ($_GET['dark']) {
$svg = preg_replace('/(<(?!rect id="tooth")[^>]*) stroke="black"/', '$1 stroke="white"', $svg);
}
echo $svg;
?>