Skip to content

Instantly share code, notes, and snippets.

@matori
Last active December 22, 2015 19:38
Show Gist options
  • Save matori/6520553 to your computer and use it in GitHub Desktop.
Save matori/6520553 to your computer and use it in GitHub Desktop.
コントラスト比チェック。SassMeister でいじって確認。 http://sassmeister.com/gist/Matori/6520553
// Original http://jsdo.it/a_t/qtce
@function lum_exc($val){$val:($val / 255);@return if($val <= 0.03928, $val / 12.92, pow(($val + 0.055)/1.055 , 2.4));}
@function luminance($val){@return (lum_exc(red($val)) * 0.2126)+(lum_exc(green($val)) * 0.7152)+(lum_exc(blue($val)) * 0.0722);}
@function contrastRatio($v1,$v2){$v1:luminance($v1)+0.05;$v2:luminance($v2)+0.05;@return if(($v1 - $v2)>0, $v1 / $v2, $v2 / $v1);}
$background: white;
$foreground: black;
/**
* Contrast Ratio Check Result
*
* Background Color: #{$background}
* Foreground Color: #{$foreground}
* Contrast Ratio : #{contrastRatio($background,$foreground)}
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment