diff options
author | Sophie Zhang <sophie_zhang@brown.edu> | 2023-11-02 02:12:19 -0400 |
---|---|---|
committer | Sophie Zhang <sophie_zhang@brown.edu> | 2023-11-02 02:12:19 -0400 |
commit | a1d00a36ef1afa97198a825bd25ebb4c5e598848 (patch) | |
tree | e0c0454c99938562132794333a22e490e3e37cb9 /src/fields/Doc.ts | |
parent | 78d8261522c0079b0298613a856547a9ac96ef50 (diff) | |
parent | 84c15417f2247fc650a9f7b2c959479519bd3ebb (diff) |
Merge branch 'master' into sophie-ai-images
Diffstat (limited to 'src/fields/Doc.ts')
-rw-r--r-- | src/fields/Doc.ts | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/src/fields/Doc.ts b/src/fields/Doc.ts index 9e3eb28f9..feacdc9c5 100644 --- a/src/fields/Doc.ts +++ b/src/fields/Doc.ts @@ -687,16 +687,12 @@ export namespace Doc { */ export function ComputeContentBounds(docList: Doc[]) { const bounds = docList.reduce( - (bounds, doc) => { - const [sptX, sptY] = [NumCast(doc.x), NumCast(doc.y)]; - const [bptX, bptY] = [sptX + doc[Width](), sptY + doc[Height]()]; - return { - x: Math.min(sptX, bounds.x), - y: Math.min(sptY, bounds.y), - r: Math.max(bptX, bounds.r), - b: Math.max(bptY, bounds.b), - }; - }, + (bounds, doc) => ({ + x: Math.min(NumCast(doc.x), bounds.x), + y: Math.min(NumCast(doc.y), bounds.y), + r: Math.max(NumCast(doc.x) + doc[Width](), bounds.r), + b: Math.max(NumCast(doc.y) + doc[Height](), bounds.b), + }), { x: Number.MAX_VALUE, y: Number.MAX_VALUE, r: -Number.MAX_VALUE, b: -Number.MAX_VALUE } ); return bounds; |