functions.sass 867 B

12345678910111213141516171819202122232425262728
  1. @function powerNumber($number, $exp)
  2. $value: 1
  3. @if $exp > 0
  4. @for $i from 1 through $exp
  5. $value: $value * $number
  6. @else if $exp < 0
  7. @for $i from 1 through -$exp
  8. $value: $value / $number
  9. @return $value
  10. @function colorLuminance($color)
  11. $color-rgb: ('red': red($color),'green': green($color),'blue': blue($color))
  12. @each $name, $value in $color-rgb
  13. $adjusted: 0
  14. $value: $value / 255
  15. @if $value < 0.03928
  16. $value: $value / 12.92
  17. @else
  18. $value: ($value + .055) / 1.055
  19. $value: powerNumber($value, 2)
  20. $color-rgb: map-merge($color-rgb, ($name: $value))
  21. @return (map-get($color-rgb, 'red') * .2126) + (map-get($color-rgb, 'green') * .7152) + (map-get($color-rgb, 'blue') * .0722)
  22. @function findColorInvert($color)
  23. @if (colorLuminance($color) > 0.55)
  24. @return rgba(#000, 0.7)
  25. @else
  26. @return #fff