You are here

private function SettingsPopup::getColorContrastInverse in General Data Protection Regulation Compliance 8

Inverse check.

File

src/Form/SettingsPopup.php, line 197

Class

SettingsPopup
Implements the form controller.

Namespace

Drupal\gdpr_compliance\Form

Code

private function getColorContrastInverse($color) {
  if ($color == 'none') {
    $color = '#306133';
  }
  $hexcolor = substr($color, 1);
  $r = hexdec(substr($hexcolor, 0, 2));
  $g = hexdec(substr($hexcolor, 2, 2));
  $b = hexdec(substr($hexcolor, 4, 2));
  $yiq = ($r * 299 + $g * 587 + $b * 114) / 1000;
  return $yiq >= 128 ? 'black' : 'white';
}