_wp_tinycolor_bound_alpha

函式
_wp_tinycolor_bound_alpha ( $n )
Access
Private
引數
  • (mixed) $n Number of unknown type.
    Required:
返回值
  • (float) Value in the range [0,1].
相關
  • https://github.com/bgrins/TinyColor
定義位置
相關方法
wp_tinycolor_bound01wp_tinycolor_rgb_to_rgbwp_tinycolor_string_to_rgbwp_tinycolor_hsl_to_rgbwp_tinycolor_hue_to_rgb
引入
5.9.0
棄用
-

_wp_tinycolor_bound_alpha: 這個函式檢查一個顏色的alpha值是否在可接受的範圍內(0-1)。它在_wp_custom_background_cb和_wp_custom_header_cb函式中使用。

直接移植了tinycolor的boundAlpha函式,以保持與tinycolor工作方式的一致性。

function _wp_tinycolor_bound_alpha( $n ) {
	if ( is_numeric( $n ) ) {
		$n = (float) $n;
		if ( $n >= 0 && $n <= 1 ) {
			return $n;
		}
	}
	return 1;
}

常見問題

FAQs
檢視更多 >