Skip to content

Instantly share code, notes, and snippets.

@nonaybay
Created August 11, 2022 05:29
Show Gist options
  • Save nonaybay/ad555ea100bfe8f3da29d2aa9322b048 to your computer and use it in GitHub Desktop.
Save nonaybay/ad555ea100bfe8f3da29d2aa9322b048 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
@use 'sass:color';
@use 'sass:math';
@function scale($v, $w, $n, $x) {
@if ($w > 0) {
$i: ($x - $v);
$s: (($w * $s) / 100);
$v: ($v + $s);
} @else if ($w < 0) {
$i: ($v - $n);
$w: math.abs($w);
$s: (($w * $s) / 100);
$v: ($v - $s);
} @else {
$v: $v;
}
@return $v;
}
@function gen($c, $m, $h, $s, $l) {
$ch: color.hue($c);
$cs: color.saturation($c);
$h: scale($ch, $h, 0, 360);
$s: scale($cs, $s, 0, 100);
$c: color.mix($m, $c, $l);
$c: color.change($c, $hue: $h, $saturation: $s);
@return $c;
}
$cb: #333;
$cbh: color.hue($cb);
$cbs: color.saturation($cb);
$cbl: color.lightness($cb);
$ct: #666;
$cth: color.hue($ct);
$cts: color.saturation($ct);
$ctl: color.lightness($ct);
$co: gen($cb, white, 0, 0, 25.0);
$coh: color.hue($co);
$cos: color.saturation($co);
$col: color.lightness($co);
debug {
/* base */
value: $cb;
value: $cbh;
value: $cbs;
value: $cbl;
/* target */
value: $ct;
value: $cth;
value: $cts;
value: $ctl;
/* output */
value: $co;
value: $coh;
value: $cos;
value: $col;
/* state */
value-c: if(($co != $ct), 'fails', 'pass');
value-h: if(($coh < $cth), 'inc hue', if(($coh > $cth), 'dec hue', 'pass'));
value-s: if(($cos < $cts), 'inc sat', if(($cos > $cts), 'dec sat', 'pass'));
value-l: if(($col < $ctl), 'inc lig', if(($col > $ctl), 'dec lig', 'pass'));
}
debug {
/* base */
value: #333;
value: 0deg;
value: 0%;
value: 20%;
/* target */
value: #666;
value: 0deg;
value: 0%;
value: 40%;
/* output */
value: #666666;
value: 0deg;
value: 0%;
value: 40%;
/* state */
value-c: "pass";
value-h: "pass";
value-s: "pass";
value-l: "pass";
}
{
"sass": {
"compiler": "dart-sass/1.32.12",
"extensions": {},
"syntax": "SCSS",
"outputStyle": "expanded"
},
"autoprefixer": false
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment