From 97dde878ada44ab982c5d045f35eb397be7ed1ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Dalecki?= Date: Fri, 19 Apr 2024 22:54:11 +0200 Subject: [PATCH] Fix printing on the edge --- src/book.js | 1 - src/utils/drawing.js | 17 +++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/book.js b/src/book.js index 146523b..5e5f2b6 100644 --- a/src/book.js +++ b/src/book.js @@ -584,7 +584,6 @@ export class Book { ? drawSewingMarks( sigDetails[i], positions[i], - papersize, sewingMarks.amount, sewingMarks.marginPt, sewingMarks.tapeWidthPt diff --git a/src/utils/drawing.js b/src/utils/drawing.js index 85dde6c..886279b 100644 --- a/src/utils/drawing.js +++ b/src/utils/drawing.js @@ -124,13 +124,12 @@ export function drawCropmarks(papersize, per_sheet) { /** * @param {@param {import("../book.js").PageInfo}} sigDetails - information about signature where marks will be printed * @param {import("../book.js").Position} position - position info object - * @param {number[]} papersize - paper dimensions * @param {number} amount - amount of sewing crosses. * @param {number} marginPt - distance from the end of sheet of paper to kettle mark * @param {number} tapeWidthPt - distance between two points in a single sewwing cross. * @returns {Point[]} */ -export function drawSewingMarks(sigDetails, position, papersize, amount, marginPt, tapeWidthPt) { +export function drawSewingMarks(sigDetails, position, amount, marginPt, tapeWidthPt) { // Here normalize coordinates to always think in x an y like this // | P |H| P | // | A |E| A | @@ -139,6 +138,9 @@ export function drawSewingMarks(sigDetails, position, papersize, amount, marginP // | |T| | // |-POSITION-| | | + // Left pages has spine position on the endge :/ + if (position.isLeftPage) return []; + var arePageRotated = Math.abs(position.rotation) === 90; let totalSpineHeight = 0; let spinePosition = 0; @@ -153,8 +155,8 @@ export function drawSewingMarks(sigDetails, position, papersize, amount, marginP const workingWidth = totalSpineHeight - 2 * marginPt; const spaceBetweenPoints = workingWidth / (amount + 1); - - let sewingPoints = []; + + const sewingPoints = []; for (let index = 1; index <= amount; index++) { const halfOfTape = tapeWidthPt / 2; sewingPoints.push( @@ -162,20 +164,19 @@ export function drawSewingMarks(sigDetails, position, papersize, amount, marginP { pointHeight: marginPt + spaceBetweenPoints * index - halfOfTape } ); } - + const allPoints = [ { pointHeight: marginPt }, { pointHeight: totalSpineHeight - marginPt }, ...sewingPoints, ]; - - const commonCircleValues = { size: 1, color: grayscale(0.0) }; + + const commonCircleValues = { size: 1, color: grayscale(0.0) }; const drawablePoints = allPoints.map((point) => { point = { ...point, ...commonCircleValues }; if (arePageRotated) { point.y = spinePosition; point.x = point.pointHeight + position.spineMarkBottom[0]; - } else { point.y = point.pointHeight + position.spineMarkBottom[1]; point.x = spinePosition;