summaryrefslogtreecommitdiffstats
path: root/src/_functions.scss
diff options
context:
space:
mode:
Diffstat (limited to 'src/_functions.scss')
-rw-r--r--src/_functions.scss64
1 files changed, 6 insertions, 58 deletions
diff --git a/src/_functions.scss b/src/_functions.scss
index 9c29285..0c04f1d 100644
--- a/src/_functions.scss
+++ b/src/_functions.scss
@@ -67,63 +67,11 @@
67 @return list.nth(blend-convert.lin_sRGB_to_XYZ(blend-convert.lin_sRGB(blend-convert.sassToRgb($color))), 2) + .05; 67 @return list.nth(blend-convert.lin_sRGB_to_XYZ(blend-convert.lin_sRGB(blend-convert.sassToRgb($color))), 2) + .05;
68} 68}
69 69
70@function palette-old($base-color, $contrasts, $chroma-range: 1, $reference-color: $base-color) {
71 $chroma-range: 1 - $chroma-range;
72
73 $palette: ();
74
75 @if list.nth(list.nth($contrasts, 1), 2) > list.nth(list.nth($contrasts, list.length($contrasts)), 2) {
76 $contrasts: iro.fn-list-reverse($contrasts);
77 }
78
79 $reference-lightness: blend.lightness($reference-color);
80 $i: 0;
81
82 @while $i <= 1 {
83 $l: $i * 200% - 100%;
84 $c: 0%;
85
86 @if $chroma-range != 0 {
87 $c: $i * 2 - 1;
88 $c: if(
89 $reference-lightness >= 50%,
90 math.clamp(0, $c, 1),
91 math.clamp(0, -1 * $c, 1)
92 );
93 $c: $chroma-range * $c * -100%;
94 }
95
96 $palette: list.append($palette, blend.scale($base-color, $l: $l, $c: $c));
97
98 $i: $i + config.$palette-precision;
99 }
100
101 $palette: multi-contrast($base-color, $palette, $contrasts, $reference-color);
102
103 @each $key, $color in $palette {
104 $palette: map.set($palette, #{$key}-text, blend.contrast($color))
105 }
106
107 @return $palette;
108}
109
110@function palette($base-color, $contrasts, $chroma-range: 1, $reference-color: $base-color) { 70@function palette($base-color, $contrasts, $chroma-range: 1, $reference-color: $base-color) {
111 $base-lch: blend-convert.Lab_to_LCH( 71 $base-lch: iro-colors.parse-oklch($base-color);
112 iro-colors.lin_sRGB_to_Oklab( 72 $ref-lch: iro-colors.parse-oklch($reference-color);
113 blend-convert.lin_sRGB( 73 $ref-l: list.nth($ref-lch, 1);
114 blend-convert.sassToRgb($base-color) 74 $ref-y: iro-colors.apca_sRGB_to_Y($reference-color);
115 )
116 )
117 );
118 $ref-lch: blend-convert.Lab_to_LCH(
119 iro-colors.lin_sRGB_to_Oklab(
120 blend-convert.lin_sRGB(
121 blend-convert.sassToRgb($reference-color)
122 )
123 )
124 );
125 $ref-l: list.nth($ref-lch, 1);
126 $ref-y: iro-colors.apca_sRGB_to_Y($reference-color);
127 75
128 $cmax: math.max(map.values($contrasts)...); 76 $cmax: math.max(map.values($contrasts)...);
129 $cmax: math.max($cmax, math.abs(math.min(map.values($contrasts)...))); 77 $cmax: math.max($cmax, math.abs(math.min(map.values($contrasts)...)));
@@ -131,10 +79,10 @@
131 $black-y: iro-colors.apca_sRGB_to_Y(#000); 79 $black-y: iro-colors.apca_sRGB_to_Y(#000);
132 $white-y: iro-colors.apca_sRGB_to_Y(#fff); 80 $white-y: iro-colors.apca_sRGB_to_Y(#fff);
133 81
134 $palette: ();
135
136 $chroma-easing: meta.get-function(config.$palette-chroma-easing, $module: easing); 82 $chroma-easing: meta.get-function(config.$palette-chroma-easing, $module: easing);
137 83
84 $palette: ();
85
138 @each $key, $contrast in $contrasts { 86 @each $key, $contrast in $contrasts {
139 //$i: math.div(list.length($palette), 2 * (list.length($contrasts) - 1)); 87 //$i: math.div(list.length($palette), 2 * (list.length($contrasts) - 1));
140 $y: iro-colors.apcaReverse($contrast, $ref-y); 88 $y: iro-colors.apcaReverse($contrast, $ref-y);