From 108525534c28013cfe1897c30e4565f9893f3766 Mon Sep 17 00:00:00 2001 From: Minteck Date: Mon, 10 Oct 2022 20:51:39 +0200 Subject: Update --- includes/rainbow.inc | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 includes/rainbow.inc (limited to 'includes/rainbow.inc') diff --git a/includes/rainbow.inc b/includes/rainbow.inc new file mode 100644 index 0000000..470f288 --- /dev/null +++ b/includes/rainbow.inc @@ -0,0 +1,57 @@ + $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(): array { + $members = rainbow(); + uasort($members, function ($a, $b) { + return $a['hsl'][0] - $b['hsl'][0]; + }); + $members = [ + ...array_filter($members, function ($i) { + return $i['hsl'][2] < 0.9 || $i['hsl'][1] > 0.2; + }), + ...array_filter($members, function ($i) { + return $i['hsl'][2] >= 0.9 || $i['hsl'][1] <= 0.2; + }) + ]; + + $sorted = []; + foreach ($members as $data) { + $data["_data"]["hue"] = $data["hsl"][0]; + $sorted[] = $data["_data"]; + } + + return $sorted; +} \ No newline at end of file -- cgit