WP_Duotone::colord_parse_hue( float $value, string $unit = 'deg' ): float

This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only by core. It is listed here for completeness.

Converts a hue value to degrees from 0 to 360 inclusive.

Description

Direct port of colord’s parseHue function.

Parameters

$valuefloatrequired
The hue value to parse.
$unitstringoptional
The unit of the hue value.

Default:'deg'

Return

float The parsed hue value.

Source

private static function colord_parse_hue( $value, $unit = 'deg' ) {
	$angle_units = array(
		'grad' => 360 / 400,
		'turn' => 360,
		'rad'  => 360 / ( M_PI * 2 ),
	);

	$factor = $angle_units[ $unit ] ?? 1;

	return (float) $value * $factor;
}

Changelog

VersionDescription
6.3.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.