Skip to content

pantoken / plugins/pantoken/colors/src / darken

Hàm: darken()

darken(color, percent?): string

Beta

Tối đi percent điểm độ sáng HSL — phiên bản chỉ CSS tương đương của ui-color-utils darken (tinycolor giảm độ sáng HSL). Sử dụng cú pháp màu tương đối nên độ hue và độ bão hòa được giữ nguyên.

In relative hsl(), the l channel resolves to a <number> on the 0–100 scale — the same scale tinycolor's amount uses — so the points are subtracted directly (no %).

Tham số

color

string

Màu cơ sở.

percent?

number = 10

Số điểm độ sáng để trừ (mặc định 10, khớp với mặc định của tinycolor).

Trả về

string

Một biểu thức relative-color hsl(from …).

Ví dụ

ts
darken("var(--brand)", 10); // "hsl(from var(--brand) h s calc(l - 10))"