MCPcopy Create free account
hub / github.com/anomalyco/opencode / generateV2HueScale

Function generateV2HueScale

packages/ui/src/theme/v2/resolve.ts:30–56  ·  view source on GitHub ↗

v2 ramps: 100 = lightest, 1200 = darkest — wider spread than v1 `generateScale`.

(seed: HexColor, isDark: boolean)

Source from the content-addressed store, hash-verified

28
29/** v2 ramps: 100 = lightest, 1200 = darkest — wider spread than v1 `generateScale`. */
30function generateV2HueScale(seed: HexColor, isDark: boolean): HexColor[] {
31 const base = hexToOklch(seed)
32 const chromaBoost = isDark ? 1 : 1.05
33 const lightSteps = [
34 0.99,
35 0.965,
36 0.93,
37 0.885,
38 0.835,
39 clamp(base.l, 0.48, 0.72),
40 clamp(base.l - 0.07, 0.4, 0.64),
41 clamp(base.l - 0.14, 0.32, 0.55),
42 clamp(base.l - 0.21, 0.24, 0.46),
43 clamp(base.l - 0.28, 0.17, 0.38),
44 clamp(base.l - 0.34, 0.12, 0.3),
45 clamp(base.l - 0.4, 0.08, 0.22),
46 ]
47 const chromaMultipliers = [0.28, 0.48, 0.68, 0.86, 1.02, 1.28, 1.34, 1.28, 1.18, 1.08, 0.98, 0.88]
48
49 return lightSteps.map((l, i) =>
50 oklchToHex({
51 l,
52 c: base.c * chromaMultipliers[i]! * chromaBoost,
53 h: base.h,
54 }),
55 )
56}
57
58/** Grey ramp: 100 = lightest, 1200 = darkest. Derived from palette neutral → ink like v1. */
59function generateV2NeutralScale(neutral: HexColor, ink: HexColor, isDark: boolean): HexColor[] {

Callers 1

generateV2PrimitivesFunction · 0.85

Calls 3

hexToOklchFunction · 0.90
oklchToHexFunction · 0.90
clampFunction · 0.70

Tested by

no test coverage detected