wp_tinycolor_hue_to_rgb

函数
wp_tinycolor_hue_to_rgb ( $p, $q, $t )
Access
Private
参数
  • (float) $p first component.
    Required:
  • (float) $q second component.
    Required:
  • (float) $t third component.
    Required:
返回值
  • (float) R, G, or B component.
相关
  • https://github.com/bgrins/TinyColor
定义位置
相关方法
wp_tinycolor_hsl_to_rgbwp_tinycolor_rgb_to_rgbwp_tinycolor_string_to_rgbwp_tinycolor_bound01wp_color_scheme_settings
引入
5.8.0
弃用
-

wp_tinycolor_hue_to_rgb: 该函数将色调值转换为红、绿、蓝(RGB)值: 这是由TinyColor库使用的。

hsl到rgb转换的Helper函数。

直接移植了TinyColor的函数,略微简化以保持与TinyColor的一致性。与TinyColor的一致性。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
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;
}
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; }
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;
}

常见问题

FAQs
查看更多 >