From 57c45995681e1ee61689a5e420601b1736236c8f Mon Sep 17 00:00:00 2001 From: dbox Date: Thu, 4 Feb 2016 10:05:33 -0600 Subject: [PATCH] add pow function --- knapsack/_utilities.scss | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/knapsack/_utilities.scss b/knapsack/_utilities.scss index 2f94f76..77b873b 100644 --- a/knapsack/_utilities.scss +++ b/knapsack/_utilities.scss @@ -2,7 +2,29 @@ // Utilities // ---- -//- Function: Rem Calculator + + +/// Power function +/// @param {Number} $x +/// @param {Number} $n +/// @return {Number} +/// @group utilities +/// @source https://github.com/adambom/Sass-Math/blob/master/math.scss Sass-Math +@function pow($x, $n) { + $result: 1; + + @if $n >= 0 { + @for $i from 1 through $n { + $result: $result * $x; + } + } @else { + @for $i from $n to 0 { + $result: $result / $x; + } + } + @return $result; +} + /// /// Calculates and returns the rem value based on px input. Default base font /// size is 16px, but can be changed with a global `$base-font-size` variable.