Skip to content

Commit

Permalink
Try using a larger image for weird aspect ratios
Browse files Browse the repository at this point in the history
  • Loading branch information
davepagurek committed Jan 9, 2025
1 parent 6f86e8a commit 9c0ab0b
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion test/unit/visual/visualTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,15 @@ export function visualSuite(
}

export async function checkMatch(actual, expected, p5) {
const scale = Math.min(MAX_SIDE/expected.width, MAX_SIDE/expected.height);
let scale = Math.min(MAX_SIDE/expected.width, MAX_SIDE/expected.height);

// Long screenshots end up super tiny when fit to a small square, so we
// can double the max side length for these
const ratio = expected.width / expected.height;
const narrow = ratio < 0.5 || ratio > 2;
if (narrow) {
scale *= 2;
}

for (const img of [actual, expected]) {
img.resize(
Expand Down

0 comments on commit 9c0ab0b

Please sign in to comment.