Created
July 8, 2014 16:05
-
-
Save wehrhaus/16ded9bc5a67066fd3f8 to your computer and use it in GitHub Desktop.
Stylus Percentage Difference Calcualator
This file contains 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
// http://www.mathsisfun.com/percentage-difference.html | |
// get percentage difference of 2 numbers | |
// returns optional unitType as well in the form of '%, px, em' etc | |
getPercentageDifference(v1, v2, unitType = '') | |
return unit(((v1 - v2) / ((v1 + v2) / 2)) * 100, unitType) | |
// get percentage difference of 2 numbers then returns the result minus a given max value | |
// returns optional unitType as well in the form of '%, px, em' etc | |
getPercentageDifferenceMinusMax(v1, v2, max, unitType = '') | |
return unit(max - getPercentageDifference(v1, v2), unitType) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment