返回 presentation-ai
smart-layout-gradient.ts
根目录 / src / components / notebook / presentation / editor / custom-elements / smart-layout-gradient.ts
1 const SMART_LAYOUT_COLOR = "var(--presentation-smart-layout)";
2
3 export function getSmartLayoutStepColor(index: number, total: number) {
4 if (total <= 1) {
5 return SMART_LAYOUT_COLOR;
6 }
7
8 const progress = index / (total - 1);
9
10 if (progress < 0.5) {
11 const darken = Math.round((1 - progress / 0.5) * 10);
12 return `color-mix(in srgb, ${SMART_LAYOUT_COLOR} ${100 - darken}%, black ${darken}%)`;
13 }
14
15 if (progress > 0.5) {
16 const lighten = Math.round(((progress - 0.5) / 0.5) * 10);
17 return `color-mix(in srgb, ${SMART_LAYOUT_COLOR} ${100 - lighten}%, white ${lighten}%)`;
18 }
19
20 return SMART_LAYOUT_COLOR;
21 }
22
22 lines TYPESCRIPT