Skip to content

Commit

Permalink
Prevent rounding errors showing up as invalid print area
Browse files Browse the repository at this point in the history
Fixes #41
  • Loading branch information
perliedman committed Feb 9, 2025
1 parent 24287ea commit 4054bcb
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/tools/PrintArea.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,11 @@ export default function PrintArea() {
getHeight(paperExtent),
].map((x) => x * (crs.scale / course.printScale));

// Check that print area isn't significantly larger
// (1e-5 is the tolerance so we don't complain about tiny rounding errors)
const isValid =
pageSizeMm[0] >= printAreaSizeMm[0] &&
pageSizeMm[1] >= printAreaSizeMm[1];
pageSizeMm[0] + 1e-5 >= printAreaSizeMm[0] &&
pageSizeMm[1] + 1e-5 >= printAreaSizeMm[1];
const boxStyle = new Style({
stroke: new Stroke({
color: isValid ? "#444" : "#FF0000",
Expand Down

0 comments on commit 4054bcb

Please sign in to comment.