fix: render decoded ink coordinates
This commit is contained in:
@@ -472,10 +472,10 @@ function InkView({ ink }: { ink: OneNoteInkBlock }) {
|
||||
}
|
||||
|
||||
function inkPath(stroke: OneNoteInkStroke): string {
|
||||
const [first, ...deltas] = stroke.points;
|
||||
const [first, ...points] = stroke.points;
|
||||
if (!first) return '';
|
||||
if (deltas.length === 0) return `M ${first.x} ${first.y} l 0 0`;
|
||||
return `M ${first.x} ${first.y} l ${deltas
|
||||
if (points.length === 0) return `M ${first.x} ${first.y} l 0 0`;
|
||||
return `M ${first.x} ${first.y} L ${points
|
||||
.map((point) => `${point.x} ${point.y}`)
|
||||
.join(' ')}`;
|
||||
}
|
||||
@@ -488,21 +488,11 @@ function boundingBoxFromInk(
|
||||
let xMax = -Infinity;
|
||||
let yMax = -Infinity;
|
||||
for (const stroke of strokes) {
|
||||
const [first, ...deltas] = stroke.points;
|
||||
if (!first) continue;
|
||||
let x = first.x;
|
||||
let y = first.y;
|
||||
xMin = Math.min(xMin, x);
|
||||
yMin = Math.min(yMin, y);
|
||||
xMax = Math.max(xMax, x);
|
||||
yMax = Math.max(yMax, y);
|
||||
for (const delta of deltas) {
|
||||
x += delta.x;
|
||||
y += delta.y;
|
||||
xMin = Math.min(xMin, x);
|
||||
yMin = Math.min(yMin, y);
|
||||
xMax = Math.max(xMax, x);
|
||||
yMax = Math.max(yMax, y);
|
||||
for (const point of stroke.points) {
|
||||
xMin = Math.min(xMin, point.x);
|
||||
yMin = Math.min(yMin, point.y);
|
||||
xMax = Math.max(xMax, point.x);
|
||||
yMax = Math.max(yMax, point.y);
|
||||
}
|
||||
}
|
||||
return Number.isFinite(xMin)
|
||||
|
||||
Reference in New Issue
Block a user