W3cubDocs

/WordPress

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

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 = isset( $angle_units[ $unit ] ) ? $angle_units[ $unit ] : 1;

	return (float) $value * $factor;
}

Changelog

Version Description
6.3.0 Introduced.

© 2003–2024 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_duotone/colord_parse_hue