From 037a69c0eff02690701a94658b26621a418e7a54 Mon Sep 17 00:00:00 2001 From: Patrick Niebeling Date: Mon, 16 Nov 2026 14:05:04 +0100 Subject: [PATCH] Drop the favicon generator script The logo is fixed, the generated files are all that is needed. Co-Authored-By: Claude Sonnet 5.5 --- docs/frontend.md | 6 +- resources/favicon/generate.php | 144 --------------------------------- 2 files changed, 3 insertions(+), 147 deletions(-) delete mode 100644 resources/favicon/generate.php diff --git a/docs/frontend.md b/docs/frontend.md index e8eea6b..cd418f3 100644 --- a/docs/frontend.md +++ b/docs/frontend.md @@ -43,6 +43,6 @@ Neue Farben als Token in beiden Dark-Blöcken von `plenario.css` pflegen; auf de Das Logo (`.brand__mark` in `plenario.css`) ist auch das Favicon: `webroot/favicon.svg` (moderne Browser), `favicon.ico` (16/32/48 px, Fallback) und `apple-touch-icon.png` (180 px, iOS, deckend ohne Rundung, die macht iOS selbst). Eingebunden über -`templates/element/favicon.php` in allen drei Layouts (default, present, error). Die Dateien sind statisch und werden aus -einer Geometrie erzeugt: Ändert sich das Logo, `php resources/favicon/generate.php webroot` ausführen (braucht `ext-gd`) -und Farben/Anteile im Skript an `.brand__mark` angleichen. Test: `FaviconTest.php`. +`templates/element/favicon.php` in allen drei Layouts (default, present, error). Die Dateien sind statisch, es gibt keinen +Generator im Repo: Das Logo ändert sich nicht. Falls doch, alle drei Dateien von Hand passend zu `.brand__mark` neu erstellen +(Kreisdiagramm 40/25/20/15 % ab 12 Uhr im Uhrzeigersinn, Ecken 6/22). Test: `FaviconTest.php`. diff --git a/resources/favicon/generate.php b/resources/favicon/generate.php deleted file mode 100644 index a45beb6..0000000 --- a/resources/favicon/generate.php +++ /dev/null @@ -1,144 +0,0 @@ - $stop) { - [$x1, $y1] = $point($prev); - [$x2, $y2] = $point($stop); - $large = ($stop - $prev) > 0.5 ? 1 : 0; - $paths .= sprintf( - " \n", - $colors[$i], - $c, - $c, - $x1, - $y1, - $R, - $R, - $large, - $x2, - $y2, - ); - $prev = $stop; -} -$rx = round($size * $radiusRatio, 2); -$svg = << - PlenarIO - - -{$paths} - - -SVG; -file_put_contents($out . '/favicon.svg', $svg); - -// ---- PNG / ICO (GD, 4x4 supersampling) --------------------------------------------------- -$rgb = fn(string $hex): array => [hexdec(substr($hex, 1, 2)), hexdec(substr($hex, 3, 2)), hexdec(substr($hex, 5, 2))]; -$palette = array_map($rgb, $colors); - -$render = function (int $n, float $padding = 0.0) use ($stops, $palette, $radiusRatio): string { - $img = imagecreatetruecolor($n, $n); - imagealphablending($img, false); - imagesavealpha($img, true); - $ss = 4; - $inner = $n * (1 - 2 * $padding); - $r = $inner * $radiusRatio; - $offset = $n * $padding; - for ($y = 0; $y < $n; $y++) { - for ($x = 0; $x < $n; $x++) { - $sum = [0.0, 0.0, 0.0]; - $cover = 0; - for ($sy = 0; $sy < $ss; $sy++) { - for ($sx = 0; $sx < $ss; $sx++) { - $px = $x + ($sx + 0.5) / $ss - $offset; - $py = $y + ($sy + 0.5) / $ss - $offset; - if ($px < 0 || $py < 0 || $px > $inner || $py > $inner) { - continue; - } - // rounded corners - $cx = min(max($px, $r), $inner - $r); - $cy = min(max($py, $r), $inner - $r); - if (($px - $cx) ** 2 + ($py - $cy) ** 2 > $r ** 2) { - continue; - } - $angle = atan2($px - $inner / 2, -($py - $inner / 2)); // 0 = top, clockwise - $f = fmod($angle / (2 * M_PI) + 1, 1); - $k = 0; - while ($k < 3 && $f >= $stops[$k]) { - $k++; - } - foreach ($palette[$k] as $j => $v) { - $sum[$j] += $v; - } - $cover++; - } - } - $total = $ss * $ss; - if ($cover === 0) { - $col = imagecolorallocatealpha($img, 0, 0, 0, 127); - } else { - $col = imagecolorallocatealpha( - $img, - (int)round($sum[0] / $cover), - (int)round($sum[1] / $cover), - (int)round($sum[2] / $cover), - (int)round(127 * (1 - $cover / $total)), - ); - } - imagesetpixel($img, $x, $y, $col); - } - } - ob_start(); - imagepng($img, null, 9); - $png = (string)ob_get_clean(); - - return $png; -}; - -// favicon.ico with 16, 32 and 48 px (PNG compressed entries) -$sizes = [16, 32, 48]; -$images = array_map(fn(int $n): string => $render($n), $sizes); -$ico = pack('vvv', 0, 1, count($sizes)); -$offset = 6 + 16 * count($sizes); -foreach ($sizes as $i => $n) { - $ico .= pack('CCCCvvVV', $n, $n, 0, 0, 1, 32, strlen($images[$i]), $offset); - $offset += strlen($images[$i]); -} -file_put_contents($out . '/favicon.ico', $ico . implode('', $images)); - -// iOS ignores transparency (fills black) and rounds the corners itself: opaque full-bleed square. -$apple = imagecreatetruecolor(180, 180); -$stopsPx = $stops; -for ($y = 0; $y < 180; $y++) { - for ($x = 0; $x < 180; $x++) { - $angle = atan2($x + 0.5 - 90, -($y + 0.5 - 90)); - $f = fmod($angle / (2 * M_PI) + 1, 1); - $k = 0; - while ($k < 3 && $f >= $stopsPx[$k]) { - $k++; - } - imagesetpixel($apple, $x, $y, imagecolorallocate($apple, ...$palette[$k])); - } -} -imagepng($apple, $out . '/apple-touch-icon.png', 9); -echo "ok\n";