wpseek.com
Outil de recherche WordPress pour les développeurs et auteurs de thèmes
wp_tinycolor_bound01 is private and should not be used in themes or plugins directly.
wp_tinycolor_bound01 › WordPress Function
Depuis5.8.0
Dépréciée6.3.0
› wp_tinycolor_bound01 ( $n, $max )
Accès: |
|
Paramètres: (2) |
|
Liens: | |
Retourne: |
|
Défini(e) dans: |
|
Codex: |
Takes input from [0, n] and returns it as [0, 1].
Direct port of TinyColor's function, lightly simplified to maintain consistency with TinyColor.Fonctions en relation: _wp_tinycolor_bound_alpha, wp_tinycolor_rgb_to_rgb, wp_tinycolor_hue_to_rgb, wp_tinycolor_hsl_to_rgb, wp_tinycolor_string_to_rgb
Source
function wp_tinycolor_bound01( $n, $max ) { _deprecated_function( __FUNCTION__, '6.3.0' ); if ( 'string' === gettype( $n ) && str_contains( $n, '.' ) && 1 === (float) $n ) { $n = '100%'; } $n = min( $max, max( 0, (float) $n ) ); // Automatically convert percentage into number. if ( 'string' === gettype( $n ) && str_contains( $n, '%' ) ) { $n = (int) ( $n * $max ) / 100; } // Handle floating point rounding errors. if ( ( abs( $n - $max ) < 0.000001 ) ) { return 1.0; } // Convert into [0, 1] range if it isn't already. return ( $n % $max ) / (float) $max; }