W3cubDocs

/WordPress

WP_Duotone::colord_hsla_to_hsva( array $hsla ): array

Converts an HSLA array to HSVA.

Description

Direct port of colord’s hslaToHsva function.

Parameters

$hslaarrayrequired
The HSLA array to convert.

Return

array The HSVA array.

Source

private static function colord_hsla_to_hsva( $hsla ) {
	$h = $hsla['h'];
	$s = $hsla['s'];
	$l = $hsla['l'];
	$a = $hsla['a'];

	$s *= ( $l < 50 ? $l : 100 - $l ) / 100;

	return array(
		'h' => $h,
		's' => $s > 0 ? ( ( 2 * $s ) / ( $l + $s ) ) * 100 : 0,
		'v' => $l + $s,
		'a' => $a,
	);
}

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_hsla_to_hsva