' .
'<' .
'use xlink:href="#tear" x="7" transform="scale(0.8)"/>';
$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;
$b = ($_GET['b'] ?? 0)/100;
$t = ($_GET['t'] ?? 0)/100;
$speak = $_GET['speak_rate'] ?? 0;
$blink = $_GET['blink_rate'] ?? 0;
$invert = ($_GET['invert'] ?? 0)/100;
$color = $_GET['color'] ?? null;
$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;
}
function render($template, $data, $V) {
$index = 0;
return preg_replace_callback('/\?/', function() use (&$index, $V, $data) {
return dotprod($V, $data[$index++]);
}, $template);
}
function color_palette($inv, $hue) {
$l = fn($x) => sprintf('%.3f', 1 - $x);
$c = fn($x) => sprintf('%.3f', 1.6*$x*(1-$x) - 3*$x*($x-0.5)*($x-1));
return 'light-dark(oklch('.$l($inv).' '.$c($inv).' '.$hue.'),oklch('.$l(1-$inv).' '.$c(1-$inv).' '.$hue.'))';
}
function invertable_darkmode($inv, $svg, $color = null) {
if (is_null($color)) {
$stroke = color_palette(1 - $inv, 14);
$svg = preg_replace('/(