Merge pull request #19726 from Snuffleupagus/_setDefaultAppearance-bbox
Use `Util.rectBoundingBox` more in the annotation code (PR 19713 follow-up)
This commit is contained in:
commit
f23087ca7e
@ -1699,10 +1699,7 @@ class MarkupAnnotation extends Annotation {
|
|||||||
fillAlpha,
|
fillAlpha,
|
||||||
pointsCallback,
|
pointsCallback,
|
||||||
}) {
|
}) {
|
||||||
let minX = Number.MAX_VALUE;
|
const bbox = (this.data.rect = [Infinity, Infinity, -Infinity, -Infinity]);
|
||||||
let minY = Number.MAX_VALUE;
|
|
||||||
let maxX = Number.MIN_VALUE;
|
|
||||||
let maxY = Number.MIN_VALUE;
|
|
||||||
|
|
||||||
const buffer = ["q"];
|
const buffer = ["q"];
|
||||||
if (extra) {
|
if (extra) {
|
||||||
@ -1732,14 +1729,8 @@ class MarkupAnnotation extends Annotation {
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
for (let i = 0, ii = pointsArray.length; i < ii; i += 8) {
|
for (let i = 0, ii = pointsArray.length; i < ii; i += 8) {
|
||||||
const [mX, MX, mY, MY] = pointsCallback(
|
const points = pointsCallback(buffer, pointsArray.subarray(i, i + 8));
|
||||||
buffer,
|
Util.rectBoundingBox(...points, bbox);
|
||||||
pointsArray.subarray(i, i + 8)
|
|
||||||
);
|
|
||||||
minX = Math.min(minX, mX);
|
|
||||||
maxX = Math.max(maxX, MX);
|
|
||||||
minY = Math.min(minY, mY);
|
|
||||||
maxY = Math.max(maxY, MY);
|
|
||||||
}
|
}
|
||||||
buffer.push("Q");
|
buffer.push("Q");
|
||||||
|
|
||||||
@ -1771,7 +1762,6 @@ class MarkupAnnotation extends Annotation {
|
|||||||
|
|
||||||
const appearanceDict = new Dict(xref);
|
const appearanceDict = new Dict(xref);
|
||||||
appearanceDict.set("Resources", resources);
|
appearanceDict.set("Resources", resources);
|
||||||
const bbox = (this.data.rect = [minX, minY, maxX, maxY]);
|
|
||||||
appearanceDict.set("BBox", bbox);
|
appearanceDict.set("BBox", bbox);
|
||||||
|
|
||||||
this.appearance = new StringStream("/GS0 gs /Fm0 Do");
|
this.appearance = new StringStream("/GS0 gs /Fm0 Do");
|
||||||
@ -4162,8 +4152,8 @@ class LineAnnotation extends MarkupAnnotation {
|
|||||||
);
|
);
|
||||||
return [
|
return [
|
||||||
points[0] - borderWidth,
|
points[0] - borderWidth,
|
||||||
points[2] + borderWidth,
|
|
||||||
points[7] - borderWidth,
|
points[7] - borderWidth,
|
||||||
|
points[2] + borderWidth,
|
||||||
points[3] + borderWidth,
|
points[3] + borderWidth,
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
@ -4214,7 +4204,7 @@ class SquareAnnotation extends MarkupAnnotation {
|
|||||||
} else {
|
} else {
|
||||||
buffer.push("S");
|
buffer.push("S");
|
||||||
}
|
}
|
||||||
return [points[0], points[2], points[7], points[3]];
|
return [points[0], points[7], points[2], points[3]];
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -4278,7 +4268,7 @@ class CircleAnnotation extends MarkupAnnotation {
|
|||||||
} else {
|
} else {
|
||||||
buffer.push("S");
|
buffer.push("S");
|
||||||
}
|
}
|
||||||
return [points[0], points[2], points[7], points[3]];
|
return [points[0], points[7], points[2], points[3]];
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -4349,7 +4339,7 @@ class PolylineAnnotation extends MarkupAnnotation {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
buffer.push("S");
|
buffer.push("S");
|
||||||
return [points[0], points[2], points[7], points[3]];
|
return [points[0], points[7], points[2], points[3]];
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -4456,7 +4446,7 @@ class InkAnnotation extends MarkupAnnotation {
|
|||||||
}
|
}
|
||||||
buffer.push("S");
|
buffer.push("S");
|
||||||
}
|
}
|
||||||
return [points[0], points[2], points[7], points[3]];
|
return [points[0], points[7], points[2], points[3]];
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -4688,7 +4678,7 @@ class HighlightAnnotation extends MarkupAnnotation {
|
|||||||
`${points[4]} ${points[5]} l`,
|
`${points[4]} ${points[5]} l`,
|
||||||
"f"
|
"f"
|
||||||
);
|
);
|
||||||
return [points[0], points[2], points[7], points[3]];
|
return [points[0], points[7], points[2], points[3]];
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -4813,7 +4803,7 @@ class UnderlineAnnotation extends MarkupAnnotation {
|
|||||||
`${points[6]} ${points[7] + 1.3} l`,
|
`${points[6]} ${points[7] + 1.3} l`,
|
||||||
"S"
|
"S"
|
||||||
);
|
);
|
||||||
return [points[0], points[2], points[7], points[3]];
|
return [points[0], points[7], points[2], points[3]];
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -4857,7 +4847,7 @@ class SquigglyAnnotation extends MarkupAnnotation {
|
|||||||
buffer.push(`${x} ${y + shift} l`);
|
buffer.push(`${x} ${y + shift} l`);
|
||||||
} while (x < xEnd);
|
} while (x < xEnd);
|
||||||
buffer.push("S");
|
buffer.push("S");
|
||||||
return [points[4], xEnd, y - 2 * dy, y + 2 * dy];
|
return [points[4], y - 2 * dy, xEnd, y + 2 * dy];
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -4896,7 +4886,7 @@ class StrikeOutAnnotation extends MarkupAnnotation {
|
|||||||
`${(points[3] + points[7]) / 2} l`,
|
`${(points[3] + points[7]) / 2} l`,
|
||||||
"S"
|
"S"
|
||||||
);
|
);
|
||||||
return [points[0], points[2], points[7], points[3]];
|
return [points[0], points[7], points[2], points[3]];
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user