@function cs-interpolate($value, $units: 360, $stops: $ryb-interpolation) {
// Loop numbers out of scale back into the scale.
@while $value >= 360 {
$value: $value - 360;
}
@while $value < 0 {
$value: $value + 360;
}
// Find out how many units in each stop
$cs-color-deg: $units / length($stops);
// Count through stops
$cs-deg-count: $cs-color-deg;
$cs-stop-count: 1;
// Add the first stop to the end so it will be
// interpolated with the last stop.
$stops: append($stops, nth($stops, 1));
// Start interpolating
@for $i from 0 through length($stops) {
@if $value < $cs-deg-count {
@return cs-mix(nth($stops, $cs-stop-count + 1), nth($stops, $cs-stop-count), abs(percentage(($cs-deg-count - $value) / $cs-color-deg) - 100 ), $model: rgb);
}
// If the value is not in this stop, loop up to another stop.
@else {
$cs-deg-count: $cs-deg-count + $cs-color-deg;
$cs-stop-count: $cs-stop-count + 1
}
}
}
|