//// /// Basic mathematical functions. /// /// @group Math functions /// /// @access public //// /// /// Perform exponentiation. Only integer exponents are supported. /// /// @param {number} $base /// @param {number} $exp /// /// @return {number} /// /// @example scss - Exponentiation with a positive exponent /// $result: iro-math-pow(3, 2); // The value of $result is 3^2 = 9 /// /// @example scss - Exponentiation with a negative exponent /// $result: iro-math-pow(2, -3); // The value of $result is 1/(2^3) = 1/8 /// @function iro-math-pow($base, $exp) { $value: 1; @if $exp > 0 { @for $i from 1 through $exp { $value: $value * $base; } } @else if $exp < 0 { @for $i from 1 through -$exp { $value: $value / $base; } } @return $value; } /// /// Clamp a number between a minimum and maximum value. /// /// @param {number} $value - Value to clamp /// @param {number} $min - Minimum value /// @param {number} $max - Maximum value /// /// @return {number} /// /// @example scss /// $result: iro-math-clamp(20, 0, 10); // The value of $result is 10 /// /// @example scss /// $result: iro-math-clamp(50, 20, 100); // The value of $result is 50 /// @function iro-math-clamp($value, $min, $max) { @if $value < $min { @return $min; } @if $value > $max { @return $max; } @return $value; }