summaryrefslogtreecommitdiff
path: root/_sass/bourbon/functions/_is-light.scss
blob: 92d90ac3cca011895a94b3f9e920128286930017 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
@charset "UTF-8";

/// Programatically determines whether a color is light or dark.
///
/// @link http://robots.thoughtbot.com/closer-look-color-lightness
///
/// @param {Color (Hex)} $color
///
/// @example scss - Usage
///   is-light($color)
///
/// @return {Bool}

@function is-light($hex-color) {
  $-local-red: red(rgba($hex-color, 1));
  $-local-green: green(rgba($hex-color, 1));
  $-local-blue: blue(rgba($hex-color, 1));
  $-local-lightness: ($-local-red * 0.2126 + $-local-green * 0.7152 + $-local-blue * 0.0722) / 255;

  @return $-local-lightness > 0.6;
}