32 lines
802 B
PHP
32 lines
802 B
PHP
<?php
|
|
/**
|
|
* Backgrounds are just PNGs in img/bg/, generated by tools/background.py.
|
|
* Drop a new one in and it joins the cycle automatically -- this list drives
|
|
* both the CSS custom properties and the footer cycler.
|
|
*/
|
|
|
|
function bg_styles(): array
|
|
{
|
|
static $names = null;
|
|
if ($names !== null) {
|
|
return $names;
|
|
}
|
|
$files = glob(__DIR__ . '/../img/bg/*.png') ?: [];
|
|
$names = array_map(static fn($f) => pathinfo($f, PATHINFO_FILENAME), $files);
|
|
sort($names);
|
|
return $names;
|
|
}
|
|
|
|
function bg_default(): string
|
|
{
|
|
$all = bg_styles();
|
|
return in_array('flow', $all, true) ? 'flow' : ($all[0] ?? '');
|
|
}
|
|
|
|
/** A different style on every page load. */
|
|
function bg_pick(): string
|
|
{
|
|
$all = bg_styles();
|
|
return $all ? $all[random_int(0, count($all) - 1)] : '';
|
|
}
|