remove tools/make_favicon

This commit is contained in:
E. S. 2025-05-04 03:33:52 +03:00
parent 8803f73533
commit 7449090277

View File

@ -1,60 +0,0 @@
<?php
const W = 10;
const H = 10;
$img = imagecreatetruecolor(W, H);
imagealphablending($img, false);
imagesavealpha($img, true);
// Allocate a transparent color and fill the image with it
$transparent = imagecolorallocatealpha($img, 0, 0, 0, 127);
imagefill($img, 0, 0, $transparent);
$x = 0;
$y = 0;
$plaintext = 'knowledge is power';
$alphabet = 'ABCDEFGHIKLMNOPQRSTVWXYZ';
function move_cursor(): void {
global $x, $y;
if ($x >= W-1) {
$x = 0;
$y++;
} else {
$x++;
}
}
function encode(string $letter): array {
global $alphabet;
$letter = strtoupper($letter);
$n = strpos($alphabet, $letter);
if ($n === false)
throw new Exception("letter $letter not found in the alphabet");
$ab = [];
for ($i = 0; $i < 5; $i++)
$ab[] = ($n >> $i) & 0x01;
return array_reverse($ab);
}
$a = imagecolorallocate($img, 0xcc, 0xcc, 0xcc);
$b = imagecolorallocate($img, 0x99, 0x99, 0x99);
for ($i = 0; $i < strlen($plaintext); $i++) {
$c = $plaintext[$i];
if ($c == ' ') {
for ($j = 0; $j < 5; $j++)
move_cursor();
continue;
}
foreach (encode($c) as $bit) {
imagesetpixel($img, $x, $y, $bit ? $b : $a);
move_cursor();
}
}
imagepng($img, '/tmp/4in1_fav.png');