-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscrim-gradient.less
29 lines (26 loc) · 1.2 KB
/
scrim-gradient.less
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/**
* .scrim-gradient
* A simple little LESS mixin for creating scrim gradients
* Inspired by Andreas Larson - https://github.com/larsenwork
* https://css-tricks.com/easing-linear-gradients/
* @license: MIT
* @Rewritten in LESS 1.5 by morgunkorn
*/
.scrim-gradient( @scrimDirection: to bottom, @scrimColor: fade(black,50%) ) {
@scrimPositions: 1, 19, 34, 47, 56.5, 65, 73, 80.2, 86.1, 91, 95.2, 98.2;
@scrimAlphas: 1, 0.738, 0.541, 0.382, 0.278, 0.194, 0.126, 0.075, 0.042, 0.021, 0.008, 0.002;
@scrimHue: hue(@scrimColor);
@scrimSaturation: saturation(@scrimColor);
@scrimLightness: lightness(@scrimColor);
@scrimAlpha: alpha(@scrimColor);
background+: ~"linear-gradient(" @scrimDirection;
.scrim-loop(length(@scrimPositions));
.scrim-loop(@scrimIndex) when (@scrimIndex > 0) {
.scrim-loop((@scrimIndex - 1));
@scrimStopAlpha: extract(@scrimAlphas, @scrimIndex);
@scrimStopPosition: extract(@scrimPositions, @scrimIndex);
@scrimStopColor: hsla(@scrimHue, @scrimSaturation, @scrimLightness, @scrimAlpha * @scrimStopAlpha);
background+: @scrimStopColor percentage(@scrimStopPosition / 100);
}
background+: hsla(@scrimHue, @scrimSaturation, @scrimLightness, 0) ~' 100% )';
}