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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
|
<?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 = ceil(sqrt(count(scoreOrderGlobal())));
echo(" Using " . $columns . " columns\n");
$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;
});
echo(" " . count($members) . " members\n");
$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) {
if (isset($newPacks[$y][$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))));
} else {
imagesetpixel($img, $x, $y, imagecolorallocate($img, 255, 255, 255));
}
}
}
$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");
imagepng($img3, "/tmp/ponieslogo1.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");
imagepng($img3, "/tmp/ponieslogo2.png");
// --------------------------
$columns = ceil(sqrt(count(array_filter(scoreOrderGlobal(), function ($i) {
return $i["_system"] === "gdapd";
}))));
echo(" Using " . $columns . " columns\n");
$members = array_values(array_filter(scoreOrderGlobal(), function ($i) {
return $i["_system"] === "gdapd";
}));
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;
});
echo(" " . count($members) . " members\n");
$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) {
if (isset($newPacks[$y][$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))));
} else {
imagesetpixel($img, $x, $y, imagecolorallocate($img, 255, 255, 255));
}
}
}
$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/newlogo2.png");
imagepng($img3, "/tmp/ponieslogo1a.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/newlogo2-template.png");
imagepng($img3, "/tmp/ponieslogo2a.png");
|