-
Notifications
You must be signed in to change notification settings - Fork 0
/
logo.php
executable file
·88 lines (75 loc) · 2.19 KB
/
logo.php
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
#!/usr/bin/env php
<?php
$buttons_src_gray = [
"a" => file_get_contents("logo_button_a.svg"),
"b" => file_get_contents("logo_button_b.svg"),
"x" => file_get_contents("logo_button_x.svg"),
"y" => file_get_contents("logo_button_y.svg"),
"C" => file_get_contents("logo_C.svg"),
];
$colors = [
"a" => "red",
"b" => "yellow",
"x" => "blue",
"y" => "green",
"C" => "#025",
];
foreach ($buttons_src_gray as $name => $src) {
$buttons_src_color[$name] = str_replace(
"lightgray",
$colors[$name],
$src
);
file_put_contents("logo_{$name}_color.svg", $buttons_src_color[$name]);
}
$viewbox = [0, 0, 0, 0, 0, 0];
foreach ($buttons_src_gray as $src) {
preg_match('/viewBox="([^"]+)"/', $src, $matches);
$v = explode(" ", $matches[1]);
$viewbox[0] = min($viewbox[0], $v[0]);
$viewbox[1] = min($viewbox[1], $v[1]);
$viewbox[2] = max($viewbox[2], $v[2]);
$viewbox[3] = max($viewbox[3], $v[3]);
$viewbox[4] = max($viewbox[4], $v[2]);
$viewbox[5] = max($viewbox[5], $v[3]);
}
$viewbox[0]--;
$viewbox[1]--;
$viewbox[2] = $viewbox[2] - $viewbox[0] + $viewbox[4];
$viewbox[2]++;
$viewbox[3] = $viewbox[3] - $viewbox[1] + $viewbox[5];
$viewbox[3]++;
unset($viewbox[4]);
unset($viewbox[5]);
$viewbox = implode(" ", $viewbox);
$t = explode("\n", $buttons_src_gray["a"]);
$prefix = [];
$prefix[] = array_shift($t);
$prefix[] = array_shift($t);
$prefix[] = array_shift($t);
$prefix[] = array_shift($t);
$prefix[2] = "<svg width=\"32mm\" height=\"26mm\" viewBox=\"-70 -75 160 150\" xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\">";
$suffix = [];
$suffix[] = array_pop($t);
$suffix[] = array_pop($t);
$src_out = $buttons_src_gray["a"];
$out = "";
foreach ($prefix as $line) {
$out .= $line . "\n";
}
$filename = "logo_full.svg";
foreach ($colors as $btn => $name) {
$btn_src = $buttons_src_color[$btn];
$btn_src = explode("\n", $btn_src);
array_shift($btn_src);
array_shift($btn_src);
array_shift($btn_src);
array_shift($btn_src);
array_pop($btn_src);
array_pop($btn_src);
$out .= implode("\n", $btn_src) . "\n";
}
foreach ($suffix as $line) {
$out .= $line . "\n";
}
file_put_contents($filename, $out);