WP_Duotone::colord_hsva_to_rgba( array $hsva ): array

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

Converts an HSVA array to RGBA.

Description

Direct port of colord’s hsvaToRgba function.

Parameters

$hsvaarrayrequired
The HSVA array to convert.

Return

array The RGBA array.

Source

private static function colord_hsva_to_rgba( $hsva ) {
	$h = ( $hsva['h'] / 360 ) * 6;
	$s = $hsva['s'] / 100;
	$v = $hsva['v'] / 100;
	$a = $hsva['a'];

	$hh     = floor( $h );
	$b      = $v * ( 1 - $s );
	$c      = $v * ( 1 - ( $h - $hh ) * $s );
	$d      = $v * ( 1 - ( 1 - $h + $hh ) * $s );
	$module = $hh % 6;

	return array(
		'r' => array( $v, $c, $b, $b, $d, $v )[ $module ] * 255,
		'g' => array( $d, $v, $v, $c, $b, $b )[ $module ] * 255,
		'b' => array( $b, $b, $d, $v, $v, $c )[ $module ] * 255,
		'a' => $a,
	);
}

Changelog

VersionDescription
6.3.0Introduced.

User Contributed Notes

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