-
Notifications
You must be signed in to change notification settings - Fork 222
/
color.html.md.erb
897 lines (701 loc) · 33.6 KB
/
color.html.md.erb
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
---
title: sass:color
---
<%= partial '../snippets/built-in-module-status' %>
<% function <<SIGNATURE, 'adjust-color(...)', returns: 'color' do
color.adjust($color,
$red: null, $green: null, $blue: null,
$hue: null, $saturation: null, $lightness: null,
$whiteness: null, $blackness: null,
$alpha: null)
SIGNATURE
%>
<% impl_status dart: '1.27.0', libsass: false, ruby: false, feature: "$whiteness and $blackness" %>
Increases or decreases one or more properties of `$color` by fixed amounts.
Adds the value passed for each keyword argument to the corresponding property
of the color, and returns the adjusted color. It's an error to specify an RGB
property (`$red`, `$green`, and/or `$blue`) at the same time as an HSL
property (`$hue`, `$saturation`, and/or `$lightness`), or either of those at
the same time as an [HWB][] property (`$hue`, `$whiteness`, and/or
`$blackness`).
[HWB]: https://en.wikipedia.org/wiki/HWB_color_model
All optional arguments must be numbers. The `$red`, `$green`, and `$blue`
arguments must be [unitless][] and between -255 and 255 (inclusive). The
`$hue` argument must have either the unit `deg` or no unit. The `$saturation`,
`$lightness`, `$whiteness`, and `$blackness` arguments must be between `-100%`
and `100%` (inclusive), and may not be unitless. The `$alpha` argument must be
unitless and between -1 and 1 (inclusive).
[unitless]: ../values/numbers#units
See also:
* [`color.scale()`](#scale) for fluidly scaling a color's properties.
* [`color.change()`](#change) for setting a color's properties.
<% example(autogen_css: false) do %>
@debug color.adjust(#6b717f, $red: 15); // #7a717f
@debug color.adjust(#d2e1dd, $red: -10, $blue: 10); // #c8e1e7
@debug color.adjust(#998099, $lightness: -30%, $alpha: -0.4); // rgba(71, 57, 71, 0.6)
===
@debug color.adjust(#6b717f, $red: 15) // #7a717f
@debug color.adjust(#d2e1dd, $red: -10, $blue: 10) // #c8e1e7
@debug color.adjust(#998099, $lightness: -30%, $alpha: -0.4) // rgba(71, 57, 71, 0.6)
<% end %>
<% end %>
<% function 'adjust-hue($color, $degrees)', returns: 'color' do %>
Increases or decreases `$color`'s hue.
The `$hue` must be a number between `-360deg` and `360deg` (inclusive) to add
to `$color`'s hue. It may be [unitless][] but it may not have any unit other
than `deg`.
[unitless]: ../values/numbers#units
See also [`color.adjust()`](#adjust), which can adjust any property of a
color.
<% heads_up do %>
Because `adjust-hue()` is redundant with [`adjust()`](#adjust), it's not
included directly in the new module system. Instead of
`adjust-hue($color, $amount)`, you can write
[`color.adjust($color, $hue: $amount)`](#adjust).
<% end %>
<% example(autogen_css: false) do %>
// Hue 222deg becomes 282deg.
@debug adjust-hue(#6b717f, 60deg); // #796b7f
// Hue 164deg becomes 104deg.
@debug adjust-hue(#d2e1dd, -60deg); // #d6e1d2
// Hue 210deg becomes 255deg.
@debug adjust-hue(#036, 45); // #1a0066
===
// Hue 222deg becomes 282deg.
@debug adjust-hue(#6b717f, 60deg) // #796b7f
// Hue 164deg becomes 104deg.
@debug adjust-hue(#d2e1dd, -60deg) // #d6e1d2
// Hue 210deg becomes 255deg.
@debug adjust-hue(#036, 45) // #1a0066
<% end %>
<% end %>
<% function 'color.alpha($color)',
'alpha($color)',
'opacity($color)',
returns: 'number' do %>
Returns the alpha channel of `$color` as a number between 0 and 1.
As a special case, this supports the Internet Explorer syntax
`alpha(opacity=20)`, for which it returns an [unquoted string][].
[unquoted string]: ../values/strings#unquoted
See also:
* [`color.red()`](#red) for getting a color's red channel.
* [`color.green()`](#green) for getting a color's green channel.
* [`color.blue()`](#blue) for getting a color's blue channel.
* [`color.hue()`](#hue) for getting a color's hue.
* [`color.saturation()`](#saturation) for getting a color's saturation.
* [`color.lightness()`](#lightness) for getting a color's lightness.
<% example(autogen_css: false) do %>
@debug color.alpha(#e1d7d2); // 1
@debug color.opacity(rgb(210, 225, 221, 0.4)); // 0.4
@debug alpha(opacity=20); // alpha(opacity=20)
===
@debug color.alpha(#e1d7d2) // 1
@debug color.opacity(rgb(210, 225, 221, 0.4)) // 0.4
@debug alpha(opacity=20) // alpha(opacity=20)
<% end %>
<% end %>
<% function 'color.blackness($color)', returns: 'number' do %>
<% impl_status dart: '1.27.0', libsass: false, ruby: false %>
Returns the [HWB][] blackness of `$color` as a number between `0%` and `100%`.
[HWB]: https://en.wikipedia.org/wiki/HWB_color_model
See also:
* [`color.red()`](#red) for getting a color's red channel.
* [`color.green()`](#green) for getting a color's green channel.
* [`color.hue()`](#hue) for getting a color's hue.
* [`color.saturation()`](#saturation) for getting a color's saturation.
* [`color.lightness()`](#lightness) for getting a color's lightness.
* [`color.whiteness()`](#whiteness) for getting a color's whiteness.
* [`color.alpha()`](#alpha) for getting a color's alpha channel.
<% example(autogen_css: false) do %>
@debug color.blackness(#e1d7d2); // 11.7647058824%
@debug color.blackness(white); // 0%
@debug color.blackness(black); // 100%
===
@debug color.blackness(#e1d7d2) // 11.7647058824%
@debug color.blackness(white) // 0%
@debug color.blackness(black) // 100%
<% end %>
<% end %>
<% function 'color.blue($color)', 'blue($color)', returns: 'number' do %>
Returns the blue channel of `$color` as a number between 0 and 255.
See also:
* [`color.red()`](#red) for getting a color's red channel.
* [`color.green()`](#green) for getting a color's green channel.
* [`color.hue()`](#hue) for getting a color's hue.
* [`color.saturation()`](#saturation) for getting a color's saturation.
* [`color.lightness()`](#lightness) for getting a color's lightness.
* [`color.whiteness()`](#whiteness) for getting a color's whiteness.
* [`color.blackness()`](#blackness) for getting a color's blackness.
* [`color.alpha()`](#alpha) for getting a color's alpha channel.
<% example(autogen_css: false) do %>
@debug color.blue(#e1d7d2); // 210
@debug color.blue(white); // 255
@debug color.blue(black); // 0
===
@debug color.blue(#e1d7d2) // 210
@debug color.blue(white) // 255
@debug color.blue(black) // 0
<% end %>
<% end %>
<% function <<SIGNATURE, 'change-color(...)', returns: 'color' do
color.change($color,
$red: null, $green: null, $blue: null,
$hue: null, $saturation: null, $lightness: null,
$whiteness: null, $blackness: null,
$alpha: null)
SIGNATURE
%>
<% impl_status dart: '1.27.0', libsass: false, ruby: false, feature: "$whiteness and $blackness" %>
Sets one or more properties of a color to new values.
Uses the value passed for each keyword argument in place of the corresponding
property of the color, and returns the changed color. It's an error to specify
an RGB property (`$red`, `$green`, and/or `$blue`) at the same time as an HSL
property (`$hue`, `$saturation`, and/or `$lightness`), or either of those at
the same time as an [HWB][] property (`$hue`, `$whiteness`, and/or
`$blackness`).
[HWB]: https://en.wikipedia.org/wiki/HWB_color_model
All optional arguments must be numbers. The `$red`, `$green`, and `$blue`
arguments must be [unitless][] and between 0 and 255 (inclusive). The `$hue`
argument must have either the unit `deg` or no unit. The `$saturation`,
`$lightness`, `$whiteness`, and `$blackness` arguments must be between `0%`
and `100%` (inclusive), and may not be unitless. The `$alpha` argument must be
unitless and between -1 and 1 (inclusive).
[unitless]: ../values/numbers#units
See also:
* [`color.scale()`](#scale) for fluidly scaling a color's properties.
* [`color.adjust()`](#adjust) for adjusting a color's properties by fixed
amounts.
<% example(autogen_css: false) do %>
@debug color.change(#6b717f, $red: 100); // #64717f
@debug color.change(#d2e1dd, $red: 100, $blue: 50); // #64e132
@debug color.change(#998099, $lightness: 30%, $alpha: 0.5); // rgba(85, 68, 85, 0.5)
===
@debug color.change(#6b717f, $red: 100) // #64717f
@debug color.change(#d2e1dd, $red: 100, $blue: 50) // #64e132
@debug color.change(#998099, $lightness: 30%, $alpha: 0.5) // rgba(85, 68, 85, 0.5)
<% end %>
<% end %>
<% function 'color.complement($color)',
'complement($color)',
returns: 'color' do %>
Returns the RGB [complement][] of `$color`.
This is identical to [`color.adjust($color, $hue: 180deg)`](#adjust).
[complement]: https://en.wikipedia.org/wiki/Complementary_colors
<% example(autogen_css: false) do %>
// Hue 222deg becomes 42deg.
@debug color.complement(#6b717f); // #7f796b
// Hue 164deg becomes 344deg.
@debug color.complement(#d2e1dd); // #e1d2d6
// Hue 210deg becomes 30deg.
@debug color.complement(#036); // #663300
===
// Hue 222deg becomes 42deg.
@debug color.complement(#6b717f) // #7f796b
// Hue 164deg becomes 344deg.
@debug color.complement(#d2e1dd) // #e1d2d6
// Hue 210deg becomes 30deg.
@debug color.complement(#036) // #663300
<% end %>
<% end %>
<% function 'darken($color, $amount)', returns: 'color' do %>
Makes `$color` darker.
The `$amount` must be a number between `0%` and `100%` (inclusive). Decreases
the HSL lightness of `$color` by that amount.
<% heads_up do %>
The `darken()` function decreases lightness by a fixed amount, which is often
not the desired effect. To make a color a certain percentage darker than it was
before, use [`color.scale()`](#scale) instead.
Because `darken()` is usually not the best way to make a color darker, it's
not included directly in the new module system. However, if you have to
preserve the existing behavior, `darken($color, $amount)` can be written
[`color.adjust($color, $lightness: -$amount)`](#adjust).
<% example(autogen_css: false) do %>
// #036 has lightness 20%, so when darken() subtracts 30% it just returns black.
@debug darken(#036, 30%); // black
// scale() instead makes it 30% darker than it was originally.
@debug color.scale(#036, $lightness: -30%); // #002447
===
// #036 has lightness 20%, so when darken() subtracts 30% it just returns black.
@debug darken(#036, 30%) // black
// scale() instead makes it 30% darker than it was originally.
@debug color.scale(#036, $lightness: -30%) // #002447
<% end %>
<% end %>
<% example(autogen_css: false) do %>
// Lightness 92% becomes 72%.
@debug darken(#b37399, 20%); // #7c4465
// Lightness 85% becomes 45%.
@debug darken(#f2ece4, 40%); // #b08b5a
// Lightness 20% becomes 0%.
@debug darken(#036, 30%); // black
===
// Lightness 92% becomes 72%.
@debug darken(#b37399, 20%) // #7c4465
// Lightness 85% becomes 45%.
@debug darken(#f2ece4, 40%) // #b08b5a
// Lightness 20% becomes 0%.
@debug darken(#036, 30%) // black
<% end %>
<% end %>
<% function 'desaturate($color, $amount)', returns: 'color' do %>
Makes `$color` less saturated.
The `$amount` must be a number between `0%` and `100%` (inclusive). Decreases
the HSL saturation of `$color` by that amount.
<% heads_up do %>
The `desaturate()` function decreases saturation by a fixed amount, which is
often not the desired effect. To make a color a certain percentage less
saturated than it was before, use [`color.scale()`](#scale) instead.
Because `desaturate()` is usually not the best way to make a color less
saturated, it's not included directly in the new module system. However, if
you have to preserve the existing behavior, `desaturate($color, $amount)`
can be written [`color.adjust($color, $saturation: -$amount)`](#adjust).
<% example(autogen_css: false) do %>
// #d2e1dd has saturation 20%, so when desaturate() subtracts 30% it just
// returns gray.
@debug desaturate(#d2e1dd, 30%); // #dadada
// scale() instead makes it 30% less saturated than it was originally.
@debug color.scale(#6b717f, $saturation: -30%); // #6e727c
===
// #6b717f has saturation 20%, so when desaturate() subtracts 30% it just
// returns gray.
@debug desaturate(#d2e1dd, 30%) // #dadada
// scale() instead makes it 30% less saturated than it was originally.
@debug color.scale(#6b717f, $saturation: -30%) // #6e727c
<% end %>
<% end %>
<% example(autogen_css: false) do %>
// Saturation 100% becomes 80%.
@debug desaturate(#036, 20%); // #0a335c
// Saturation 35% becomes 15%.
@debug desaturate(#f2ece4, 20%); // #eeebe8
// Saturation 20% becomes 0%.
@debug desaturate(#d2e1dd, 30%); // #dadada
===
// Saturation 100% becomes 80%.
@debug desaturate(#036, 20%) // #0a335c
// Saturation 35% becomes 15%.
@debug desaturate(#f2ece4, 20%) // #eeebe8
// Saturation 20% becomes 0%.
@debug desaturate(#d2e1dd, 30%) // #dadada
<% end %>
<% end %>
<% function 'color.grayscale($color)',
'grayscale($color)',
returns: 'color' do %>
Returns a gray color with the same lightness as `$color`.
This is identical to [`color.change($color, $saturation: 0%)`](#change).
<% example(autogen_css: false) do %>
@debug color.grayscale(#6b717f); // #757575
@debug color.grayscale(#d2e1dd); // #dadada
@debug color.grayscale(#036); // #333333
===
@debug color.grayscale(#6b717f) // #757575
@debug color.grayscale(#d2e1dd) // #dadada
@debug color.grayscale(#036) // #333333
<% end %>
<% end %>
<% function 'color.green($color)', 'green($color)', returns: 'number' do %>
Returns the green channel of `$color` as a number between 0 and 255.
See also:
* [`color.red()`](#red) for getting a color's red channel.
* [`color.blue()`](#blue) for getting a color's blue channel.
* [`color.hue()`](#hue) for getting a color's hue.
* [`color.saturation()`](#saturation) for getting a color's saturation.
* [`color.lightness()`](#lightness) for getting a color's lightness.
* [`color.whiteness()`](#whiteness) for getting a color's whiteness.
* [`color.blackness()`](#blackness) for getting a color's blackness.
* [`color.alpha()`](#alpha) for getting a color's alpha channel.
<% example(autogen_css: false) do %>
@debug color.green(#e1d7d2); // 215
@debug color.green(white); // 255
@debug color.green(black); // 0
===
@debug color.green(#e1d7d2) // 215
@debug color.green(white) // 255
@debug color.green(black) // 0
<% end %>
<% end %>
<% function 'color.hue($color)', 'hue($color)', returns: 'number' do %>
Returns the hue of `$color` as a number between `0deg` and `360deg`.
See also:
* [`color.red()`](#red) for getting a color's red channel.
* [`color.green()`](#green) for getting a color's green channel.
* [`color.blue()`](#blue) for getting a color's blue channel.
* [`color.saturation()`](#saturation) for getting a color's saturation.
* [`color.lightness()`](#lightness) for getting a color's lightness.
* [`color.whiteness()`](#whiteness) for getting a color's whiteness.
* [`color.blackness()`](#blackness) for getting a color's blackness.
* [`color.alpha()`](#alpha) for getting a color's alpha channel.
<% example(autogen_css: false) do %>
@debug color.hue(#e1d7d2); // 20deg
@debug color.hue(#f2ece4); // 34.2857142857deg
@debug color.hue(#dadbdf); // 228deg
===
@debug color.hue(#e1d7d2) // 20deg
@debug color.hue(#f2ece4) // 34.2857142857deg
@debug color.hue(#dadbdf) // 228deg
<% end %>
<% end %>
<% function 'color.hwb($hue $whiteness $blackness)',
'color.hwb($hue $whiteness $blackness / $alpha)',
'color.hwb($hue, $whiteness, $blackness, $alpha: 1)', returns: 'color' do %>
<% impl_status dart: '1.27.0', libsass: false, ruby: false %>
Returns a color with the given [hue, whiteness, and blackness][] and the given
alpha channel.
[hue, whiteness, and blackness]: https://en.wikipedia.org/wiki/HWB_color_model
The hue is a number between `0deg` and `360deg` (inclusive). The whiteness and
blackness are numbers between `0%` and `100%` (inclusive). The hue may be
[unitless][], but the whiteness and blackness must have unit `%`. The alpha
channel can be specified as either a unitless number between 0 and 1
(inclusive), or a percentage between `0%` and `100%` (inclusive).
[unitless]: ../values/numbers#units
<% heads_up do %>
Sass's [special parsing rules][] for slash-separated values make it
difficult to pass variables for `$blackness` or `$alpha` when using the
`color.hwb($hue $whiteness $blackness / $alpha)` signature. Consider using
`color.hwb($hue, $whiteness, $blackness, $alpha)` instead.
[special parsing rules]: ../operators/numeric#slash-separated-values
<% end %>
<% example(autogen_css: false) do %>
@debug color.hwb(210, 0%, 60%); // #036
@debug color.hwb(34, 89%, 5%); // #f2ece4
@debug color.hwb(210 0% 60% / 0.5); // rgba(0, 51, 102, 0.5)
===
@debug color.hwb(210, 0%, 60%) // #036
@debug color.hwb(34, 89%, 5%) // #f2ece4
@debug color.hwb(210 0% 60% / 0.5) // rgba(0, 51, 102, 0.5)
<% end %>
<% end %>
<% function 'color.ie-hex-str($color)',
'ie-hex-str($color)',
returns: 'unquoted string' do %>
Returns an unquoted string that represents `$color` in the `#AARRGGBB` format
expected by Internet Explorer's [`-ms-filter`][] property.
[`-ms-filter`]: https://developer.mozilla.org/en-US/docs/Web/CSS/-ms-filter
<% example(autogen_css: false) do %>
@debug color.ie-hex-str(#b37399); // #FFB37399
@debug color.ie-hex-str(#808c99); // #FF808C99
@debug color.ie-hex-str(rgba(242, 236, 228, 0.6)); // #99F2ECE4
===
@debug color.ie-hex-str(#b37399); // #FFB37399
@debug color.ie-hex-str(#808c99); // #FF808C99
@debug color.ie-hex-str(rgba(242, 236, 228, 0.6)); // #99F2ECE4
<% end %>
<% end %>
<% function 'color.invert($color, $weight: 100%)',
'invert($color, $weight: 100%)',
returns: 'color' do %>
Returns the inverse or [negative][] of `$color`.
[negative]: https://en.wikipedia.org/wiki/Negative_(photography)
The `$weight` must be a number between `0%` and `100%` (inclusive). A higher
weight means the result will be closer to the negative, and a lower weight means
it will be closer to `$color`. Weight `50%` will always produce `#808080`.
<% example(autogen_css: false) do %>
@debug color.invert(#b37399); // #4c8c66
@debug color.invert(black); // white
@debug color.invert(#550e0c, 20%); // #663b3a
===
@debug color.invert(#b37399) // #4c8c66
@debug color.invert(black) // white
@debug color.invert(#550e0c, 20%) // #663b3a
<% end %>
<% end %>
<% function 'lighten($color, $amount)', returns: 'color' do %>
Makes `$color` lighter.
The `$amount` must be a number between `0%` and `100%` (inclusive). Increases
the HSL lightness of `$color` by that amount.
<% heads_up do %>
The `lighten()` function increases lightness by a fixed amount, which is often
not the desired effect. To make a color a certain percentage lighter than it was
before, use [`scale()`](#scale) instead.
Because `lighten()` is usually not the best way to make a color lighter,
it's not included directly in the new module system. However, if you have to
preserve the existing behavior, `lighten($color, $amount)` can be written
[`adjust($color, $lightness: $amount)`](#adjust).
<% example(autogen_css: false) do %>
// #e1d7d2 has lightness 85%, so when lighten() adds 30% it just returns white.
@debug lighten(#e1d7d2, 30%); // white
// scale() instead makes it 30% lighter than it was originally.
@debug color.scale(#e1d7d2, $lightness: 30%); // #eae3e0
===
// #e1d7d2 has lightness 85%, so when lighten() adds 30% it just returns white.
@debug lighten(#e1d7d2, 30%) // white
// scale() instead makes it 30% lighter than it was originally.
@debug color.scale(#e1d7d2, $lightness: 30%) // #eae3e0
<% end %>
<% end %>
<% example(autogen_css: false) do %>
// Lightness 46% becomes 66%.
@debug lighten(#6b717f, 20%); // #a1a5af
// Lightness 20% becomes 80%.
@debug lighten(#036, 60%); // #99ccff
// Lightness 85% becomes 100%.
@debug lighten(#e1d7d2, 30%); // white
===
// Lightness 46% becomes 66%.
@debug lighten(#6b717f, 20%) // #a1a5af
// Lightness 20% becomes 80%.
@debug lighten(#036, 60%) // #99ccff
// Lightness 85% becomes 100%.
@debug lighten(#e1d7d2, 30%) // white
<% end %>
<% end %>
<% function 'color.lightness($color)',
'lightness($color)',
returns: 'number' do %>
Returns the HSL lightness of `$color` as a number between `0%` and `100%`.
See also:
* [`color.red()`](#red) for getting a color's red channel.
* [`color.green()`](#green) for getting a color's green channel.
* [`color.blue()`](#blue) for getting a color's blue channel.
* [`color.hue()`](#hue) for getting a color's hue.
* [`color.saturation()`](#saturation) for getting a color's saturation.
* [`color.whiteness()`](#whiteness) for getting a color's whiteness.
* [`color.blackness()`](#blackness) for getting a color's blackness.
* [`color.alpha()`](#alpha) for getting a color's alpha channel.
<% example(autogen_css: false) do %>
@debug color.lightness(#e1d7d2); // 85.2941176471%
@debug color.lightness(#f2ece4); // 92.1568627451%
@debug color.lightness(#dadbdf); // 86.4705882353%
===
@debug color.lightness(#e1d7d2) // 85.2941176471%
@debug color.lightness(#f2ece4) // 92.1568627451%
@debug color.lightness(#dadbdf) // 86.4705882353%
<% end %>
<% end %>
<% function 'color.mix($color1, $color2, $weight: 50%)',
'mix($color1, $color2, $weight: 50%)',
returns: 'color' do %>
Returns a number that's a mixture of `$color1` and `$color2`.
Both the `$weight` and the relative opacity of each color determines how much of
each color is in the result. The `$weight` must be a number between `0%` and
`100%` (inclusive). A larger weight indicates that more of `$color1` should be
used, and a smaller weight indicates that more of `$color2` should be used.
<% example(autogen_css: false) do %>
@debug color.mix(#036, #d2e1dd); // #698aa2
@debug color.mix(#036, #d2e1dd, 75%); // #355f84
@debug color.mix(#036, #d2e1dd, 25%); // #9eb6bf
@debug color.mix(rgba(242, 236, 228, 0.5), #6b717f); // rgba(141, 144, 152, 0.75)
===
@debug color.mix(#036, #d2e1dd) // #698aa2
@debug color.mix(#036, #d2e1dd, 75%) // #355f84
@debug color.mix(#036, #d2e1dd, 25%) // #9eb6bf
@debug color.mix(rgba(242, 236, 228, 0.5), #6b717f) // rgba(141, 144, 152, 0.75)
<% end %>
<% end %>
<% function 'opacify($color, $amount)', 'fade-in($color, $amount)', returns: 'color' do %>
Makes `$color` more opaque.
The `$amount` must be a number between `0` and `1` (inclusive). Increases the
alpha channel of `$color` by that amount.
<% heads_up do %>
The `opacify()` function increases the alpha channel by a fixed amount, which is often
not the desired effect. To make a color a certain percentage more opaque than it was
before, use [`scale()`](#scale) instead.
Because `opacify()` is usually not the best way to make a color more opaque,
it's not included directly in the new module system. However, if you have to
preserve the existing behavior, `opacify($color, $amount)` can be written
[`adjust($color, $alpha: -$amount)`](#adjust).
<% example(autogen_css: false) do %>
// rgba(#036, 0.7) has alpha 0.7, so when opacify() adds 0.3 it returns a fully
// opaque color.
@debug opacify(rgba(#036, 0.7), 0.3); // #036
// scale() instead makes it 30% more opaque than it was originally.
@debug color.scale(rgba(#036, 0.7), $alpha: 30%); // rgba(0, 51, 102, 0.79)
===
// rgba(#036, 0.7) has alpha 0.7, so when opacify() adds 0.3 it returns a fully
// opaque color.
@debug opacify(rgba(#036, 0.7), 0.3) // #036
// scale() instead makes it 30% more opaque than it was originally.
@debug color.scale(rgba(#036, 0.7), $alpha: 30%) // rgba(0, 51, 102, 0.79)
<% end %>
<% end %>
<% example(autogen_css: false) do %>
@debug opacify(rgba(#6b717f, 0.5), 0.2); // rgba(107, 113, 127, 0.7)
@debug fade-in(rgba(#e1d7d2, 0.5), 0.4); // rgba(225, 215, 210, 0.9)
@debug opacify(rgba(#036, 0.7), 0.3); // #036
===
@debug opacify(rgba(#6b717f, 0.5), 0.2) // rgba(107, 113, 127, 0.7)
@debug fade-in(rgba(#e1d7d2, 0.5), 0.4) // rgba(225, 215, 210, 0.9)
@debug opacify(rgba(#036, 0.7), 0.3) // #036
<% end %>
<% end %>
<% function 'color.red($color)', 'red($color)', returns: 'number' do %>
Returns the red channel of `$color` as a number between 0 and 255.
See also:
* [`color.green()`](#green) for getting a color's green channel.
* [`color.blue()`](#blue) for getting a color's blue channel.
* [`color.hue()`](#hue) for getting a color's hue.
* [`color.saturation()`](#saturation) for getting a color's saturation.
* [`color.lightness()`](#lightness) for getting a color's lightness.
* [`color.whiteness()`](#whiteness) for getting a color's whiteness.
* [`color.blackness()`](#blackness) for getting a color's blackness.
* [`color.alpha()`](#alpha) for getting a color's alpha channel.
<% example(autogen_css: false) do %>
@debug color.red(#e1d7d2); // 225
@debug color.red(white); // 255
@debug color.red(black); // 0
===
@debug color.red(#e1d7d2) // 225
@debug color.red(white) // 255
@debug color.red(black) // 0
<% end %>
<% end %>
<% function 'saturate($color, $amount)', 'saturate($color, $amount)', returns: 'color' do %>
Makes `$color` more saturated.
The `$amount` must be a number between `0%` and `100%` (inclusive). Increases
the HSL saturation of `$color` by that amount.
<% heads_up do %>
The `saturate()` function increases saturation by a fixed amount, which is often
not the desired effect. To make a color a certain percentage more saturated than
it was before, use [`scale()`](#scale) instead.
Because `saturate()` is usually not the best way to make a color more
saturated, it's not included directly in the new module system. However, if
you have to preserve the existing behavior, `saturate($color, $amount)` can
be written [`adjust($color, $saturation: $amount)`](#adjust).
<% example(autogen_css: false) do %>
// #0e4982 has saturation 80%, so when saturate() adds 30% it just becomes
// fully saturated.
@debug saturate(#0e4982, 30%); // #004990
// scale() instead makes it 30% more saturated than it was originally.
@debug color.scale(#0e4982, $saturation: 30%); // #0a4986
===
// #0e4982 has saturation 80%, so when saturate() adds 30% it just becomes
// fully saturated.
@debug saturate(#0e4982, 30%) // #004990
// scale() instead makes it 30% more saturated than it was originally.
@debug color.scale(#0e4982, $saturation: 30%) // #0a4986
<% end %>
<% end %>
<% example(autogen_css: false) do %>
// Saturation 50% becomes 70%.
@debug saturate(#c69, 20%); // #e05299
// Saturation 35% becomes 85%.
@debug desaturate(#f2ece4, 50%); // #ebebeb
// Saturation 80% becomes 100%.
@debug saturate(#0e4982, 30%) // #004990
===
// Saturation 50% becomes 70%.
@debug saturate(#c69, 20%); // #e05299
// Saturation 35% becomes 85%.
@debug desaturate(#f2ece4, 50%); // #ebebeb
// Saturation 80% becomes 100%.
@debug saturate(#0e4982, 30%) // #004990
<% end %>
<% end %>
<% function 'color.saturation($color)',
'saturation($color)',
returns: 'number' do %>
Returns the HSL saturation of `$color` as a number between `0%` and `100%`.
See also:
* [`color.red()`](#red) for getting a color's red channel.
* [`color.green()`](#green) for getting a color's green channel.
* [`color.blue()`](#blue) for getting a color's blue channel.
* [`color.hue()`](#hue) for getting a color's hue.
* [`color.lightness()`](#lightness) for getting a color's lightness.
* [`color.whiteness()`](#whiteness) for getting a color's whiteness.
* [`color.blackness()`](#blackness) for getting a color's blackness.
* [`color.alpha()`](#alpha) for getting a color's alpha channel.
<% example(autogen_css: false) do %>
@debug color.saturation(#e1d7d2); // 20%
@debug color.saturation(#f2ece4); // 30%
@debug color.saturation(#dadbdf); // 7.2463768116%
===
@debug color.saturation(#e1d7d2) // 20%
@debug color.saturation(#f2ece4) // 30%
@debug color.saturation(#dadbdf) // 7.2463768116%
<% end %>
<% end %>
<% function <<SIGNATURE, 'scale-color(...)', returns: 'color' do
color.scale($color,
$red: null, $green: null, $blue: null,
$saturation: null, $lightness: null,
$whiteness: null, $blackness: null,
$alpha: null)
SIGNATURE
%>
<% impl_status dart: '1.27.0', libsass: false, ruby: false, feature: "$whiteness and $blackness" %>
Fluidly scales one or more properties of `$color`.
Each keyword argument must be a number between `-100%` and `100%` (inclusive).
This indicates how far the corresponding property should be moved from its
original position towards the maximum (if the argument is positive) or the
minimum (if the argument is negative). This means that, for example,
`$lightness: 50%` will make all colors `50%` closer to maximum lightness
without making them fully white.
It's an error to specify an RGB property (`$red`, `$green`, and/or `$blue`) at
the same time as an HSL property (`$saturation`, and/or `$lightness`), or
either of those at the same time as an [HWB][] property (`$whiteness`, and/or
`$blackness`).
[HWB]: https://en.wikipedia.org/wiki/HWB_color_model
See also:
* [`color.adjust()`](#adjust) for changing a color's properties by fixed
amounts.
* [`color.change()`](#change) for setting a color's properties.
<% example(autogen_css: false) do %>
@debug color.scale(#6b717f, $red: 15%); // #81717f
@debug color.scale(#d2e1dd, $lightness: -10%, $saturation: 10%); // #b3d4cb
@debug color.scale(#998099, $alpha: -40%); // rgba(153, 128, 153, 0.6)
===
@debug color.scale(#6b717f, $red: 15%) // #81717f
@debug color.scale(#d2e1dd, $lightness: -10%, $saturation: 10%) // #b3d4cb
@debug color.scale(#998099, $alpha: -40%) // rgba(153, 128, 153, 0.6)
<% end %>
<% end %>
<% function 'transparentize($color, $amount)', 'fade-out($color, $amount)', returns: 'color' do %>
Makes `$color` more transparent.
The `$amount` must be a number between `0` and `1` (inclusive). Decreases the
alpha channel of `$color` by that amount.
<% heads_up do %>
The `transparentize()` function decreases the alpha channel by a fixed amount,
which is often not the desired effect. To make a color a certain percentage more
transparent than it was before, use [`color.scale()`](#scale) instead.
Because `transparentize()` is usually not the best way to make a color more
transparent, it's not included directly in the new module system. However,
if you have to preserve the existing behavior,
`transparentize($color, $amount)` can be written
[`color.adjust($color, $alpha: -$amount)`](#adjust).
<% example(autogen_css: false) do %>
// rgba(#036, 0.3) has alpha 0.3, so when transparentize() subtracts 0.3 it
// returns a fully transparent color.
@debug transparentize(rgba(#036, 0.3), 0.3); // rgba(0, 51, 102, 0)
// scale() instead makes it 30% more transparent than it was originally.
@debug color.scale(rgba(#036, 0.3), $alpha: -30%); // rgba(0, 51, 102, 0.21)
===
// rgba(#036, 0.3) has alpha 0.3, so when transparentize() subtracts 0.3 it
// returns a fully transparent color.
@debug transparentize(rgba(#036, 0.3), 0.3) // rgba(0, 51, 102, 0)
// scale() instead makes it 30% more transparent than it was originally.
@debug color.scale(rgba(#036, 0.3), $alpha: -30%) // rgba(0, 51, 102, 0.21)
<% end %>
<% end %>
<% example(autogen_css: false) do %>
@debug transparentize(rgba(#6b717f, 0.5), 0.2) // rgba(107, 113, 127, 0.3)
@debug fade-out(rgba(#e1d7d2, 0.5), 0.4) // rgba(225, 215, 210, 0.1)
@debug transparentize(rgba(#036, 0.3), 0.3) // rgba(0, 51, 102, 0)
===
@debug transparentize(rgba(#6b717f, 0.5), 0.2) // rgba(107, 113, 127, 0.3)
@debug fade-out(rgba(#e1d7d2, 0.5), 0.4) // rgba(225, 215, 210, 0.1)
@debug transparentize(rgba(#036, 0.3), 0.3) // rgba(0, 51, 102, 0)
<% end %>
<% end %>
<% function 'color.whiteness($color)', returns: 'number' do %>
<% impl_status dart: '1.27.0', libsass: false, ruby: false %>
Returns the [HWB][] whiteness of `$color` as a number between `0%` and `100%`.
[HWB]: https://en.wikipedia.org/wiki/HWB_color_model
See also:
* [`color.red()`](#red) for getting a color's red channel.
* [`color.green()`](#green) for getting a color's green channel.
* [`color.hue()`](#hue) for getting a color's hue.
* [`color.saturation()`](#saturation) for getting a color's saturation.
* [`color.lightness()`](#lightness) for getting a color's lightness.
* [`color.blackness()`](#blackness) for getting a color's blackness.
* [`color.alpha()`](#alpha) for getting a color's alpha channel.
<% example(autogen_css: false) do %>
@debug color.whiteness(#e1d7d2); // 82.3529411765%
@debug color.whiteness(white); // 100%
@debug color.whiteness(black); // 0%
===
@debug color.whiteness(#e1d7d2) // 82.3529411765%
@debug color.whiteness(white) // 100%
@debug color.whiteness(black) // 0%
<% end %>
<% end %>