1// If a native exponent function doesnt exist 2// this one is needed. 3@function ms-pow($Base, $Exponent) { 4 5 // Find and remove unit. 6 // Avoids messyness with unit calculations 7 $Unit: $Base * 0 + 1; 8 $Base: $Base/$Unit; 9 10 // This function doesnt support non-interger exponents. 11 // Warn the user about why this is breaking. 12 @if round($Exponent) != $Exponent { 13 @warn "Unfortunately, you need Compass to use non-integer exponents"; 14 } 15 16 // Set up the loop, priming the return with the base. 17 $Return: $Base; 18 19 // If the number is positive, multiply it. 20 @if $Exponent > 0 { 21 // Basic feedback loop as exponents 22 // are recursivley multiplied numbers. 23 @for $i from 1 to $Exponent { 24 $Return: $Return * $Base; 25 } 26 } 27 28 // If the number is 0 or negitive 29 // divide instead of multiply. 30 @else { 31 // Libsass doesnt allow negitive values in loops 32 @for $i from (-1 + 1) to (abs($Exponent) + 1) { 33 $Return: $Return / $Base; 34 } 35 } 36 37 // Return is now compounded redy to be returned. 38 // Add the unit back onto the number. 39 @return $Return * $Unit; 40}