From c2f382aba86aaebb9806ff1b43c1af69992e9a10 Mon Sep 17 00:00:00 2001 From: Evgeny Zinoviev Date: Mon, 11 Jul 2022 15:01:02 +0300 Subject: support dark mode for images with alpha channel --- engine/themes.php | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 engine/themes.php (limited to 'engine/themes.php') diff --git a/engine/themes.php b/engine/themes.php new file mode 100644 index 0000000..839377f --- /dev/null +++ b/engine/themes.php @@ -0,0 +1,38 @@ + [ + 'bg' => 0x222222, + // 'alpha' => 0x303132, + 'alpha' => 0x222222, + ], + 'light' => [ + 'bg' => 0xffffff, + // 'alpha' => 0xf2f2f2, + 'alpha' => 0xffffff, + ] + ]; + + public static function getThemes(): array { + return array_keys(self::$Themes); + } + + public static function themeExists(string $name): bool { + return array_key_exists($name, self::$Themes); + } + + public static function getThemeAlphaColorAsRGB(string $name): array { + $color = self::$Themes[$name]['alpha']; + $r = ($color >> 16) & 0xff; + $g = ($color >> 8) & 0xff; + $b = $color & 0xff; + return [$r, $g, $b]; + } + + public static function getUserTheme(): string { + return ($_COOKIE['theme'] ?? 'auto'); + } + +} \ No newline at end of file -- cgit v1.2.3