Created
January 24, 2014 13:43
-
-
Save xzyfer/8597475 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ---- | |
| // Sass (v3.3.0.rc.2) | |
| // Compass (v1.0.0.alpha.17) | |
| // ---- | |
| $px: 599px; | |
| $em: 49.99em; | |
| @function increment($number) { | |
| @return $number + 1 / exponent(10, precision($number)); | |
| } | |
| @function precision($number) { | |
| @if is-float($number) { | |
| $number: #{strip-units($number)}; | |
| // FIXME: make this >= 0 once https://github.com/nex3/sass/issues/1060 is closed | |
| @if str-index($number, ".") >= 1 { | |
| @return str-length($number) - str-index($number, "."); | |
| } | |
| } | |
| @return 0; | |
| } | |
| // Inspired by https://github.com/Team-Sass/Sassy-math/blob/master/sass/math.scss#L297 | |
| @function is-float($number) { | |
| @if type-of($number) == "number" and $number - floor($number) != 0 { | |
| @return true; | |
| } | |
| @warn "#{$number} is not a number!"; | |
| @return false; | |
| } | |
| // Inspired by https://github.com/nex3/sass/issues/533#issuecomment-11675408 | |
| @function strip-units($number) { | |
| @return $number / ($number * 0 + 1); | |
| } | |
| // Inspired by https://github.com/Team-Sass/Sassy-math/blob/master/sass/math.scss#L36 | |
| @function exponent($base, $exponent) { | |
| $value: $base; | |
| // positive intergers get multiplied | |
| @if $exponent > 1 { | |
| @for $i from 2 through $exponent { | |
| $value: $value * $base; | |
| } | |
| } | |
| // negitive intergers get divided. A number divided by itself is 1 | |
| @if $exponent < 1 { | |
| @for $i from 0 through -$exponent { | |
| $value: $value / $base; | |
| } | |
| } | |
| @return $value; | |
| } | |
| foo { | |
| px: precision($px); | |
| em: precision($em); | |
| px2: increment($px); | |
| em2: increment($em); | |
| foo: 1 / exponent(10, 2); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| foo { | |
| px: 0; | |
| em: 2; | |
| px2: 600px; | |
| em2: 50em; | |
| foo: 0.01; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment