HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.109.1.lve.el8.x86_64 #1 SMP Thu Mar 5 20:23:46 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.30
Disabled: exec,passthru,shell_exec,system
Upload Files
File: /home/posscale/public_html/printmanager/vendor/spatie/color/src/Contrast.php
<?php

namespace Spatie\Color;

class Contrast
{
    public static function ratio(Color $a, Color $b): float
    {
        $a = $a instanceof Hex ? $a : $a->toHex();
        $b = $b instanceof Hex ? $b : $b->toHex();

        $l1 = self::calculateLuminance($a);
        $l2 = self::calculateLuminance($b);

        return round(
            ($l1 > $l2)
                ? ($l1 + 0.05) / ($l2 + 0.05)
                : ($l2 + 0.05) / ($l1 + 0.05),
            2
        );
    }

    public static function calculateLuminance(Hex $color): float
    {
        return
            0.2126 * pow(hexdec($color->red()) / 255, 2.2) +
            0.7152 * pow(hexdec($color->green()) / 255, 2.2) +
            0.0722 * pow(hexdec($color->blue()) / 255, 2.2);
    }
}