-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
image-rendering.scss
59 lines (59 loc) · 2.4 KB
/
image-rendering.scss
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/// Experimental and no MS support as of 2019
/// @param {string} $value
/// @returns {CSS} - `Property: Value` with prefixed values and properties
/// @see {link} - https://developer.mozilla.org/en-US/docs/Web/CSS/image-rendering
/// @see {link} - https://drafts.csswg.org/css-images-3/#the-image-rendering
/// @see {link} - https://developer.mozilla.org/en-US/docs/Web/CSS/image-rendering
/// @see {link} - https://drafts.csswg.org/css-images-3/#the-image-rendering
/// @see {link} - https://github.com/postcss/autoprefixer/issues/449
/// @see {link} - https://stackoverflow.com/questions/3900436/image-scaling-by-css-is-there-a-webkit-alternative-for-moz-crisp-edges
/// @example - Available values
/// - `auto`: UA dependent
/// - `smooth`: scale image with algorithm similar to bilinear interpolation
/// - `high-quality`: prioritized when resources are constrained, otherwise identical to smooth
/// - `crisp-edges`: preserve contrast during image scaling
/// - `pixelated`: scale using nearest neighbor algorithm
/// - `optimizeQuality`: use smooth
/// - `optimizeSpeed`: use pixelated
/// @example scss - Usage of image-rendering
/// .example-class {
/// @include image-rendering($value: crisp-edges);
/// }
/// @example css - Results of image-rendering
/// .example-class {
/// image-rendering: -webkit-optimize-contrast;
/// -ms-interpolation-mode: bicubic;
/// image-rendering: -moz-crisp-edges;
/// image-rendering: -o-crisp-edges;
/// image-rendering: crisp-edges;
/// }
/// @requires {mixin} render-vendor-prefixes
/// @author S0AndS0
/// @license AGPL-3.0
@mixin image-rendering($value) {
@if $value == crisp-edges {
image-rendering: -webkit-optimize-contrast; // Android, Chrome, Safari
-ms-interpolation-mode: bicubic; // IE 8-
@include render-vendor-prefixes(
$property: image-rendering,
$value: $value,
$vendor-list: (
-moz, // Firefox
-o, // Opera
),
$prefix: value,
);
}
@else if $value == pixelated {
image-rendering: optimizeSpeed; // Lagacy perposal fallback
-ms-interpolation-mode: nearest-neighbor; // IE 8-
image-rendering: #{$value};
}
@else if $value == smooth {
image-rendering: optimizeQuality; // Lagacy perposal fallback
image-rendering: #{$value};
}
@else {
image-rendering: #{$value};
}
}