Converts an HSVA array to RGBA.
Description
Direct port of colord’s hsvaToRgba function.
Parameters
$hsva
arrayrequired- The HSVA array to convert.
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
Version | Description |
---|---|
6.3.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.