From 2bb5aed8452fefba143bc75ca299400fd3294a2b Mon Sep 17 00:00:00 2001 From: Rebecca S Date: Mon, 29 May 2023 15:18:22 -0700 Subject: [PATCH] 8 page, single sheet zine (#40) * page layout logic lifted from old wip * finishing the 8 page zine --- index.html | 11 +++++++++ preload.js | 50 ++++++++++++++++++++++++++++++++++++++++- src/book.js | 4 +++- src/wacky_imposition.js | 46 +++++++++++++++++++++++++++++++++++++ 4 files changed, 109 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index 10b0f28..ab0b6da 100644 --- a/index.html +++ b/index.html @@ -244,6 +244,17 @@

Wacky Small Layouts

+ + + + +
+ Instructions +

+ The classic no-cut, single page zine! Just fold it up right and you've got yourself a mutant non-standard folio making an 8 page little fellow-- all extra pages beyond 8 are discarded. For better folding instructions than I could possibly write, see: https://www.quarantinepubliclibrary.com/tutorial +

+
+
diff --git a/preload.js b/preload.js index 2a0a3a7..92f8cc4 100644 --- a/preload.js +++ b/preload.js @@ -236,7 +236,7 @@ class Book { } this.rearrangedpages = this.book.pagelist; - } else if (this.format == 'a9_3_3_4' || this.format == 'a10_6_10s' || this.format == 'A7_2_16s' || this.format == '1_3rd' || this.format == 'a_3_6s' || this.format == 'a_4_8s') { + } else if (this.format == 'a9_3_3_4' || this.format == 'a10_6_10s' || this.format == 'A7_2_16s' || this.format == '1_3rd' || this.format == '8_zine'|| this.format == 'a_3_6s' || this.format == 'a_4_8s') { this.book = new _wacky_imposition_js__WEBPACK_IMPORTED_MODULE_5__.WackyImposition(this.orderedpages, this.duplex, this.format, this.pack_pages) } console.log("Created pages for : ",this.book) @@ -298,6 +298,8 @@ class Book { resultPDF = await this.buildSheets(this.filename, this.book.a7_2_16s_builder()); } else if (this.format == '1_3rd') { resultPDF = await this.buildSheets(this.filename, this.book.page_1_3rd_builder()); + } else if (this.format == '8_zine') { + resultPDF = await this.buildSheets(this.filename, this.book.page_8_zine_builder()); } console.log("Attempting to generate preview for ",resultPDF); @@ -30840,9 +30842,21 @@ class WackyImposition{ } else if (format == "A7_2_16s") { this.sheets = Math.ceil(pages.length/32.0); this.sigconfig = Array(this.sheets * 2) + } else if (format == "8_zine") { + this.sheets = 1; + this.sigconfig = [1]; } } + page_8_zine_builder() { + return { + sheetMaker: this.build_8_zine_sheetList.bind(this), + lineMaker: this.build_8_zine_lineFunction.bind(this), + isLandscape: false, + fileNameMod: "8_zine" + ((this.isPacked) ? "_packed" : "_spread") + } + } + page_1_3rd_builder() { return { sheetMaker: this.build_1_3rd_sheetList.bind(this), @@ -30897,9 +30911,26 @@ class WackyImposition{ } } + // ---------------- the real guts of the layout + /** + * It's an 8 page zine. Same page count every time.... + * + * @param pageCount - total pages in document (to add blanks if < 8) + * @return an array of a single sheets. It's just one printed page (face) + * The sheet is an array of rows, containing a list of page objects + */ + build_8_zine_sheetList(pageCount) { + let p = this.page; + let f = this.flipPage; + return [[ + this.auditForBlanks([ p(7),p(0),p(1),p(2) ], pageCount), + this.auditForBlanks([ f(6),f(5),f(4),f(3) ], pageCount) + ]]; + } + /** * Produces a 3 folio signature per sheet * @param pageCount - total pages in document @@ -30964,6 +30995,23 @@ class WackyImposition{ }; } + /** + * @return a FUNCTION. The function takes as it's parameter: + * Object definition: { + * gap: [leftGap, topGap], + * renderPageSize: [width, height], + * paperSize: [width, height], + * isFront: boolean, + * isPacked: boolean + * } + * and returns: a list of lines, as described by PDF-lib.js's `PDFPageDrawLineOptions` object + */ + build_8_zine_lineFunction() { + return info => { + return []; + }; + } + /** * Produces two 3 folio foldup signatures and a 4 folio foldup signature. * 5 rows, 4 pages across. 1-12 / 13-24 / 25 - 40 diff --git a/src/book.js b/src/book.js index 589894a..a73db1e 100644 --- a/src/book.js +++ b/src/book.js @@ -214,7 +214,7 @@ export class Book { } this.rearrangedpages = this.book.pagelist; - } else if (this.format == 'a9_3_3_4' || this.format == 'a10_6_10s' || this.format == 'A7_2_16s' || this.format == '1_3rd' || this.format == 'a_3_6s' || this.format == 'a_4_8s') { + } else if (this.format == 'a9_3_3_4' || this.format == 'a10_6_10s' || this.format == 'A7_2_16s' || this.format == '1_3rd' || this.format == '8_zine'|| this.format == 'a_3_6s' || this.format == 'a_4_8s') { this.book = new WackyImposition(this.orderedpages, this.duplex, this.format, this.pack_pages) } console.log("Created pages for : ",this.book) @@ -276,6 +276,8 @@ export class Book { resultPDF = await this.buildSheets(this.filename, this.book.a7_2_16s_builder()); } else if (this.format == '1_3rd') { resultPDF = await this.buildSheets(this.filename, this.book.page_1_3rd_builder()); + } else if (this.format == '8_zine') { + resultPDF = await this.buildSheets(this.filename, this.book.page_8_zine_builder()); } console.log("Attempting to generate preview for ",resultPDF); diff --git a/src/wacky_imposition.js b/src/wacky_imposition.js index 3e45e43..f06bba3 100644 --- a/src/wacky_imposition.js +++ b/src/wacky_imposition.js @@ -28,9 +28,21 @@ export class WackyImposition{ } else if (format == "A7_2_16s") { this.sheets = Math.ceil(pages.length/32.0); this.sigconfig = Array(this.sheets * 2) + } else if (format == "8_zine") { + this.sheets = 1; + this.sigconfig = [1]; } } + page_8_zine_builder() { + return { + sheetMaker: this.build_8_zine_sheetList.bind(this), + lineMaker: this.build_8_zine_lineFunction.bind(this), + isLandscape: false, + fileNameMod: "8_zine" + ((this.isPacked) ? "_packed" : "_spread") + } + } + page_1_3rd_builder() { return { sheetMaker: this.build_1_3rd_sheetList.bind(this), @@ -85,9 +97,26 @@ export class WackyImposition{ } } + // ---------------- the real guts of the layout + /** + * It's an 8 page zine. Same page count every time.... + * + * @param pageCount - total pages in document (to add blanks if < 8) + * @return an array of a single sheets. It's just one printed page (face) + * The sheet is an array of rows, containing a list of page objects + */ + build_8_zine_sheetList(pageCount) { + let p = this.page; + let f = this.flipPage; + return [[ + this.auditForBlanks([ p(7),p(0),p(1),p(2) ], pageCount), + this.auditForBlanks([ f(6),f(5),f(4),f(3) ], pageCount) + ]]; + } + /** * Produces a 3 folio signature per sheet * @param pageCount - total pages in document @@ -152,6 +181,23 @@ export class WackyImposition{ }; } + /** + * @return a FUNCTION. The function takes as it's parameter: + * Object definition: { + * gap: [leftGap, topGap], + * renderPageSize: [width, height], + * paperSize: [width, height], + * isFront: boolean, + * isPacked: boolean + * } + * and returns: a list of lines, as described by PDF-lib.js's `PDFPageDrawLineOptions` object + */ + build_8_zine_lineFunction() { + return info => { + return []; + }; + } + /** * Produces two 3 folio foldup signatures and a 4 folio foldup signature. * 5 rows, 4 pages across. 1-12 / 13-24 / 25 - 40