mirror of
https://github.com/quotefox/Hyper-Station-13.git
synced 2026-08-28 15:16:18 +01:00
61 lines
1.4 KiB
SCSS
61 lines
1.4 KiB
SCSS
/**
|
|
* Copyright (c) 2018 Aleksej Komarov
|
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
|
*/
|
|
|
|
// Type-casting
|
|
// --------------------------------------------------------
|
|
|
|
// Get a unit-less numeric value
|
|
@function num($value) {
|
|
@if type-of($value) != number {
|
|
@error 'Could not convert `#{$value}` - must be `type-of number`';
|
|
@return null;
|
|
}
|
|
@if unit($value) == '%' {
|
|
@return $value / 100%;
|
|
}
|
|
@return $value / ($value * 0 + 1);
|
|
}
|
|
|
|
|
|
// Color
|
|
// --------------------------------------------------------
|
|
|
|
// Increases perceptual color lightness.
|
|
@function lighten($color, $percent) {
|
|
$scaled: hsl(
|
|
hue($color),
|
|
saturation($color),
|
|
lightness($color) * (1 + num($percent)));
|
|
$mixed: mix(#ffffff, $color, 100% * num($percent));
|
|
@return mix($scaled, $mixed, 75%);
|
|
}
|
|
|
|
// Returns the NTSC luminance of `$color` as a float (between 0 and 1).
|
|
// 1 is pure white, 0 is pure black.
|
|
@function luminance($color) {
|
|
$colors: (
|
|
'red': red($color),
|
|
'green': green($color),
|
|
'blue': blue($color)
|
|
);
|
|
|
|
@each $name, $value in $colors {
|
|
$adjusted: 0;
|
|
$value: $value / 255;
|
|
@if $value < 0.03928 {
|
|
$value: $value / 12.92;
|
|
}
|
|
@else {
|
|
$value: ($value + .055) / 1.055;
|
|
$value: math-pow($value, 2.4);
|
|
}
|
|
$colors: map-merge($colors, ($name: $value));
|
|
}
|
|
|
|
@return (map-get($colors, 'red') * .2126)
|
|
+ (map-get($colors, 'green') * .7152)
|
|
+ (map-get($colors, 'blue') * .0722);
|
|
}
|