@function yiq-test($color, $threshold) {
  $r: red($color);
  $g: green($color);
  $b: blue($color);

  $yiq: (($r * 299) + ($g * 587) + ($b * 114)) / 1000;

  @return if($yiq >= $threshold, true, false);
}

@function yiq(
  $base,
  $dark: $dfr-yiq-color-dark,
  $light: $dfr-yiq-color-light,
  $threshold: $dfr-yiq-threshold
) {
  @return if(yiq-test($base, $threshold), $dark, $light);
}
