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
檢視更多 >