Skip to content

Commit d0ee354

Browse files
committed
Use the Util.pointBoundingBox helper in the PatternInfo class (PR 20340 follow-up)
Rather than computing the `bounds` manually, as done in PR 20340, we can shorten/simplify the code by using an existing helper instead.
1 parent 3127492 commit d0ee354

1 file changed

Lines changed: 5 additions & 13 deletions

File tree

src/display/obj_bin_transform_display.js

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* limitations under the License.
1414
*/
1515

16-
import { assert, FeatureTest, MeshFigureType } from "../shared/util.js";
16+
import { assert, FeatureTest, MeshFigureType, Util } from "../shared/util.js";
1717
import {
1818
CSS_FONT_INFO,
1919
FONT_INFO,
@@ -438,19 +438,11 @@ class PatternInfo {
438438
const shadingType = this.data[PATTERN_INFO.SHADING_TYPE];
439439
let bounds = null;
440440
if (coords.length > 0) {
441-
let minX = coords[0],
442-
maxX = coords[0];
443-
let minY = coords[1],
444-
maxY = coords[1];
445-
for (let i = 0; i < coords.length; i += 2) {
446-
const x = coords[i],
447-
y = coords[i + 1];
448-
minX = minX > x ? x : minX;
449-
minY = minY > y ? y : minY;
450-
maxX = maxX < x ? x : maxX;
451-
maxY = maxY < y ? y : maxY;
441+
bounds = [Infinity, Infinity, -Infinity, -Infinity];
442+
443+
for (let i = 0, ii = coords.length; i < ii; i += 2) {
444+
Util.pointBoundingBox(coords[i], coords[i + 1], bounds);
452445
}
453-
bounds = [minX, minY, maxX, maxY];
454446
}
455447
return [
456448
"Mesh",

0 commit comments

Comments
 (0)