Format old PHP files

This commit is contained in:
2022-01-14 10:48:52 +01:00
parent 0ad86228e9
commit 87df496efd
67 changed files with 1555 additions and 1528 deletions

View File

@@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/* Computes the lightness of a pixel. Lightness is used in HSL notation, as well
* as in various operations on images. This function returns a normalized value
* for lightness between 0 and 1, inclusive (0.0 being black, 1.0 being white).
@@ -9,39 +11,36 @@
* x, y The coordinates of the pixel to work on
*
* by Jed Smith <?php $u = "jed"; $d = "bz"; printf("<%s@%s.%s>", $u, $u, $d) ?>
*/
function imagelightnessat($img, $x, $y)
{
if(!is_resource($img))
{
trigger_error("imagelightnessat(): supplied argument is not a valid "
. "Image resource", E_USER_WARNING);
return 0.0;
}
$c = @imagecolorat($img, $x, $y);
if($c === false) return false;
if(imageistruecolor($img))
{
$red = ($c >> 16) & 0xFF;
$green = ($c >> 8) & 0xFF;
$blue = $c & 0xFF;
}
else
{
$i = imagecolorsforindex($img, $c);
$red = $i['red'];
$green = $i['green'];
$blue = $i['blue'];
}
$m = min($red, $green, $blue);
$n = max($red, $green, $blue);
/* Because RGB isn't normalized in GD, we divide by 510 here.
* Lightness = (Max(RGB) + Min(RGB)) / 2
* But that's assuming red, green, and blue are 0 through 1 inclusive.
* Red, green, and blue are actually 0-255 (255 + 255 = 510).
*/
$lightness = (double)(($m + $n) / 510.0);
return($lightness);
}
*/
function imagelightnessat($img, $x, $y) {
if (!is_resource($img)) {
trigger_error('imagelightnessat(): supplied argument is not a valid '
. 'Image resource', \E_USER_WARNING);
?>
return 0.0;
}
$c = @imagecolorat($img, $x, $y);
if ($c === false) {
return false;
}
if (imageistruecolor($img)) {
$red = ($c >> 16) & 0xFF;
$green = ($c >> 8) & 0xFF;
$blue = $c & 0xFF;
} else {
$i = imagecolorsforindex($img, $c);
$red = $i['red'];
$green = $i['green'];
$blue = $i['blue'];
}
$m = min($red, $green, $blue);
$n = max($red, $green, $blue);
/* Because RGB isn't normalized in GD, we divide by 510 here.
* Lightness = (Max(RGB) + Min(RGB)) / 2
* But that's assuming red, green, and blue are 0 through 1 inclusive.
* Red, green, and blue are actually 0-255 (255 + 255 = 510).
*/
$lightness = (float) (($m + $n) / 510.0);
return $lightness;
}