style: apply new dprint rules to CharacterComparisonEngine
This commit is contained in:
+9
-3
@@ -269,8 +269,12 @@ export class CharacterComparisonEngine {
|
|||||||
// right side (i+1..n-1) not yet past → font B widths
|
// right side (i+1..n-1) not yet past → font B widths
|
||||||
const prefA = new Float64Array(n + 1);
|
const prefA = new Float64Array(n + 1);
|
||||||
const sufB = new Float64Array(n + 1);
|
const sufB = new Float64Array(n + 1);
|
||||||
for (let i = 0; i < n; i++) { prefA[i + 1] = prefA[i] + chars[i].widthA; }
|
for (let i = 0; i < n; i++) {
|
||||||
for (let i = n - 1; i >= 0; i--) { sufB[i] = sufB[i + 1] + chars[i].widthB; }
|
prefA[i + 1] = prefA[i] + chars[i].widthA;
|
||||||
|
}
|
||||||
|
for (let i = n - 1; i >= 0; i--) {
|
||||||
|
sufB[i] = sufB[i + 1] + chars[i].widthB;
|
||||||
|
}
|
||||||
// Per-char threshold: slider x at which this char should toggle isPast.
|
// Per-char threshold: slider x at which this char should toggle isPast.
|
||||||
const thresholds = new Float64Array(n);
|
const thresholds = new Float64Array(n);
|
||||||
for (let i = 0; i < n; i++) {
|
for (let i = 0; i < n; i++) {
|
||||||
@@ -280,7 +284,9 @@ export class CharacterComparisonEngine {
|
|||||||
}
|
}
|
||||||
// Determine isPast for each char at the current slider position.
|
// Determine isPast for each char at the current slider position.
|
||||||
const isPastArr = new Uint8Array(n);
|
const isPastArr = new Uint8Array(n);
|
||||||
for (let i = 0; i < n; i++) { isPastArr[i] = sliderX > thresholds[i] ? 1 : 0; }
|
for (let i = 0; i < n; i++) {
|
||||||
|
isPastArr[i] = sliderX > thresholds[i] ? 1 : 0;
|
||||||
|
}
|
||||||
// Compute visual positions based on actual rendered widths (font A if past, B if not).
|
// Compute visual positions based on actual rendered widths (font A if past, B if not).
|
||||||
const totalRendered = chars.reduce((s, c, i) => s + (isPastArr[i] ? c.widthA : c.widthB), 0);
|
const totalRendered = chars.reduce((s, c, i) => s + (isPastArr[i] ? c.widthA : c.widthB), 0);
|
||||||
const xOffset = (containerWidth - totalRendered) / 2;
|
const xOffset = (containerWidth - totalRendered) / 2;
|
||||||
|
|||||||
Reference in New Issue
Block a user