@promptctl/rich-js 0.25.1 → 0.25.2
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/core/strip.d.ts +15 -5
- package/dist/core/strip.js +24 -19
- package/package.json +1 -1
package/dist/core/strip.d.ts
CHANGED
|
@@ -372,11 +372,21 @@ export type JoinerSpec = string | {
|
|
|
372
372
|
*/
|
|
373
373
|
export declare function joinerNamed(spec: JoinerSpec): CellJoiner;
|
|
374
374
|
/**
|
|
375
|
-
* A ramp of `steps` cells from the left ground to the right
|
|
376
|
-
*
|
|
377
|
-
*
|
|
378
|
-
*
|
|
379
|
-
*
|
|
375
|
+
* A ramp of `steps` cells from the left ground to the right, each cell filled
|
|
376
|
+
* with one colour: cell `i` is the colour `(i + 1/2) / steps` of the way
|
|
377
|
+
* across, so no cell is either neighbour's ground. A cell is a space whose ink
|
|
378
|
+
* is the terminal's ground, so its one colour is its fill, the same in ASCII.
|
|
379
|
+
* Beside a neighbour with no ground there is no colour to ramp toward, so that
|
|
380
|
+
* join draws the caps the ramp is ended in.
|
|
381
|
+
*
|
|
382
|
+
* [LAW:dataflow-not-control-flow] A ramp cell is fill alone: a space has no
|
|
383
|
+
* ink, and `"ground"` as its `fg` is the absence of a colour on that side
|
|
384
|
+
* (`cellStyle`). So the lift, the path every seam cell is drawn by, has no ink
|
|
385
|
+
* to hold off its ground, and the ramp is the blend, monotone however close
|
|
386
|
+
* its grounds or however many its steps. Two samples to a cell, ink over
|
|
387
|
+
* ground, cannot be: the lift holds every cell's two the floor apart, so
|
|
388
|
+
* `steps` such cells rise without turning back only between grounds `steps`
|
|
389
|
+
* floors apart.
|
|
380
390
|
*/
|
|
381
391
|
export declare function gradientSeam(steps?: number): JoinSeam;
|
|
382
392
|
export {};
|
package/dist/core/strip.js
CHANGED
|
@@ -627,26 +627,31 @@ function named(table, kind, kinds, name) {
|
|
|
627
627
|
throw new Error(`no ${kind} named ${JSON.stringify(name)}; the ${kinds} are ${Object.keys(table).join(", ")}`);
|
|
628
628
|
return table[name];
|
|
629
629
|
}
|
|
630
|
-
function gradient(steps, glyph) {
|
|
631
|
-
// Midpoint sampling across `2 * steps` half-cell positions: cell i takes
|
|
632
|
-
// samples 2i (its ink, the left half) and 2i+1 (its ground, the right half),
|
|
633
|
-
// so no sample equals either neighbour's ground.
|
|
634
|
-
const samples = 2 * steps;
|
|
635
|
-
return {
|
|
636
|
-
seam: Array.from({ length: steps }, (_, i) => ({
|
|
637
|
-
glyph,
|
|
638
|
-
fg: { mix: [LEFT_BG, RIGHT_BG, (2 * i + 0.5) / samples] },
|
|
639
|
-
bg: { mix: [LEFT_BG, RIGHT_BG, (2 * i + 1.5) / samples] },
|
|
640
|
-
})),
|
|
641
|
-
};
|
|
642
|
-
}
|
|
643
630
|
/**
|
|
644
|
-
* A ramp of `steps` cells from the left ground to the right
|
|
645
|
-
*
|
|
646
|
-
*
|
|
647
|
-
*
|
|
648
|
-
*
|
|
631
|
+
* A ramp of `steps` cells from the left ground to the right, each cell filled
|
|
632
|
+
* with one colour: cell `i` is the colour `(i + 1/2) / steps` of the way
|
|
633
|
+
* across, so no cell is either neighbour's ground. A cell is a space whose ink
|
|
634
|
+
* is the terminal's ground, so its one colour is its fill, the same in ASCII.
|
|
635
|
+
* Beside a neighbour with no ground there is no colour to ramp toward, so that
|
|
636
|
+
* join draws the caps the ramp is ended in.
|
|
637
|
+
*
|
|
638
|
+
* [LAW:dataflow-not-control-flow] A ramp cell is fill alone: a space has no
|
|
639
|
+
* ink, and `"ground"` as its `fg` is the absence of a colour on that side
|
|
640
|
+
* (`cellStyle`). So the lift, the path every seam cell is drawn by, has no ink
|
|
641
|
+
* to hold off its ground, and the ramp is the blend, monotone however close
|
|
642
|
+
* its grounds or however many its steps. Two samples to a cell, ink over
|
|
643
|
+
* ground, cannot be: the lift holds every cell's two the floor apart, so
|
|
644
|
+
* `steps` such cells rise without turning back only between grounds `steps`
|
|
645
|
+
* floors apart.
|
|
649
646
|
*/
|
|
650
647
|
export function gradientSeam(steps = 4) {
|
|
651
|
-
|
|
648
|
+
// [LAW:no-silent-failure] A count that is no whole number of cells would draw
|
|
649
|
+
// a lopsided ramp without a word, and no cells is no ramp: a seam that reads
|
|
650
|
+
// neither ground, joining a colourless neighbour where a ramp draws the caps.
|
|
651
|
+
if (!(Number.isInteger(steps) && steps > 0))
|
|
652
|
+
throw new RangeError(`gradientSeam steps must be a positive whole number of cells, got ${steps}`);
|
|
653
|
+
const ramp = {
|
|
654
|
+
seam: Array.from({ length: steps }, (_, i) => ({ glyph: " ", fg: GROUND, bg: { mix: [LEFT_BG, RIGHT_BG, (i + 1 / 2) / steps] } })),
|
|
655
|
+
};
|
|
656
|
+
return parseSeam(both(ramp, ramp));
|
|
652
657
|
}
|