$g) {
$h += 360;
}
break;
case $g:
$h = 60 * (($b - $r) / $d + 2);
break;
case $b:
$h = 60 * (($r - $g) / $d + 4);
break;
}
}
return array(round($h, 2), round($s, 2), round($l, 2));
}
}
if (!function_exists("imageCreateCorners")) {
function imageCreateCorners($sourceImageFile, $radius) {
# test source image
if (file_exists($sourceImageFile)) {
$res = is_array($info = getimagesize($sourceImageFile));
}
else $res = false;
# open image
if ($res) {
$w = $info[0];
$h = $info[1];
switch ($info['mime']) {
case 'image/jpeg': $src = imagecreatefromjpeg($sourceImageFile);
break;
case 'image/gif': $src = imagecreatefromgif($sourceImageFile);
break;
case 'image/png': $src = imagecreatefrompng($sourceImageFile);
break;
default:
$res = false;
}
}
# create corners
if ($res) {
$q = 10; # change this if you want
$radius *= $q;
# find unique color
do {
$r = rand(0, 255);
$g = rand(0, 255);
$b = rand(0, 255);
}
while (imagecolorexact($src, $r, $g, $b) < 0);
$nw = $w*$q;
$nh = $h*$q;
$img = imagecreatetruecolor($nw, $nh);
$alphacolor = imagecolorallocatealpha($img, $r, $g, $b, 127);
imagealphablending($img, false);
imagesavealpha($img, true);
imagefilledrectangle($img, 0, 0, $nw, $nh, $alphacolor);
imagefill($img, 0, 0, $alphacolor);
imagecopyresampled($img, $src, 0, 0, 0, 0, $nw, $nh, $w, $h);
imagearc($img, $radius-1, $radius-1, $radius*2, $radius*2, 180, 270, $alphacolor);
imagefilltoborder($img, 0, 0, $alphacolor, $alphacolor);
imagearc($img, $nw-$radius, $radius-1, $radius*2, $radius*2, 270, 0, $alphacolor);
imagefilltoborder($img, $nw-1, 0, $alphacolor, $alphacolor);
imagearc($img, $radius-1, $nh-$radius, $radius*2, $radius*2, 90, 180, $alphacolor);
imagefilltoborder($img, 0, $nh-1, $alphacolor, $alphacolor);
imagearc($img, $nw-$radius, $nh-$radius, $radius*2, $radius*2, 0, 90, $alphacolor);
imagefilltoborder($img, $nw-1, $nh-1, $alphacolor, $alphacolor);
imagealphablending($img, true);
imagecolortransparent($img, $alphacolor);
# resize image down
$dest = imagecreatetruecolor($w, $h);
imagealphablending($dest, false);
imagesavealpha($dest, true);
imagefilledrectangle($dest, 0, 0, $w, $h, $alphacolor);
imagecopyresampled($dest, $img, 0, 0, 0, 0, $w, $h, $nw, $nh);
# output image
$res = $dest;
imagedestroy($src);
imagedestroy($img);
}
return $res;
}
}
if (!function_exists("getMiniName")) {
function getMiniName(string $name) {
$parts = explode(" ", $name);
if (strlen($parts[0]) > 3 && !str_ends_with($parts[0], "e") && $parts[0] !== "Filly" && $parts[0] !== "Windy" && (isset($parts[1]) && $parts[1] !== "Brightdawn")) {
if ($parts[0] === "Princess") {
array_shift($parts);
}
if (str_contains($parts[0], "/")) {
return explode("/", $parts[0])[0];
} else {
return $parts[0];
}
} else {
return $name;
}
}
}
if (!function_exists("withCaretakersDown")) {
function withCaretakersDown(array $ordered): array {
$caretakersNo = [];
$caretakersYes = [];
foreach ($ordered as $item) {
if ($item["_metadata"]["little"] === 2) {
$caretakersYes[] = $item;
} else {
$caretakersNo[] = $item;
}
}
return [...$caretakersNo, ...$caretakersYes];
}
}
if (!function_exists("getSystemMember")) {
function getSystemMember(string $system, string $id) {
$systemID = $system;
$members = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID/members.json"), true);
$member = null;
foreach ($members as $m) {
if ($m["id"] === $id) $member = $m;
}
$member["system"] = $member["_system"] = $system;
return $member;
}
}
if (!function_exists("getMemberWithoutSystem")) {
function getMemberWithoutSystem(string $id) {
$member = null;
$members1 = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc/members.json"), true);
foreach ($members1 as $m) {
$m["_system"] = "ynmuc";
$m["system"] = "ynmuc";
if ($m["id"] === $id) $member = $m;
}
$members2 = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd/members.json"), true);
foreach ($members2 as $m) {
$m["_system"] = "gdapd";
$m["system"] = "gdapd";
if ($m["id"] === $id) $member = $m;
}
return $member;
}
}
if (!function_exists("showMembersFromList")) {
function showMembersFromList(array $list) {
foreach ($list as $member) { if ($member['name'] !== "unknown" && $member['name'] !== "fusion") {
echo('
' . (isset($member['travelling']) && $member['travelling'] ? "+" . ($member['proxy_tags'][0]['prefix'] ?? " ") : ($member['proxy_tags'][0]['prefix'] ?? " ")) . '