wpseek.com
A WordPress-centric search engine for devs and theme authors



wp_tinycolor_hue_to_rgb › WordPress Function

Since5.8.0
Deprecatedn/a
wp_tinycolor_hue_to_rgb ( $p, $q, $t )
Access:
  • private
Parameters: (3)
  • (float) $p first component.
    Required: Yes
  • (float) $q second component.
    Required: Yes
  • (float) $t third component.
    Required: Yes
See:
Returns:
  • (float) R, G, or B component.
Defined at:
Codex:

Helper function for hsl to rgb conversion.

Direct port of TinyColor's function, lightly simplified to maintain consistency with TinyColor.


Source

function wp_tinycolor_hue_to_rgb( $p, $q, $t ) {
	if ( $t < 0 ) {
		$t += 1;
	}
	if ( $t > 1 ) {
		$t -= 1;
	}
	if ( $t < 1 / 6 ) {
		return $p + ( $q - $p ) * 6 * $t;
	}
	if ( $t < 1 / 2 ) {
		return $q;
	}
	if ( $t < 2 / 3 ) {
		return $p + ( $q - $p ) * ( 2 / 3 - $t ) * 6;
	}
	return $p;
}