Skip to content

Commit

Permalink
🐛 Fix an error in the horizontal foldline logic
Browse files Browse the repository at this point in the history
  • Loading branch information
foosel committed May 25, 2024
1 parent 038913d commit 43e1a7b
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/assets/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ if (typeof importScripts === "function") {
const cardMarginDoc = cardMargin * mmFactor;
const foldingMarginDoc = foldingMargin * mmFactor;

const usableHalf = foldLine === "vertical" ? (usableWidth / 2 - 2 * foldingMarginDoc) : (usableHeight / 2 - 2 * foldingMarginDoc);
const usableHalf = foldLine === "vertical" ? (usableWidth / 2 - foldingMarginDoc) : (usableHeight / 2 - foldingMarginDoc);

let maxCardsPerPage, rotate, totalHeight, totalWidth;
if (foldLine === "vertical") {
Expand Down Expand Up @@ -242,19 +242,19 @@ if (typeof importScripts === "function") {

if (cardsPerPageWidth > cardsPerPageHeight) {
maxCardsPerPage = cardsPerPageWidth;
rotate = false;
rotate = true; // heads-up, inverted logic!
} else {
maxCardsPerPage = cardsPerPageHeight;
rotate = true;
rotate = false; // heads-up, inverted logic!
}
} else if (cardWidth < usableHalf) {
// card fits on half of the page in width, but not height
maxCardsPerPage = Math.floor(usableWidth / cardWidthDoc);
rotate = false;
rotate = true; // heads-up, inverted logic!
} else if (cardHeight < usableHalf) {
// card fits on half of the page in height, but not width
maxCardsPerPage = Math.floor(usableWidth / cardHeightDoc);
rotate = true;
rotate = false; // heads-up, inverted logic!
} else {
// card does not fit on half of the page in either orientation
postMessage({ error: "Cards are too large to fit on half of the page in either orientation" });
Expand Down Expand Up @@ -326,7 +326,7 @@ if (typeof importScripts === "function") {
yBack = yFront;
}
} else {
if (!rotate) {
if (!rotate) { // heads-up, inverted logic!
angleFront = PDFLib.degrees(0);
yFront = pageHeight / 2 + foldingMarginDoc;
xFront = (pageWidth - totalWidth) / 2 + (count % maxCardsPerPage) * (cardWidthDoc + cardMarginDoc);
Expand Down

0 comments on commit 43e1a7b

Please sign in to comment.