// Create a modular scale. Returns a list of values. @function ss-make-scale( $base: 16px, $max: 32px, $smaller-values: 1, $larger-values: 4, $rounding: false ) { $scale: (); // The ratio we'll use to calculate the missing sizes. $scaling-ratio: nth-root($max / $base, $larger-values); // Calculate and add smaller values to the scale. @for $i from -$smaller-values through -1 { $size: $base * power($scaling-ratio, $i); $scale: append($scale, $size); } // Add the base value to the scale. $scale: append($scale, $base); // Calculate and add larger values to the scale. @for $i from 1 through ($larger-values) { $size: $base * power($scaling-ratio, $i); $scale: append($scale, $size); } // Optionally round the scale. @if $rounding == true { @each $size-name, $size-value in $scale { $new-value: round($size-value); $scale: map-merge($scale, ($size-name: $new-value)); } } @return $scale; }