WP_Duotone::colord_parse_hue()private staticWP 6.3.0

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

Direct port of colord's parseHue function.

Method of the class: WP_Duotone{}

No Hooks.

Returns

float. The parsed hue value.

Usage

$result = WP_Duotone::colord_parse_hue( $value, $unit );
$value(float) (required)
The hue value to parse.
$unit(string)
The unit of the hue value.
Default: 'deg'

Changelog

Since 6.3.0 Introduced.

WP_Duotone::colord_parse_hue() code WP 6.8.1

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

	$factor = isset( $angle_units[ $unit ] ) ? $angle_units[ $unit ] : 1;

	return (float) $value * $factor;
}