public static function contrast( $color, $dark = false, $light = false, $threshold = false) { // filter: contrast(3.2); // should be kept as is, so check for color if( !property_exists($color,'rgb') ){ return null; } if( $light === false ){ $light = Less_Environment::rgba(255, 255, 255, 1.0); } if( $dark === false ){ $dark = Less_Environment::rgba(0, 0, 0, 1.0); } //Figure out which is actually light and dark! if( $dark->luma() > $light->luma() ){ $t = $light; $light = $dark; $dark = $t; } if( $threshold === false ){ $threshold = 0.43; } else { $threshold = Less_Environment::number($threshold); } if( ($color->luma() * $color->alpha) < $threshold ){ return $light; } else { return $dark; } }