summaryrefslogtreecommitdiff
path: root/includes/logo.inc
diff options
context:
space:
mode:
authorMinteck <contact@minteck.org>2022-10-10 20:51:39 +0200
committerMinteck <contact@minteck.org>2022-10-10 20:51:39 +0200
commit108525534c28013cfe1897c30e4565f9893f3766 (patch)
treedd3e5132971f96ab5f05e7f3f8f6dbbf379a19bd /includes/logo.inc
parent2162eaa06f7e4764eb3dcfe130ec2c711d0c62ab (diff)
downloadpluralconnect-108525534c28013cfe1897c30e4565f9893f3766.tar.gz
pluralconnect-108525534c28013cfe1897c30e4565f9893f3766.tar.bz2
pluralconnect-108525534c28013cfe1897c30e4565f9893f3766.zip
Update
Diffstat (limited to 'includes/logo.inc')
-rw-r--r--includes/logo.inc97
1 files changed, 97 insertions, 0 deletions
diff --git a/includes/logo.inc b/includes/logo.inc
new file mode 100644
index 0000000..442ff2b
--- /dev/null
+++ b/includes/logo.inc
@@ -0,0 +1,97 @@
+<?php
+
+require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/functions.inc";
+require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/bitset.inc";
+require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/score.inc";
+
+$columns = round(sqrt(count(scoreOrderGlobal())));
+$members = scoreOrderGlobal();
+
+usort($members, function ($a, $b) {
+ $vr = hexdec(substr($a["color"], 0, 2));
+ $vg = hexdec(substr($a["color"], 2, 2));
+ $vb = hexdec(substr($a["color"], 4, 2));
+
+ $hsl = rgbToHsl($vr, $vg, $vb);
+ if ($hsl[0] == 0) $hsl[0] = 360;
+ $ra = $hsl[0];
+
+ $vr = hexdec(substr($b["color"], 0, 2));
+ $vg = hexdec(substr($b["color"], 2, 2));
+ $vb = hexdec(substr($b["color"], 4, 2));
+
+ $hsl = rgbToHsl($vr, $vg, $vb);
+ if ($hsl[0] == 0) $hsl[0] = 360;
+ $rb = $hsl[0];
+
+ return $ra - $rb;
+});
+
+$packs = [];
+$currentPack = [];
+
+foreach ($members as $member) {
+ if (count($currentPack) >= $columns) {
+ $packs[] = $currentPack;
+ $currentPack = [];
+ }
+
+ $currentPack[] = $member["color"];
+}
+
+if (count($currentPack) > 0) $packs[] = $currentPack;
+
+$newPacks = [];
+foreach ($packs as $pack) {
+ usort($pack, function ($a, $b) {
+ $vra = hexdec(substr($a, 0, 2));
+ $vga = hexdec(substr($a, 2, 2));
+ $vba = hexdec(substr($a, 4, 2));
+
+ $hsla = rgbToHsl($vra, $vga, $vba);
+ $ra = $hsla[2] * $hsla[1];
+
+ $vrb = hexdec(substr($b, 0, 2));
+ $vgb = hexdec(substr($b, 2, 2));
+ $vbb = hexdec(substr($b, 4, 2));
+
+ $hslb = rgbToHsl($vrb, $vgb, $vbb);
+ $rb = $hslb[2] * $hslb[1];
+
+ return $rb < $ra;
+ });
+
+ while (count($pack) < $columns) $pack[] = "ffffff";
+
+ $newPacks[] = $pack;
+}
+
+$img = imagecreatetruecolor($columns, $columns);
+$factor = 64;
+
+for ($y = 0; $y < $columns; ++$y) {
+ for ($x = 0; $x < $columns; ++$x) {
+ imagesetpixel($img, $x, $y, imagecolorallocate($img, hexdec(substr($newPacks[$y][$x], 0, 2)), hexdec(substr($newPacks[$y][$x], 2, 2)), hexdec(substr($newPacks[$y][$x], 4, 2))));
+ }
+}
+
+$img2 = imagecreatetruecolor($columns * $factor, $columns * $factor);
+imagecopyresampled($img2, $img, 0, 0, 0, 0, $columns * $factor, $columns * $factor, $columns, $columns);
+
+imagepng($img2, "/tmp/image.png");
+$img3 = imageCreateCorners("/tmp/image.png", $columns * 10);
+unlink("/tmp/image.png");
+
+imagepng($img3, $_SERVER['DOCUMENT_ROOT'] . "/assets/logo/newlogo.png");
+
+for ($x = 1; $x <= 120; $x++) {
+ imagefilter($img2, IMG_FILTER_GAUSSIAN_BLUR);
+}
+
+imagefilter($img2, IMG_FILTER_BRIGHTNESS, -100);
+
+imagepng($img2, "/tmp/image.png");
+$img3 = imageCreateCorners("/tmp/image.png", $columns * 10);
+unlink("/tmp/image.png");
+
+imagepng($img3, $_SERVER['DOCUMENT_ROOT'] . "/assets/logo/newlogo-template.png"); \ No newline at end of file