Skip to content

Commit

Permalink
8 page, single sheet zine (#40)
Browse files Browse the repository at this point in the history
* page layout logic lifted from old wip

* finishing the 8 page zine
  • Loading branch information
sithel authored May 29, 2023
1 parent dcbba1b commit 2bb5aed
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 2 deletions.
11 changes: 11 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,17 @@ <h3>Wacky Small Layouts</h3>
</p>
</details>
</span>
<span class="row"> <input type="radio" id="8_zine" name="sig_format" value="8_zine">
<label for="8_zine">Single Sheet Zine - 8 per side <sub>(one sided printed page foldup)</sub></label>
</span>
<span class="row instruction-indent">
<details>
<summary>Instructions</summary>
<p>
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: <a href="https://www.quarantinepubliclibrary.com/tutorial">https://www.quarantinepubliclibrary.com/tutorial</a>
</p>
</details>
</span>
<span class="row"> <input type="radio" id="a_3_6s" name="sig_format" value="a_3_6s">
<label for="a_3_6s">Small - 18 per side <sub>(3 folio signature per row x 3)</sub></label>
</span>
Expand Down
50 changes: 49 additions & 1 deletion preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion src/book.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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);

Expand Down
46 changes: 46 additions & 0 deletions src/wacky_imposition.js
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 2bb5aed

Please sign in to comment.