W3cubDocs

/WordPress

WP_Duotone::colord_clamp( float $number, float $min, float $max = 1 ): float

Clamps a value between an upper and lower bound.

Description

Direct port of colord’s clamp function.

Parameters

$numberfloatrequired
The number to clamp.
$minfloatrequired
The minimum value.
$maxfloatoptional
The maximum value.

Default:1

Return

float The clamped value.

Source

private static function colord_clamp( $number, $min = 0, $max = 1 ) {
	return $number > $max ? $max : ( $number > $min ? $number : $min );
}

Changelog

Version Description
6.3.0 Introduced.

© 2003–2024 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_duotone/colord_clamp