Split srgb-scale into its own function

This commit is contained in:
Kane York 2015-08-20 13:31:00 -07:00
parent 3eb2668fcf
commit 26c3d74460
1 changed files with 23 additions and 15 deletions

View File

@ -39,24 +39,32 @@ $base-font-family: Helvetica, Arial, sans-serif !default;
@return ((red($color) * .299) + (green($color) * .587) + (blue($color) * .114)); @return ((red($color) * .299) + (green($color) * .587) + (blue($color) * .114));
} }
// Replaces dark-light-diff($primary, $secondary, 50%, -50%)
// Uses an approximation of sRGB blending, GAMMA=2 instead of GAMMA=2.2 // Uses an approximation of sRGB blending, GAMMA=2 instead of GAMMA=2.2
@function choose-grey($percent) { @function srgb-scale($foreground, $background, $percent) {
$ratio: ($percent / 100%); $ratio: ($percent / 100%);
$iratio: 1 - $ratio; $iratio: 1 - $ratio;
$pr2: red($primary) * red($primary); $f_r2: red($foreground) * red($foreground);
$pg2: green($primary) * green($primary); $f_g2: green($foreground) * green($foreground);
$pb2: blue($primary) * blue($primary); $f_b2: blue($foreground) * blue($foreground);
$sr2: red($secondary) * red($secondary); $b_r2: red($background) * red($background);
$sg2: green($secondary) * green($secondary); $b_g2: green($background) * green($background);
$sb2: blue($secondary) * blue($secondary); $b_b2: blue($background) * blue($background);
$rr2: $pr2 * $ratio + $sr2 * $iratio; $r_r2: $f_r2 * $ratio + $b_r2 * $iratio;
$rg2: $pg2 * $ratio + $sg2 * $iratio; $r_g2: $f_g2 * $ratio + $b_g2 * $iratio;
$rb2: $pb2 * $ratio + $sb2 * $iratio; $r_b2: $f_b2 * $ratio + $b_b2 * $iratio;
$rr: sqrt($rr2); $r_r: sqrt($r_r2);
$rg: sqrt($rg2); $r_g: sqrt($r_g2);
$rb: sqrt($rb2); $r_b: sqrt($r_b2);
@return rgb($rr, $rg, $rb); @return rgb($r_r, $r_g, $r_b);
}
// Replaces dark-light-diff($primary, $secondary, 50%, -50%)
@function choose-grey($percent) {
@return srgb-scale($primary, $secondary, $percent);
}
@function choose-gray($percent) {
@return choose-grey($percent);
} }
@function dark-light-diff($adjusted-color, $comparison-color, $lightness, $darkness) { @function dark-light-diff($adjusted-color, $comparison-color, $lightness, $darkness) {