@sarmal/core 0.27.0 → 0.28.1
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/dist/auto-init.cjs +106 -145
- package/dist/auto-init.js +105 -144
- package/dist/cli.js +103 -145
- package/dist/cli.js.map +1 -1
- package/dist/curves/artemis2.cjs +10 -16
- package/dist/curves/artemis2.d.cts +1 -1
- package/dist/curves/artemis2.d.ts +1 -1
- package/dist/curves/artemis2.js +9 -15
- package/dist/curves/astroid.cjs +4 -4
- package/dist/curves/astroid.d.cts +1 -1
- package/dist/curves/astroid.d.ts +1 -1
- package/dist/curves/astroid.js +3 -3
- package/dist/curves/deltoid.cjs +4 -4
- package/dist/curves/deltoid.d.cts +1 -1
- package/dist/curves/deltoid.d.ts +1 -1
- package/dist/curves/deltoid.js +3 -3
- package/dist/curves/epicycloid3.cjs +4 -4
- package/dist/curves/epicycloid3.d.cts +1 -1
- package/dist/curves/epicycloid3.d.ts +1 -1
- package/dist/curves/epicycloid3.js +3 -3
- package/dist/curves/epitrochoid7.cjs +5 -5
- package/dist/curves/epitrochoid7.d.cts +1 -1
- package/dist/curves/epitrochoid7.d.ts +1 -1
- package/dist/curves/epitrochoid7.js +4 -4
- package/dist/curves/index.cjs +43 -59
- package/dist/curves/index.d.cts +29 -29
- package/dist/curves/index.d.ts +29 -29
- package/dist/curves/index.js +43 -75
- package/dist/curves/lame.cjs +5 -6
- package/dist/curves/lame.d.cts +1 -1
- package/dist/curves/lame.d.ts +1 -1
- package/dist/curves/lame.js +4 -5
- package/dist/curves/lissajous32.cjs +4 -4
- package/dist/curves/lissajous32.d.cts +1 -1
- package/dist/curves/lissajous32.d.ts +1 -1
- package/dist/curves/lissajous32.js +3 -3
- package/dist/curves/lissajous43.cjs +4 -4
- package/dist/curves/lissajous43.d.cts +1 -1
- package/dist/curves/lissajous43.d.ts +1 -1
- package/dist/curves/lissajous43.js +3 -3
- package/dist/curves/rose3.cjs +4 -4
- package/dist/curves/rose3.d.cts +1 -1
- package/dist/curves/rose3.d.ts +1 -1
- package/dist/curves/rose3.js +3 -3
- package/dist/curves/rose5.cjs +4 -4
- package/dist/curves/rose5.d.cts +1 -1
- package/dist/curves/rose5.d.ts +1 -1
- package/dist/curves/rose5.js +3 -3
- package/dist/curves/rose52.cjs +5 -5
- package/dist/curves/rose52.d.cts +1 -1
- package/dist/curves/rose52.d.ts +1 -1
- package/dist/curves/rose52.js +4 -4
- package/dist/curves/star.cjs +5 -8
- package/dist/curves/star.d.cts +1 -1
- package/dist/curves/star.d.ts +1 -1
- package/dist/curves/star.js +4 -7
- package/dist/curves/star4.cjs +5 -8
- package/dist/curves/star4.d.cts +1 -1
- package/dist/curves/star4.d.ts +1 -1
- package/dist/curves/star4.js +4 -7
- package/dist/curves/star7.cjs +5 -8
- package/dist/curves/star7.d.cts +1 -1
- package/dist/curves/star7.d.ts +1 -1
- package/dist/curves/star7.js +4 -7
- package/dist/index.cjs +94 -131
- package/dist/index.d.cts +30 -78
- package/dist/index.d.ts +30 -78
- package/dist/index.js +94 -152
- package/dist/renderer-shared-OR--cv-t.d.ts +15 -26
- package/dist/renderer-shared-jqw_Q1WO.d.cts +15 -26
- package/dist/terminal.cjs +52 -75
- package/dist/terminal.cjs.map +1 -1
- package/dist/terminal.d.cts +14 -31
- package/dist/terminal.d.ts +14 -31
- package/dist/terminal.js +51 -74
- package/dist/terminal.js.map +1 -1
- package/dist/types-zbxUgcmZ.d.cts +266 -280
- package/dist/types-zbxUgcmZ.d.ts +266 -280
- package/package.json +9 -3
- package/skills/core/SKILL.md +151 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { P as Point } from
|
|
1
|
+
import { P as Point } from './types-zbxUgcmZ.js';
|
|
2
2
|
|
|
3
3
|
interface BoundaryResult {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
scale: number;
|
|
5
|
+
offsetX: number;
|
|
6
|
+
offsetY: number;
|
|
7
7
|
}
|
|
8
8
|
/**
|
|
9
9
|
* Computes how to map engine coordinates into a viewport of the given logical size.
|
|
@@ -14,36 +14,25 @@ interface BoundaryResult {
|
|
|
14
14
|
* `minPaddingPx` defaults to `FIT_PADDING_MIN` (4px) for pixel-space callers.
|
|
15
15
|
* Pass `0` when the logical space is itself a normalized viewBox (e.g. SVG export).
|
|
16
16
|
*/
|
|
17
|
-
declare function computeBoundaries(
|
|
18
|
-
pts: Point[],
|
|
19
|
-
logicalWidth: number,
|
|
20
|
-
logicalHeight: number,
|
|
21
|
-
minPaddingPx?: number,
|
|
22
|
-
): BoundaryResult | null;
|
|
17
|
+
declare function computeBoundaries(pts: Point[], logicalWidth: number, logicalHeight: number, minPaddingPx?: number): BoundaryResult | null;
|
|
23
18
|
/**
|
|
24
19
|
* Can be passed directly to `trailColor`,
|
|
25
20
|
* or can be mixed/sliced before passing as a prop.
|
|
26
21
|
*/
|
|
27
22
|
declare const palettes: {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
23
|
+
readonly bard: ["#a855f7", "#3b82f6", "#14b8a6", "#ec4899"];
|
|
24
|
+
readonly sunset: ["#f97316", "#dc2626", "#9333ea", "#f472b6"];
|
|
25
|
+
readonly ocean: ["#1e3a8a", "#06b6d4", "#22d3ee", "#e0f2fe"];
|
|
26
|
+
readonly ice: ["#1e3a8a", "#67e8f9"];
|
|
27
|
+
readonly fire: ["#7f1d1d", "#fbbf24"];
|
|
28
|
+
readonly forest: ["#14532d", "#86efac"];
|
|
34
29
|
};
|
|
35
30
|
type SarmalPalette = keyof typeof palettes;
|
|
36
31
|
/** RGB color components */
|
|
37
32
|
interface Rgb {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
33
|
+
r: number;
|
|
34
|
+
g: number;
|
|
35
|
+
b: number;
|
|
41
36
|
}
|
|
42
37
|
|
|
43
|
-
export {
|
|
44
|
-
type BoundaryResult as B,
|
|
45
|
-
type Rgb as R,
|
|
46
|
-
type SarmalPalette as S,
|
|
47
|
-
computeBoundaries as c,
|
|
48
|
-
palettes as p,
|
|
49
|
-
};
|
|
38
|
+
export { type BoundaryResult as B, type Rgb as R, type SarmalPalette as S, computeBoundaries as c, palettes as p };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { P as Point } from
|
|
1
|
+
import { P as Point } from './types-zbxUgcmZ.cjs';
|
|
2
2
|
|
|
3
3
|
interface BoundaryResult {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
scale: number;
|
|
5
|
+
offsetX: number;
|
|
6
|
+
offsetY: number;
|
|
7
7
|
}
|
|
8
8
|
/**
|
|
9
9
|
* Computes how to map engine coordinates into a viewport of the given logical size.
|
|
@@ -14,36 +14,25 @@ interface BoundaryResult {
|
|
|
14
14
|
* `minPaddingPx` defaults to `FIT_PADDING_MIN` (4px) for pixel-space callers.
|
|
15
15
|
* Pass `0` when the logical space is itself a normalized viewBox (e.g. SVG export).
|
|
16
16
|
*/
|
|
17
|
-
declare function computeBoundaries(
|
|
18
|
-
pts: Point[],
|
|
19
|
-
logicalWidth: number,
|
|
20
|
-
logicalHeight: number,
|
|
21
|
-
minPaddingPx?: number,
|
|
22
|
-
): BoundaryResult | null;
|
|
17
|
+
declare function computeBoundaries(pts: Point[], logicalWidth: number, logicalHeight: number, minPaddingPx?: number): BoundaryResult | null;
|
|
23
18
|
/**
|
|
24
19
|
* Can be passed directly to `trailColor`,
|
|
25
20
|
* or can be mixed/sliced before passing as a prop.
|
|
26
21
|
*/
|
|
27
22
|
declare const palettes: {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
23
|
+
readonly bard: ["#a855f7", "#3b82f6", "#14b8a6", "#ec4899"];
|
|
24
|
+
readonly sunset: ["#f97316", "#dc2626", "#9333ea", "#f472b6"];
|
|
25
|
+
readonly ocean: ["#1e3a8a", "#06b6d4", "#22d3ee", "#e0f2fe"];
|
|
26
|
+
readonly ice: ["#1e3a8a", "#67e8f9"];
|
|
27
|
+
readonly fire: ["#7f1d1d", "#fbbf24"];
|
|
28
|
+
readonly forest: ["#14532d", "#86efac"];
|
|
34
29
|
};
|
|
35
30
|
type SarmalPalette = keyof typeof palettes;
|
|
36
31
|
/** RGB color components */
|
|
37
32
|
interface Rgb {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
33
|
+
r: number;
|
|
34
|
+
g: number;
|
|
35
|
+
b: number;
|
|
41
36
|
}
|
|
42
37
|
|
|
43
|
-
export {
|
|
44
|
-
type BoundaryResult as B,
|
|
45
|
-
type Rgb as R,
|
|
46
|
-
type SarmalPalette as S,
|
|
47
|
-
computeBoundaries as c,
|
|
48
|
-
palettes as p,
|
|
49
|
-
};
|
|
38
|
+
export { type BoundaryResult as B, type Rgb as R, type SarmalPalette as S, computeBoundaries as c, palettes as p };
|
package/dist/terminal.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
2
|
|
|
3
3
|
// src/engine.ts
|
|
4
4
|
var TWO_PI = Math.PI * 2;
|
|
@@ -63,13 +63,13 @@ function resolveCurve(curveDef) {
|
|
|
63
63
|
period,
|
|
64
64
|
speed,
|
|
65
65
|
skeleton: curveDef.skeleton,
|
|
66
|
-
skeletonFn: curveDef.skeletonFn
|
|
66
|
+
skeletonFn: curveDef.skeletonFn
|
|
67
67
|
};
|
|
68
68
|
}
|
|
69
69
|
function createEngine(curveDef, trailLength = 120) {
|
|
70
70
|
if (!Number.isFinite(trailLength) || trailLength <= 0) {
|
|
71
71
|
throw new RangeError(
|
|
72
|
-
`[sarmal] trailLength must be a positive finite number, got ${trailLength}
|
|
72
|
+
`[sarmal] trailLength must be a positive finite number, got ${trailLength}`
|
|
73
73
|
);
|
|
74
74
|
}
|
|
75
75
|
let curve = resolveCurve(curveDef);
|
|
@@ -110,8 +110,7 @@ function createEngine(curveDef, trailLength = 120) {
|
|
|
110
110
|
actualTime += deltaTime;
|
|
111
111
|
if (morphCurveB !== null && _morphAlpha !== null) {
|
|
112
112
|
const a = curve.fn(phase, actualTime, EMPTY_PARAMS);
|
|
113
|
-
const phaseB =
|
|
114
|
-
_morphStrategy === "normalized" ? (phase / curve.period) * morphCurveB.period : phase;
|
|
113
|
+
const phaseB = _morphStrategy === "normalized" ? phase / curve.period * morphCurveB.period : phase;
|
|
115
114
|
const b = morphCurveB.fn(phaseB, actualTime, EMPTY_PARAMS);
|
|
116
115
|
trail.push(a.x + (b.x - a.x) * _morphAlpha, a.y + (b.y - a.y) * _morphAlpha);
|
|
117
116
|
} else {
|
|
@@ -138,14 +137,14 @@ function createEngine(curveDef, trailLength = 120) {
|
|
|
138
137
|
trail.clear();
|
|
139
138
|
},
|
|
140
139
|
jump(newPhase, { clearTrail = false } = {}) {
|
|
141
|
-
phase = (
|
|
140
|
+
phase = (newPhase % curve.period + curve.period) % curve.period;
|
|
142
141
|
if (clearTrail) {
|
|
143
142
|
trail.clear();
|
|
144
143
|
}
|
|
145
144
|
},
|
|
146
145
|
seek(targetPhase, { wrap = false, step = curve.period / trailLength } = {}) {
|
|
147
146
|
const advance = curve.speed * step;
|
|
148
|
-
const target = (
|
|
147
|
+
const target = (targetPhase % curve.period + curve.period) % curve.period;
|
|
149
148
|
const targetTime = target / curve.speed;
|
|
150
149
|
phase = target;
|
|
151
150
|
actualTime = targetTime;
|
|
@@ -154,7 +153,7 @@ function createEngine(curveDef, trailLength = 120) {
|
|
|
154
153
|
const count = wrap ? trailLength : Math.min(trailLength, pointsFromStart);
|
|
155
154
|
for (let i = count - 1; i >= 0; i--) {
|
|
156
155
|
const samplePhase = target - i * advance;
|
|
157
|
-
const wrappedPhase = (
|
|
156
|
+
const wrappedPhase = (samplePhase % curve.period + curve.period) % curve.period;
|
|
158
157
|
const elapsed = targetTime - i * step;
|
|
159
158
|
const point = curve.fn(wrappedPhase, elapsed, EMPTY_PARAMS);
|
|
160
159
|
trail.push(point.x, point.y);
|
|
@@ -171,16 +170,13 @@ function createEngine(curveDef, trailLength = 120) {
|
|
|
171
170
|
...frozenB,
|
|
172
171
|
fn: (samplePhase, elapsed, params) => {
|
|
173
172
|
const a = frozenA.fn(samplePhase, elapsed, params);
|
|
174
|
-
const phaseB =
|
|
175
|
-
frozenStrategy === "normalized"
|
|
176
|
-
? (samplePhase / frozenA.period) * frozenB.period
|
|
177
|
-
: samplePhase;
|
|
173
|
+
const phaseB = frozenStrategy === "normalized" ? samplePhase / frozenA.period * frozenB.period : samplePhase;
|
|
178
174
|
const b = frozenB.fn(phaseB, elapsed, params);
|
|
179
175
|
return {
|
|
180
176
|
x: a.x + (b.x - a.x) * frozenAlpha,
|
|
181
|
-
y: a.y + (b.y - a.y) * frozenAlpha
|
|
177
|
+
y: a.y + (b.y - a.y) * frozenAlpha
|
|
182
178
|
};
|
|
183
|
-
}
|
|
179
|
+
}
|
|
184
180
|
};
|
|
185
181
|
}
|
|
186
182
|
_morphStrategy = strategy;
|
|
@@ -193,7 +189,7 @@ function createEngine(curveDef, trailLength = 120) {
|
|
|
193
189
|
completeMorph() {
|
|
194
190
|
if (morphCurveB !== null) {
|
|
195
191
|
if (_morphStrategy === "normalized" && curve.period !== morphCurveB.period) {
|
|
196
|
-
phase =
|
|
192
|
+
phase = phase / curve.period * morphCurveB.period;
|
|
197
193
|
}
|
|
198
194
|
curve = morphCurveB;
|
|
199
195
|
}
|
|
@@ -205,22 +201,19 @@ function createEngine(curveDef, trailLength = 120) {
|
|
|
205
201
|
const points = new Array(steps);
|
|
206
202
|
if (morphCurveB !== null && _morphAlpha !== null) {
|
|
207
203
|
for (let i = 0; i < steps; i++) {
|
|
208
|
-
const samplePhase =
|
|
204
|
+
const samplePhase = i / (steps - 1) * curve.period;
|
|
209
205
|
const a = sampleSkeleton(curve, samplePhase);
|
|
210
|
-
const phaseB =
|
|
211
|
-
_morphStrategy === "normalized"
|
|
212
|
-
? (samplePhase / curve.period) * morphCurveB.period
|
|
213
|
-
: samplePhase;
|
|
206
|
+
const phaseB = _morphStrategy === "normalized" ? samplePhase / curve.period * morphCurveB.period : samplePhase;
|
|
214
207
|
const b = sampleSkeleton(morphCurveB, phaseB);
|
|
215
208
|
points[i] = {
|
|
216
209
|
x: a.x + (b.x - a.x) * _morphAlpha,
|
|
217
|
-
y: a.y + (b.y - a.y) * _morphAlpha
|
|
210
|
+
y: a.y + (b.y - a.y) * _morphAlpha
|
|
218
211
|
};
|
|
219
212
|
}
|
|
220
213
|
return points;
|
|
221
214
|
}
|
|
222
215
|
for (let i = 0; i < steps; i++) {
|
|
223
|
-
const samplePhase =
|
|
216
|
+
const samplePhase = i / (steps - 1) * curve.period;
|
|
224
217
|
points[i] = sampleSkeleton(curve, samplePhase);
|
|
225
218
|
}
|
|
226
219
|
return points;
|
|
@@ -262,7 +255,7 @@ function createEngine(curveDef, trailLength = 120) {
|
|
|
262
255
|
_speedTransition.reject(new Error("Speed transition cancelled"));
|
|
263
256
|
_speedTransition = null;
|
|
264
257
|
}
|
|
265
|
-
}
|
|
258
|
+
}
|
|
266
259
|
};
|
|
267
260
|
}
|
|
268
261
|
|
|
@@ -272,10 +265,7 @@ var FIT_PADDING_MIN = 4;
|
|
|
272
265
|
function computeBoundaries(pts, logicalWidth, logicalHeight, minPaddingPx = FIT_PADDING_MIN) {
|
|
273
266
|
if (pts.length === 0) return null;
|
|
274
267
|
const first = pts[0];
|
|
275
|
-
let minX = first.x,
|
|
276
|
-
maxX = first.x,
|
|
277
|
-
minY = first.y,
|
|
278
|
-
maxY = first.y;
|
|
268
|
+
let minX = first.x, maxX = first.x, minY = first.y, maxY = first.y;
|
|
279
269
|
for (const p of pts) {
|
|
280
270
|
if (p.x < minX) {
|
|
281
271
|
minX = p.x;
|
|
@@ -294,7 +284,7 @@ function computeBoundaries(pts, logicalWidth, logicalHeight, minPaddingPx = FIT_
|
|
|
294
284
|
const h = maxY - minY;
|
|
295
285
|
if (w === 0 && h === 0) {
|
|
296
286
|
throw new Error(
|
|
297
|
-
"[sarmal] Degenerate curve: all skeleton points are identical. Check that your curve fn returns distinct points for different values of t."
|
|
287
|
+
"[sarmal] Degenerate curve: all skeleton points are identical. Check that your curve fn returns distinct points for different values of t."
|
|
298
288
|
);
|
|
299
289
|
}
|
|
300
290
|
const scaleXProportional = logicalWidth / (w * (1 + FIT_PADDING * 2));
|
|
@@ -305,17 +295,17 @@ function computeBoundaries(pts, logicalWidth, logicalHeight, minPaddingPx = FIT_
|
|
|
305
295
|
scaleXProportional,
|
|
306
296
|
scaleYProportional,
|
|
307
297
|
scaleXMinPadding,
|
|
308
|
-
scaleYMinPadding
|
|
298
|
+
scaleYMinPadding
|
|
309
299
|
);
|
|
310
300
|
return {
|
|
311
301
|
scale,
|
|
312
302
|
offsetX: (logicalWidth - w * scale) / 2 - minX * scale,
|
|
313
|
-
offsetY: (logicalHeight - h * scale) / 2 - minY * scale
|
|
303
|
+
offsetY: (logicalHeight - h * scale) / 2 - minY * scale
|
|
314
304
|
};
|
|
315
305
|
}
|
|
316
306
|
function hexToRgb(hex) {
|
|
317
307
|
const n = parseInt(hex.slice(1), 16);
|
|
318
|
-
return { r: n >> 16, g:
|
|
308
|
+
return { r: n >> 16, g: n >> 8 & 255, b: n & 255 };
|
|
319
309
|
}
|
|
320
310
|
|
|
321
311
|
// src/terminal.ts
|
|
@@ -329,12 +319,15 @@ var BRAILLE_BIT = [
|
|
|
329
319
|
[1, 8],
|
|
330
320
|
[2, 16],
|
|
331
321
|
[4, 32],
|
|
332
|
-
[64, 128]
|
|
322
|
+
[64, 128]
|
|
333
323
|
];
|
|
334
324
|
function brailleChar(bits) {
|
|
335
325
|
return String.fromCodePoint(BRAILLE_BASE + (bits & 255));
|
|
336
326
|
}
|
|
337
327
|
function brailleBit(row, col) {
|
|
328
|
+
if (row < 0 || row >= BRAILLE_BIT.length || col < 0 || col >= (BRAILLE_BIT[0]?.length ?? 0)) {
|
|
329
|
+
return 0;
|
|
330
|
+
}
|
|
338
331
|
return BRAILLE_BIT[row][col];
|
|
339
332
|
}
|
|
340
333
|
function dotToCell(dotCol, dotRow) {
|
|
@@ -342,7 +335,7 @@ function dotToCell(dotCol, dotRow) {
|
|
|
342
335
|
charCol: Math.floor(dotCol / 2),
|
|
343
336
|
charRow: Math.floor(dotRow / 4),
|
|
344
337
|
dotColInCell: dotCol % 2,
|
|
345
|
-
dotRowInCell: dotRow % 4
|
|
338
|
+
dotRowInCell: dotRow % 4
|
|
346
339
|
};
|
|
347
340
|
}
|
|
348
341
|
function detectColor() {
|
|
@@ -357,13 +350,10 @@ function detectColor() {
|
|
|
357
350
|
if (term.includes("truecolor") || term.includes("24bit")) {
|
|
358
351
|
return "truecolor";
|
|
359
352
|
}
|
|
360
|
-
if (
|
|
361
|
-
return "
|
|
362
|
-
}
|
|
363
|
-
if (term !== "" && term !== "linux" && term !== "dumb") {
|
|
364
|
-
return "256-color";
|
|
353
|
+
if (term === "" || term === "linux" || term === "dumb") {
|
|
354
|
+
return "monochrome";
|
|
365
355
|
}
|
|
366
|
-
return "
|
|
356
|
+
return "256-color";
|
|
367
357
|
}
|
|
368
358
|
function rgbTo256(r, g, b) {
|
|
369
359
|
const avg = Math.round((r + g + b) / 3);
|
|
@@ -373,17 +363,18 @@ function rgbTo256(r, g, b) {
|
|
|
373
363
|
}
|
|
374
364
|
return 232 + Math.min(23, Math.round((avg - 8) / 10));
|
|
375
365
|
}
|
|
376
|
-
const ri = Math.round(
|
|
377
|
-
const gi = Math.round(
|
|
378
|
-
const bi = Math.round(
|
|
366
|
+
const ri = Math.round(r / 255 * 5);
|
|
367
|
+
const gi = Math.round(g / 255 * 5);
|
|
368
|
+
const bi = Math.round(b / 255 * 5);
|
|
379
369
|
return 16 + 36 * ri + 6 * gi + bi;
|
|
380
370
|
}
|
|
381
371
|
function dimColor(hex, brightness) {
|
|
372
|
+
const clamped = Math.max(0, Math.min(1, brightness));
|
|
382
373
|
const c = hexToRgb(hex);
|
|
383
374
|
return {
|
|
384
|
-
r: Math.round(c.r *
|
|
385
|
-
g: Math.round(c.g *
|
|
386
|
-
b: Math.round(c.b *
|
|
375
|
+
r: Math.max(0, Math.min(255, Math.round(c.r * clamped))),
|
|
376
|
+
g: Math.max(0, Math.min(255, Math.round(c.g * clamped))),
|
|
377
|
+
b: Math.max(0, Math.min(255, Math.round(c.b * clamped)))
|
|
387
378
|
};
|
|
388
379
|
}
|
|
389
380
|
var AR = "\x1B[0m";
|
|
@@ -408,25 +399,18 @@ function snapCol(col, max) {
|
|
|
408
399
|
function applyBoundary(x, y, scale, offsetX, offsetY) {
|
|
409
400
|
return {
|
|
410
401
|
screenX: x * scale + offsetX,
|
|
411
|
-
screenY: y * scale + offsetY
|
|
402
|
+
screenY: y * scale + offsetY
|
|
412
403
|
};
|
|
413
404
|
}
|
|
414
|
-
function renderFrame(
|
|
415
|
-
trail,
|
|
416
|
-
trailCount,
|
|
417
|
-
charWidth,
|
|
418
|
-
charHeight,
|
|
419
|
-
scale,
|
|
420
|
-
offsetX,
|
|
421
|
-
offsetY,
|
|
422
|
-
trailRgb,
|
|
423
|
-
headRgb,
|
|
424
|
-
colorCap,
|
|
425
|
-
) {
|
|
405
|
+
function renderFrame(trail, trailCount, charWidth, charHeight, scale, offsetX, offsetY, trailRgb, headRgb, colorCap) {
|
|
426
406
|
const dotWidth = charWidth * 2;
|
|
427
407
|
const dotHeight = charHeight * 4;
|
|
428
|
-
const grid = Array.from(
|
|
429
|
-
|
|
408
|
+
const grid = Array.from(
|
|
409
|
+
{ length: charHeight },
|
|
410
|
+
() => Array.from(
|
|
411
|
+
{ length: charWidth },
|
|
412
|
+
() => ({ bits: 0, brightness: 0, isHead: false })
|
|
413
|
+
)
|
|
430
414
|
);
|
|
431
415
|
for (let i = 0; i < trailCount; i++) {
|
|
432
416
|
const pt = trail[i];
|
|
@@ -436,12 +420,7 @@ function renderFrame(
|
|
|
436
420
|
const dotCol = snapCol(screenX, dotWidth);
|
|
437
421
|
const dotRow = snapCol(screenY, dotHeight);
|
|
438
422
|
const cell = dotToCell(dotCol, dotRow);
|
|
439
|
-
if (
|
|
440
|
-
cell.charRow < 0 ||
|
|
441
|
-
cell.charRow >= charHeight ||
|
|
442
|
-
cell.charCol < 0 ||
|
|
443
|
-
cell.charCol >= charWidth
|
|
444
|
-
) {
|
|
423
|
+
if (cell.charRow < 0 || cell.charRow >= charHeight || cell.charCol < 0 || cell.charCol >= charWidth) {
|
|
445
424
|
continue;
|
|
446
425
|
}
|
|
447
426
|
const c = grid[cell.charRow][cell.charCol];
|
|
@@ -492,11 +471,7 @@ function renderMonochromeFrame(grid, charWidth, charHeight) {
|
|
|
492
471
|
line += " ";
|
|
493
472
|
continue;
|
|
494
473
|
}
|
|
495
|
-
|
|
496
|
-
line += "\u28FF";
|
|
497
|
-
} else {
|
|
498
|
-
line += brailleChar(cell.bits);
|
|
499
|
-
}
|
|
474
|
+
line += brailleChar(cell.bits);
|
|
500
475
|
}
|
|
501
476
|
lines.push(line);
|
|
502
477
|
}
|
|
@@ -504,7 +479,8 @@ function renderMonochromeFrame(grid, charWidth, charHeight) {
|
|
|
504
479
|
}
|
|
505
480
|
function terminalSarmal(stream, curveDef, options) {
|
|
506
481
|
if (!stream.isTTY) {
|
|
507
|
-
return () => {
|
|
482
|
+
return () => {
|
|
483
|
+
};
|
|
508
484
|
}
|
|
509
485
|
const size = options?.size ?? DEFAULT_SIZE;
|
|
510
486
|
const fps = options?.fps ?? DEFAULT_FPS;
|
|
@@ -523,7 +499,8 @@ function terminalSarmal(stream, curveDef, options) {
|
|
|
523
499
|
const skeleton = engine.getSarmalSkeleton();
|
|
524
500
|
const b = computeBoundaries(skeleton, charWidth * 2, charHeight * 4, 1);
|
|
525
501
|
if (!b) {
|
|
526
|
-
return () => {
|
|
502
|
+
return () => {
|
|
503
|
+
};
|
|
527
504
|
}
|
|
528
505
|
const { scale, offsetX, offsetY } = b;
|
|
529
506
|
let running = true;
|
|
@@ -553,7 +530,7 @@ function terminalSarmal(stream, curveDef, options) {
|
|
|
553
530
|
offsetY,
|
|
554
531
|
trailRgb,
|
|
555
532
|
headRgb,
|
|
556
|
-
colorCap
|
|
533
|
+
colorCap
|
|
557
534
|
);
|
|
558
535
|
if (firstFrame) {
|
|
559
536
|
firstFrame = false;
|
|
@@ -590,4 +567,4 @@ exports.dotToCell = dotToCell;
|
|
|
590
567
|
exports.rgbTo256 = rgbTo256;
|
|
591
568
|
exports.terminalSarmal = terminalSarmal;
|
|
592
569
|
//# sourceMappingURL=terminal.cjs.map
|
|
593
|
-
//# sourceMappingURL=terminal.cjs.map
|
|
570
|
+
//# sourceMappingURL=terminal.cjs.map
|