forked from vatger/atc-booking
-
Notifications
You must be signed in to change notification settings - Fork 0
/
color_mode.php
47 lines (39 loc) · 1.17 KB
/
color_mode.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
$avail_modes = ["dark", "bright"];
$MODE = array_key_exists("VATGER_BOOKING_MODE", $_COOKIE) ? $_COOKIE["VATGER_BOOKING_MODE"] : false;
foreach ($avail_modes as $mode) {
if (isset($_GET["set_mode_$mode"])) {
if (setcookie("VATGER_BOOKING_MODE", $mode, time()+60*60*24*30*3)) {
$MODE = $mode;
}
}
}
if (empty($MODE) || !in_array($MODE, $avail_modes)) $MODE = "bright";
$colors_bright = [
"background" => [240, 240, 240],
"black" => [0, 0, 0],
"gray" => [190, 190, 190],
"red" => [190, 40, 40],
"blue" => [072, 118, 255],
"orange" => [255, 140, 0],
];
$colors_dark = [
"background" => [23,23,23],
"black" => [230, 230, 230],
"gray" => [100, 100, 100],
"red" => [190, 40, 40],
"blue" => [072, 118, 255],
"orange" => [255, 140, 0],
];
$all_colores = [
"dark" => $colors_dark,
"bright" => $colors_bright
];
define("_COLOR_MODE_", $MODE);
define("_COLOR_MODES_AVAIL_", $avail_modes);
define("_COLORS_ALL_", $all_colores);
function get_color_in_mode($im, string $identifier) : false|int
{
$c = _COLORS_ALL_[_COLOR_MODE_][$identifier];
return imagecolorallocate($im, $c[0], $c[1], $c[2]);
}