Classify colors as light or dark

Apply one explicit relative-luminance threshold for interface branching and labels.

#747474 - luminance 0.17465 dark
#757575 - luminance 0.17789 dark
#767676 - luminance 0.18116 light

See the exact boundary

PHPColor classifies colors with relative luminance greater than or equal to 0.179 as light. Values below it are dark.

Read the predicate and its input

Inspect luminance beside the boolean when the boundary matters to your application.

<?php

use PhpColor\Color\Color;

foreach (['#747474', '#757575', '#767676'] as $hex) {
    $color = Color::parse($hex);
    printf("%s %.15f %s\n",
        $hex,
        $color->getLuminance(),
        $color->isLight() ? 'light' : 'dark',
    );
}

// #747474 0.174647403655585 dark
// #757575 0.177888415983629 dark
// #767676 0.181164244249860 light
use PhpColor\Color\Color; foreach (['#747474', '#757575', '#767676'] as $hex) { $color = Color::parse($hex); printf("%s %.15f %s\n", $hex, $color->getLuminance(), $color->isLight() ? 'light' : 'dark', ); } // #747474 0.174647403655585 dark // #757575 0.177888415983629 dark // #767676 0.181164244249860 light

A class is not a contrast verdict

Light or dark describes one color under PHPColor's threshold. It does not evaluate a foreground and background pair.

LightRelative luminance is greater than or equal to 0.179.
DarkRelative luminance is below 0.179.
PairingUse a contrast calculation for two colors.
SemanticsThe predicate does not infer token roles or theme intent.

Choose a next step

Classify one color or measure the pair you actually use