Merge branch 'master' of patchii.net:flash/flash.moe

This commit is contained in:
flash 2024-01-02 20:57:31 +00:00
commit f30420bff1
37 changed files with 115 additions and 9 deletions

View file

@ -2,15 +2,17 @@
background-image: url('/images/sprite.png'); background-image: url('/images/sprite.png');
width: 25px; width: 25px;
height: 25px; height: 25px;
background-size: 400px 25px; background-size: 450px 25px;
} }
@media only screen and (-webkit-min-device-pixel-ratio: 2), only screen and (min-device-pixel-ratio: 2) { @media only screen and (-webkit-min-device-pixel-ratio: 2), only screen and (min-device-pixel-ratio: 2) {
.fmi { background-image: url('/images/sprite@2x.png'); background-size: 400px 25px; } .fmi { background-image: url('/images/sprite@2x.png'); background-size: 450px 25px; }
} }
.fmi.fmi-email { background-position: 400px 0px; } .fmi.fmi-bluesky { background-position: 450px 0px; }
.fmi.fmi-flashii { background-position: 375px 0px; } .fmi.fmi-email { background-position: 425px 0px; }
.fmi.fmi-github { background-position: 350px 0px; } .fmi.fmi-flashii { background-position: 400px 0px; }
.fmi.fmi-lastfm { background-position: 325px 0px; } .fmi.fmi-github { background-position: 375px 0px; }
.fmi.fmi-lastfm { background-position: 350px 0px; }
.fmi.fmi-line { background-position: 325px 0px; }
.fmi.fmi-music { background-position: 300px 0px; } .fmi.fmi-music { background-position: 300px 0px; }
.fmi.fmi-n3ds { background-position: 275px 0px; } .fmi.fmi-n3ds { background-position: 275px 0px; }
.fmi.fmi-osu { background-position: 250px 0px; } .fmi.fmi-osu { background-position: 250px 0px; }

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

View file

@ -0,0 +1,104 @@
<?php
if(is_file('sprite.css'))
unlink('sprite.css');
if(is_file('sprite.html'))
unlink('sprite.html');
if(is_file('sprite.png'))
unlink('sprite.png');
if(is_file('sprite@2x.png'))
unlink('sprite@2x.png');
$files = glob('*.png');
define('CSS_TPL', '.fmi.fmi-%1$s { background-position: %2$dpx %3$dpx; }' . PHP_EOL);
$css = <<<CSS
.fmi {
background-image: url('sprite.png');
width: 25px;
height: 25px;
background-size: %1\$dpx %2\$dpx;
}
@media only screen and (-webkit-min-device-pixel-ratio: 2), only screen and (min-device-pixel-ratio: 2) {
.fmi { background-image: url('sprite@2x.png'); background-size: %1\$dpx %2\$dpx; }
}
CSS;
define('HTML_TPL', '<div class="fmi fmi-%1$s" style="border: 1px solid #0f0; margin: 5px; display: inline-block;" title="%1$s"></div>');
define('HTML_WRAP', '<!doctype html><link href="sprite.css" type="text/css" rel="stylesheet"/><div style="background-color: #000;">%1$s</div><div style="background-color: #fff;">%1$s</div>');
$html = '';
$lWidth2x = 0;
$lWidth1x = 0;
$lHeight2x = 0;
$lHeight1x = 0;
$width2x = 0;
$height2x = 0;
$dropFiles = [];
foreach($files as $file) {
$imgSize = getimagesize($file);
if($imgSize === false || $imgSize[2] !== IMAGETYPE_PNG) {
$dropFiles[] = $file;
continue;
}
if($lWidth2x < $imgSize[0])
$lWidth2x = $imgSize[0];
if($lHeight2x < $imgSize[1])
$lHeight2x = $imgSize[1];
$width2x += $imgSize[0];
if($height2x < $imgSize[1])
$height2x = $imgSize[1];
}
if($width2x < 1 || $height2x < 1)
die('did nothing' . PHP_EOL);
$files = array_diff($files, $dropFiles);
$lWidth1x = ceil($lWidth2x / 2);
$lHeight1x = ceil($lHeight2x / 2);
$width1x = ceil($width2x / 2);
$height1x = ceil($height2x / 2);
$offset = 0;
$sprite1x = new Imagick;
$sprite1x->newImage($width1x, $height1x, 'none');
$sprite1x->setImageFormat('png');
$sprite2x = new Imagick;
$sprite2x->newImage($width2x, $height2x, 'none');
$sprite2x->setImageFormat('png');
foreach($files as $file) {
$fileName = pathinfo($file, PATHINFO_FILENAME);
$html .= sprintf(HTML_TPL, $fileName);
$css .= sprintf(CSS_TPL, $fileName, $width1x - ($offset * $lWidth1x), 0);
$imagick = new Imagick($file);
$sprite2x->compositeImage($imagick, Imagick::COMPOSITE_DEFAULT, $offset * $lWidth2x, 0);
$imagick->resizeImage(
ceil($imagick->getImageWidth() / 2),
ceil($imagick->getImageHeight() / 2),
Imagick::FILTER_LANCZOS, 1
);
$sprite1x->compositeImage($imagick, Imagick::COMPOSITE_DEFAULT, $offset * $lWidth1x, 0);
$imagick->destroy();
$offset++;
}
$sprite1x->writeImage('sprite.png');
$sprite1x->destroy();
$sprite2x->writeImage('sprite@2x.png');
$sprite2x->destroy();
file_put_contents('sprite.css', sprintf($css, $width1x, $height1x, $width2x, $height2x));
file_put_contents('sprite.html', sprintf(HTML_WRAP, $html));

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.2 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.7 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.6 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.3 KiB

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.2 KiB

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.7 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 22 KiB

View file

@ -1,4 +1,4 @@
#!/usr/bin/env php #!/usr/bin/env php8.2
<?php <?php
use Index\Data\Migration\FsDbMigrationRepo; use Index\Data\Migration\FsDbMigrationRepo;

View file

@ -1,4 +1,4 @@
#!/usr/bin/env php #!/usr/bin/env php8.2
<?php <?php
use Index\Data\Migration\FsDbMigrationRepo; use Index\Data\Migration\FsDbMigrationRepo;

View file

@ -1,4 +1,4 @@
#!/usr/bin/env php #!/usr/bin/env php8.2
<?php <?php
require_once __DIR__ . '/../makai.php'; require_once __DIR__ . '/../makai.php';