Skip to content

Instantly share code, notes, and snippets.

@allejo
Created May 27, 2015 17:02
Show Gist options
  • Save allejo/98c8596e07e93ef08598 to your computer and use it in GitHub Desktop.
Save allejo/98c8596e07e93ef08598 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
<div class="foo-1"></div>
<div class="foo-2"></div>
<div class="foo-3"></div>
<div class="foo-4"></div>
<div class="foo-5"></div>
<div class="foo-6"></div>
// ----
// Sass (v3.4.13)
// Compass (v1.0.3)
// ----
div {
display: inline-block;
height: 100px;
width: 100px;
}
$color-a: #018b37;
$color-b: #e47e7c;
$segments: 6;
$hue: hue($color-a) - hue($color-b);
$saturation: saturation($color-a) - saturation($color-b);
$lightness: lightness($color-a) - lightness($color-b);
$previous-color: $color-a;
@for $i from 1 through $segments {
.foo-#{$i} {
@if ($i == 1) {
background-color: $color-a;
}
@else if ($i == $segments) {
background-color: $color-b;
}
@else {
$function-saturation: if($saturation > 0, 'desaturate', 'saturate');
$function-lightness: if($lightness > 0, 'darken', 'lighten');
$divisor: $segments - 2;
$multiplier: $i - 1;
$hueMod: adjust_hue($color-a, ($hue/$divisor) * $multiplier);
$saturateMod: call($function-saturation, $hueMod, abs(($saturation/$divisor) * $multiplier));
$lightnessMod: call($function-lightness, $saturateMod, abs(($lightness/$divisor) * $multiplier));
background-color: $lightnessMod;
}
}
}
div {
display: inline-block;
height: 100px;
width: 100px;
}
.foo-1 {
background-color: #018b37;
}
.foo-2 {
background-color: #09b8b5;
}
.foo-3 {
background-color: #166be0;
}
.foo-4 {
background-color: #6247e4;
}
.foo-5 {
background-color: #cb7ce4;
}
.foo-6 {
background-color: #e47e7c;
}
<div class="foo-1"></div>
<div class="foo-2"></div>
<div class="foo-3"></div>
<div class="foo-4"></div>
<div class="foo-5"></div>
<div class="foo-6"></div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment