@lokiyou/pi-nano-footer 0.8.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.ts +6 -8
- package/package.json +1 -1
package/index.ts
CHANGED
|
@@ -63,11 +63,10 @@ let working = false;
|
|
|
63
63
|
let animInterval: ReturnType<typeof setInterval> | undefined;
|
|
64
64
|
|
|
65
65
|
/**
|
|
66
|
-
* 从 borderColor
|
|
66
|
+
* 从 borderColor 函数采样字符,提取当前 RGB 色值
|
|
67
67
|
*/
|
|
68
68
|
function extractRGB(fn: (str: string) => string): [number, number, number] | null {
|
|
69
69
|
const sample = fn("─");
|
|
70
|
-
// borderColor 输出格式:\x1b[38;2;R;G;Bm─\x1b[0m
|
|
71
70
|
const m = sample.match(ANSI_RE);
|
|
72
71
|
if (!m) return null;
|
|
73
72
|
return [parseInt(m[1]), parseInt(m[2]), parseInt(m[3])];
|
|
@@ -82,12 +81,11 @@ Editor.prototype.render = function (width: number): string[] {
|
|
|
82
81
|
const rgb = extractRGB(saved);
|
|
83
82
|
if (rgb) {
|
|
84
83
|
const [r, g, b] = rgb;
|
|
85
|
-
//
|
|
86
|
-
//
|
|
87
|
-
|
|
88
|
-
const
|
|
89
|
-
const
|
|
90
|
-
const glow = t * t * 0.35; // 0~0.35 白色 blend,t² 让辉光集中在峰值
|
|
84
|
+
// 基于当前边框颜色做呼吸,颜色不变只是明暗+辉光变化
|
|
85
|
+
// 周期 ~800ms,60fps 驱动,非工作→工作无突兀跳变
|
|
86
|
+
const t = 0.5 + 0.5 * Math.sin(performance.now() / 400);
|
|
87
|
+
const bright = 0.25 + 0.75 * t;
|
|
88
|
+
const glow = t * t * 0.35;
|
|
91
89
|
const nr = Math.round(Math.min(255, r * bright + (255 - r) * glow));
|
|
92
90
|
const ng = Math.round(Math.min(255, g * bright + (255 - g) * glow));
|
|
93
91
|
const nb = Math.round(Math.min(255, b * bright + (255 - b) * glow));
|