Skip to content

pantoken / plugins/pantoken/colors/src / darken

ฟังก์ชัน: darken()

darken(color, percent?): string

เบต้า

ทำให้มืดลงโดย percent จุดความสว่าง HSL — ภาพสะท้อนเฉพาะ CSS ของ ui-color-utils darken (tinycolor ลดความสว่าง HSL). ใช้ไวยากรณ์สีเชิงสัมพันธ์เพื่อให้ hue และ saturation ถูกเก็บไว้.

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 %).

พารามิเตอร์

color

string

สีพื้นฐาน.

percent?

number = 10

จำนวนจุดความสว่างที่จะลบ (ค่าเริ่มต้น 10 ซึ่งตรงกับค่าเริ่มต้นของ tinycolor).

คืนค่า

string

นิพจน์สีเชิงสัมพันธ์ hsl(from …).

ตัวอย่าง

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