Skip to content

Instantly share code, notes, and snippets.

@stephenway
Created July 31, 2014 17:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stephenway/ec0a3a839114e4981588 to your computer and use it in GitHub Desktop.
Save stephenway/ec0a3a839114e4981588 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
// ----
// libsass (v2.0.0)
// ----
@function scale-to-adjust($start, $change) {
@if($change > 0) {
$end: $start + $change;
@return percentage(($end - $start)/(100 - $start));
} @else {
@return percentage($change / $start);
}
}
@function scale-key($key, $color) {
$h: hue($color) - hue($key);
$s: saturation($color) - saturation($key);
$l: lightness($color) - lightness($key);
@return "scale-color(adjust-hue($key, #{$h}), $saturation: #{scale-to-adjust(saturation($key), $s)}, $lightness: #{scale-to-adjust(lightness($key), $l)}); ";
}
@function adjust-key($key, $color) {
$h: hue($color) - hue($key);
$s: saturation($color) - saturation($key);
$l: lightness($color) - lightness($key);
@return "adjust-color($key, $hue: #{$h}, $saturation: #{$s}, $lightness: #{$l}); ";
}
@function hack-colors($colors, $method: scale){
$key: nth($colors, 1);
$hack: "$key: #{$key}; ";
@for $i from 2 through length($colors) {
@if $method == scale {
$hack: $hack + "$color-#{$i}: #{scale-key($key, nth($colors, $i))}";
} @else {
$hack: $hack + "$color-#{$i}: #{adjust-key($key, nth($colors, $i))}";
}
}
@return $hack;
}
.output {
color: hack-colors(rgb(37,141,200) rgb(104,60,19));
}
.output {
color: "$key: #258dc8; $color-2: scale-color(adjust-hue($key, -173deg), $saturation: 1.05471%, $lightness: -48.10127%); "; }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment