Get's the luminosity contrast based on the sRGB color space
https://www.w3.org/TR/WCAG20/#relativeluminancedef

@return float
768521
public function getLuminosity(): float
    {
        $rSrgb = $this->colors['r'] / 255;
        $gSrgb = $this->colors['g'] / 255;
        $bSrgb = $this->colors['b'] / 255;

        $r = $rSrgb <= 0.03928 ? $rSrgb / 12.92 : pow(($rSrgb + 0.055) / 1.055, 2.4);
        $g = $gSrgb <= 0.03928 ? $gSrgb / 12.92 : pow(($gSrgb + 0.055) / 1.055, 2.4);
        $b = $bSrgb <= 0.03928 ? $bSrgb / 12.92 : pow(($bSrgb + 0.055) / 1.055, 2.4);

        return (0.2126 * $r) + (0.7152 * $g) + (0.0722 * $b);
    }
423623
public static int contrast(Color left, Color right) throws ServletException {
	return (Math.max(left.getRed(), right.getRed()) - Math.min(left.getRed(), right.getRed()))
		+ (Math.max(left.getGreen(), right.getGreen()) - Math.min(left.getGreen(), right.getGreen()))
		+ (Math.max(left.getBlue(), right.getBlue()) - Math.max(left.getBlue(), right.getBlue()));
    }
1196435
function calculateLuminance(hex, lum) {
  return Math.round(Math.min(Math.max(0, hex + (hex * lum)), 255));
}
230254
public function epsilon()
  {
    $half = $this->same('0.5', $this->prec + 1);
    $factor = $this->same('10', 0)->pow($this->prec);
    return $half->div($factor);
  }
162143
public function getPixelAspectRatio()
    {
        if ($this->pixelAspectRatio === null) {
            $match = [];
            preg_match(self::$REGEX_PIXEL_ASPECT_RATIO, $this->output, $match);
            $this->pixelAspectRatio = (array_key_exists(1, $match) && array_key_exists(
                    2,
                    $match
                )) ? ($match[1] / $match[2]) : 0;
        }

        return $this->pixelAspectRatio;
    }
1244377
public static function rgb2xyz($rgb)
    {
        // Inverse sRGB Companding
        $rgb = array_map(function ($n) {
            if ($n <= 0.04045) {
                return $n / 12.92;
            }
            return pow(($n + 0.055) / 1.055, 2.4);
        }, $rgb);

        // Linear RGB to XYZ
        return array(
            0.4124564 * $rgb[0] + 0.3575761 * $rgb[1] + 0.1804375 * $rgb[2],
            0.2126729 * $rgb[0] + 0.7151522 * $rgb[1] + 0.0721750 * $rgb[2],
            0.0193339 * $rgb[0] + 0.1191920 * $rgb[1] + 0.9503041 * $rgb[2]
        );
    }
986979
private float brightness(int color) {
        int r = (color >> 16) & 0xFF;
        int g = (color >> 8) & 0xFF;
        int b = color & 0xFF;

        int V = Math.max(b, Math.max(r, g));
        return (V / 255.f);
    }
802109
private function relativeLuminosity(RGB $color)
    {
        $luminosity = 0.2126 * pow($color->getRed() / 255, 2.2) +
            0.7152 * pow($color->getGreen() / 255, 2.2) +
            0.0722 * pow($color->getBlue() / 255, 2.2);

        return $luminosity;
    }
517352
public function getLuminance($red, $green, $blue)
    {
        switch ($this->luminanceStrategy) {
            case 1:
                $luminance = ($red * 0.2126 + $green * 0.7152 + $blue * 0.0722) / 255;
                break;
            case 2:
                $luminance = ($red * 0.299 + $green * 0.587 + $blue * 0.114) / 255;
                break;
            case 3:
                $luminance = sqrt(0.299 * pow($red, 2) + 0.587 * pow($green, 2) + 0.114 * pow($blue, 2)) / 255;
                break;
            case 0:
            default:
                $luminance = ($red + $green + $blue) / (255 * 3);
        }

        return $luminance;
    }
1126733
public function getRgba()
    {
        return sprintf('rgba(%d, %d, %d, %.2F)', $this->r, $this->g, $this->b, round(1 - $this->a / 127, 2));
    }
489878
public static int brightnessNTSC(int rgb) {
		int r = (rgb >> 16) & 0xff;
		int g = (rgb >> 8) & 0xff;
		int b = rgb & 0xff;
		return (int)(r*0.299f + g*0.587f + b*0.114f);
	}
579483
private int getNewColor(int i)
  {
    int r = (((i) * 224) % 255);
    int g = (((i + 197) * 1034345) % 255);
    int b = (((i + 23) * 74353) % 255);

    //  too dark or too bright?
    if (((r + b + g) / 3) < 100)
    {
      r = 255 - r;
      g = 255 - g;
      b = 255 - b;
    }
    else if (((r + b + g) / 3) > 192)
    {
      r = 1 * (r / 2);
      g = 1 * (g / 2);
      b = 1 * (b / 2);
    }

    if (r == 255 && g == 255 && b == 255)
    {
      r = 255;
      g = 255;
      b = 0;
    }

    return (r * 65536 + g * 256 + b);
  }
152082
public function getAspectRatio(): float
    {
        $attrs = $this->getXmlAttrs();

        if (!isset($attrs->viewBox)) {
            return 0;
        }

        list(, , $width, $height) = explode(' ', $attrs->viewBox);

        return $width / $height;
    }
900448
public function calculate(ColorJizz $foreground, ColorJizz $background)
    {
        $fgLuma  = $this->relativeLuminosity($foreground->toRGB());
        $bgLuma  = $this->relativeLuminosity($background->toRGB());

        if ($fgLuma > $bgLuma) {
            return ($fgLuma + 0.05) / ($bgLuma + 0.05);
        } else {
            return ($bgLuma + 0.05) / ($fgLuma + 0.05);
        }
    }
545043
public function getWidth() : ?float 
    {
        if ( ! $this->hasWidth()) {
            $this->setWidth($this->getDefaultWidth());
        }
        return $this->width;
    }
780132
function getFocusColor(colors) {
  if (Color(colors.primary).luminosity() >= 0.8) {
    return colors.accent;
  }

  return colors.primary;
}
419729
public function getRatio()
    {
        $rawRatio = $this->height / $this->width * 100;
        
        // round it up to two digits
        $exactFraction = floor($rawRatio);
        
        // now divide it to 4, we should get the nearest fourth
        $fourthRound = $exactFraction + (round(($rawRatio - $exactFraction) * 4) * .25);
        
        return $fourthRound;
    }