Skip to content

Commit

Permalink
Fix printing on the edge
Browse files Browse the repository at this point in the history
  • Loading branch information
MikDal002 committed Apr 19, 2024
1 parent fbb5cc0 commit 97dde87
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
1 change: 0 additions & 1 deletion src/book.js
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,6 @@ export class Book {
? drawSewingMarks(
sigDetails[i],
positions[i],
papersize,
sewingMarks.amount,
sewingMarks.marginPt,
sewingMarks.tapeWidthPt
Expand Down
17 changes: 9 additions & 8 deletions src/utils/drawing.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand All @@ -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;
Expand All @@ -153,29 +155,28 @@ 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(
{ pointHeight: marginPt + spaceBetweenPoints * index + halfOfTape },
{ 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;
Expand Down

0 comments on commit 97dde87

Please sign in to comment.