算法艺术创作
algorithmic-art
通过代码和可调参数创作生成艺术与交互式视觉效果。
color-accessibility-and-mode【设计与创意】Use this skill when designing color systems that must satisfy accessibility requirements, work in both light and dark modes, support high-contrast preferences, and remain meaningful for users with color blindness or low vision. Trigger when picking text colors, designing for global compliance (WCAG, EAA, ADA), supporting dark mode, or auditing an exi…
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
color; read that first.'Accessibility-aware color isn't a polish layer; it's a constraint that shapes the palette from the start. Adding accessibility late is much more expensive than building it in. The core constraints: WCAG contrast ratios, color-blindness compatibility, high-contrast mode support, and dark-mode parity.
Required ratios (relative luminance):
| Content | Level AA | Level AAA |
|---|---|---|
| Body text (< 18pt regular or < 14pt bold) | 4.5:1 | 7:1 |
| Large text (≥ 18pt regular or ≥ 14pt bold) | 3:1 | 4.5:1 |
| UI components and graphical objects | 3:1 | (no AAA) |
To check a color pair: any contrast tool (WebAIM, Stark, Chrome DevTools' contrast inspector). If you're picking from a designer's mockup, run every text/background pair through. Common failures:
#999 or #aaa).Practical rule: pick body text colors at neutral-700 or darker on light backgrounds; never use anything lighter than neutral-500 for content the user must read.
Approximate prevalence in populations of European descent:
Other populations have different rates — generally lower red-green prevalence in some Asian populations.
Practical implications:
Dark mode is no longer optional for new products. Macs, iPhones, and Androids all default to dark in some contexts; users expect it.
Common pitfalls:
Inverting a light palette doesn't produce a good dark palette. Saturation perception is different on dark backgrounds; very-saturated colors that read fine on white look glaring on black. Build dark-mode tokens deliberately.
Pure white text on pure black is high-contrast but hard on the eyes and produces strong "halation" (blur) on OLED screens. Most well-tuned dark modes use:
hsl(220 10% 8%).hsl(0 0% 90%) or so.Saturated colors that work on white backgrounds need toning down for dark. A primary brand at hsl(220 90% 50%) may need to be hsl(220 70% 60%) in dark mode to feel comfortable.
A pair that passes AA in light mode may fail in dark mode. The luminance values differ; recheck.
Many operating systems offer a high-contrast mode for low-vision users. Web equivalents:
prefers-contrast: more CSS media queryIn these modes, the user has explicitly requested maximum contrast. Designs should:
@media (prefers-contrast: more) {
:root {
--neutral-700: hsl(0 0% 0%);
--background: hsl(0 0% 100%);
--border: hsl(0 0% 0%);
/* ...etc... */
}
}
Some users (particularly with low vision or migraine sensitivity) override page colors entirely with system colors via Windows' Forced Colors Mode. The browser maps your colors to a small set of system tokens (Canvas, CanvasText, LinkText, ButtonText, ButtonFace, etc.).
In this mode:
Design implications:
<button> for buttons; the system colors map correctly.Color transitions can trigger photosensitive epilepsy if they flash rapidly (3+ Hz, especially with red). WCAG 2.3.1: no content flashes more than 3 times per second.
Design implications:
prefers-reduced-motion.:root {
/* Light mode */
--bg: hsl(0 0% 100%);
--fg: hsl(220 6% 12%); /* near-black; contrast 17:1 on white */
--fg-muted: hsl(220 6% 40%); /* 7.4:1 — passes AA body, AAA large */
--primary: hsl(220 90% 45%); /* 5:1 on white — AA body */
--destructive: hsl(0 75% 40%); /* 5.5:1 on white — AA body */
}
@media (prefers-color-scheme: dark) {
:root {
--bg: hsl(220 10% 9%);
--fg: hsl(220 6% 92%); /* 12:1 on dark */
--fg-muted: hsl(220 6% 65%); /* 5.5:1 — AA body */
--primary: hsl(220 80% 65%); /* tuned brighter for dark mode */
--destructive: hsl(0 70% 60%); /* tuned brighter for dark mode */
}
}
@media (prefers-contrast: more) {
:root {
--fg: hsl(0 0% 0%);
--bg: hsl(0 0% 100%);
--fg-muted: hsl(0 0% 20%);
/* etc. */
}
}
@media (prefers-reduced-motion: reduce) {
*, *::before, *::after {
animation-duration: 0.01ms !important;
transition-duration: 0.01ms !important;
}
}
* or "required." Color-blind users miss it.prefers-contrast and forced-colors. Your design works for typical users but fails for users with explicit accessibility needs.color (parent).color-semantic-systems — building the semantic layer this skill makes accessible.hierarchy-color-and-tone — using tone (not just hue) for hierarchy.accessibility-perceivable (process) — covers color contrast and other perceivable concerns.