Skip to content

Instantly share code, notes, and snippets.

@jeremyboggs
Created June 25, 2013 13:05
Show Gist options
  • Save jeremyboggs/5858277 to your computer and use it in GitHub Desktop.
Save jeremyboggs/5858277 to your computer and use it in GitHub Desktop.
/**
* Returns a color based on a base color and color rule.
*
* $base-color: The color you want to start with.
* $color-rule: complementary, analogous, split-complementary, triad, right-triangle
* $color-direction: positive (clockwise around color wheel) or negative (counterclockwise)
*/
@function color-wheel($base-color, $color-rule, $color-direction: 'positive') {
$degrees: 0;
@if $color-rule == 'analogous' {
$degrees: 30;
} @else if $color-rule == 'split-complementary' {
$degrees: 150;
} @else if $color-rule == 'triad' {
$degrees: 120;
} @else if $color-rule == 'right-triangle' {
$degrees: 90;
}
@if $color-direction == 'negative' {
$degrees: -$degrees;
}
$color: $base-color;
@if $color-rule == 'complementary' {
$color: complement($base-color);
} @else {
$color: adjust-hue($base-color, $degrees);
}
@return $color;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment