bulma/sass/utilities/functions.sass

37 lines
1.1 KiB
Sass
Raw Normal View History

2016-01-24 00:03:43 +00:00
@function powerNumber($number, $exp)
$value: 1
@if $exp > 0
@for $i from 1 through $exp
$value: $value * $number
@else if $exp < 0
@for $i from 1 through -$exp
$value: $value / $number
@return $value
@function colorLuminance($color)
$color-rgb: ('red': red($color),'green': green($color),'blue': blue($color))
@each $name, $value in $color-rgb
2016-01-24 00:03:43 +00:00
$adjusted: 0
$value: $value / 255
@if $value < 0.03928
$value: $value / 12.92
@else
$value: ($value + .055) / 1.055
$value: powerNumber($value, 2)
$color-rgb: map-merge($color-rgb, ($name: $value))
@return (map-get($color-rgb, 'red') * .2126) + (map-get($color-rgb, 'green') * .7152) + (map-get($color-rgb, 'blue') * .0722)
2016-01-24 00:03:43 +00:00
@function findColorInvert($color)
2016-09-25 16:44:01 +00:00
@if (colorLuminance($color) > 0.55)
2016-10-30 10:41:53 +00:00
@return rgba(#000, 0.7)
2016-01-24 00:03:43 +00:00
@else
2016-10-30 10:41:53 +00:00
@return #fff
2016-12-22 18:44:54 +00:00
@function removeUnit($number)
@if type-of($number) == 'number' and not unitless($number)
2017-01-15 21:20:34 +00:00
@return $number / ($number * 0 + 1)
@return $number
2016-12-22 18:44:54 +00:00
@function roundToEvenNumber($number)
@return floor($number / 2) * 2