$r, 'g' => $g, 'b' => $b); } function rgbToHex($r, $g, $b) { $hex = sprintf("#%02X%02X%02X", $r, $g, $b); return $hex; } function getComplementHex($hex) { $rgb = hexToRgb($hex); $compR = 255 - $rgb['r']; $compG = 255 - $rgb['g']; $compB = 255 - $rgb['b']; return rgbToHex($compR, $compG, $compB); } $original_hex = "#000000"; $complement_hex = "#FFFFFF"; if (isset($_POST['calculate'])) { if (!empty($_POST['hex_color']) && preg_match('/^#([0-9A-F]{3}|[0-9A-F]{6})$/i', $_POST['hex_color'])) { $original_hex = strtoupper($_POST['hex_color']); $complement_hex = getComplementHex($original_hex); } else if (isset($_POST['r'], $_POST['g'], $_POST['b'])) { $r = max(0, min(255, intval($_POST['r']))); $g = max(0, min(255, intval($_POST['g']))); $b = max(0, min(255, intval($_POST['b']))); $original_hex = rgbToHex($r, $g, $b); $complement_hex = getComplementHex($original_hex); } } ?> Komplementärfarbe berechnen

Komplementärfarbe berechnen

Originalfarbe:

HEX:

Komplementärfarbe:

HEX: