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
48
49
50
51
52
53
54
55
56
|
<?php
require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/functions.inc";
require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/score.inc";
function rainbow(): array {
$members = scoreOrderGlobal();
$data = [];
foreach ($members as $member) {
$data[$member["name"]] = [
"_data" => $member
];
if (isset($member["color"])) {
$data[$member["name"]]["rgb"] = [
hexdec(substr($member["color"], 0, 2)),
hexdec(substr($member["color"], 2, 2)),
hexdec(substr($member["color"], 4, 2))
];
$data[$member["name"]]["hsl"] = rgbToHsl(
$data[$member["name"]]["rgb"][0],
$data[$member["name"]]["rgb"][1],
$data[$member["name"]]["rgb"][2]
);
} else {
$data[$member["name"]]["rgb"] = [255, 255, 255];
$data[$member["name"]]["hsl"] = rgbToHsl(255, 255, 255);
}
}
return $data;
}
function getMembersByColor($_ = false, $ignoreHumans = false): array {
$members = rainbow();
uasort($members, function ($a, $b) {
return $a['hsl'][0] - $b['hsl'][0];
});
$sorted = [];
foreach ($members as $data) {
$data["_data"]["hue"] = $data["hsl"][0];
$sorted[] = $data["_data"];
}
if ($ignoreHumans) {
return array_filter($sorted, function ($i) {
return !in_array("human", $i["_metadata"]["species"]);
});
} else {
return $sorted;
}
}
|