Skip to content

Commit

Permalink
added folio crosshairs
Browse files Browse the repository at this point in the history
  • Loading branch information
sithel committed Jan 16, 2025
1 parent 28f206a commit ceb508b
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 10 deletions.
14 changes: 7 additions & 7 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@
.printed_page_markup_options {
margin-left: 40px;
}
#fold_line_weight, #cut_line_weight, #markup_crosshairs_weight, #markup_spine_order_weight, #markup_spine_bounds_weight {
#fold_line_weight, #cut_line_weight, #markup_crosshairs_weight, #markup_spine_order_weight, #markup_spine_bounds_weight, #markup_crosshairs_length {
width: 4em;
padding: 0px 4px;
margin-left: 10px;
Expand Down Expand Up @@ -644,7 +644,7 @@ <h2>6. Markup</h2>
<div class="printed_page_markup_options">
<input type="checkbox" id="markup_fold_lines" name="markup_fold_lines" value="fold"> <label for="markup_fold_lines"> fold lines</label> <Input type=number id="fold_line_weight" placeholder="2"/> <span id="fold_line_weight_label">line weight (pt)</span></br>
<input type="checkbox" id="markup_cut_lines" name="markup_cut_lines" value="cut"> <label for="markup_cut_lines"> cut lines</label> <Input type=number id="cut_line_weight" placeholder="2"/> <span id="cut_line_weight_label">line weight (pt)</span></br>
<input type="checkbox" id="markup_crosshairs" name="markup_crosshairs" value="cross"> <label for="markup_crosshairs"> cross-hairs</label> <Input type=number id="markup_crosshairs_weight" placeholder="2"/> <span id="markup_crosshairs_weight_label">line weight (pt)</span></br>
<input type="checkbox" id="markup_crosshairs" name="markup_crosshairs" value="cross"> <label for="markup_crosshairs"> cross-hairs</label> <Input type=number id="markup_crosshairs_weight" placeholder="2"/> <span id="markup_crosshairs_weight_label">line weight (pt)</span> | <Input type=number id="markup_crosshairs_length" placeholder="15"/> <span id="markup_crosshairs_length_label">cross-hair leg length (pt)</span></br>
<input type="checkbox" id="markup_spine_order" name="markup_spine_order" value="order"> <label for="markup_spine_order"> spine marks: order</label> <Input type=number id="markup_spine_order_weight" placeholder="2"/> <span id="markup_spine_order_weight_label">line weight (pt)</span></br>
<input type="checkbox" id="markup_spine_bounds" name="markup_spine_bounds" value="order"> <label for="markup_spine_bounds"> spine marks: bounds</label> <Input type=number id="markup_spine_bounds_weight" placeholder="2"/> <span id="markup_spine_bounds_weight_label">line weight (pt)</span></br>
<div>
Expand All @@ -657,11 +657,11 @@ <h2>6. Markup</h2>
</select>
<br/>
<div>
<input type="number" id="markup_sewing_dist_top" name="markup_sewing_dist_top" value="sewing_count"> <label for="markup_sewing_dist_top"> distance from head to top hole (pt)</label> <br/>
<input type="number" id="markup_sewing_dist_bottom" name="markup_sewing_dist_bottom" value="sewing_count"> <label for="markup_sewing_dist_bottom"> distance from tail to bottom hole (pt)</label> <br/>
<input type="number" id="markup_sewing_count" name="markup_sewing_count" value="sewing_count"> <label for="markup_sewing_count"> count of sewing stations</label> <br/>
<input type="number" id="markup_sewing_station_dist" name="markup_sewing_station_dist" value="sewing_count"> <label for="markup_sewing_station_dist"> distance between points at each sewing station (pt)</label> <br/>
<input type="number" id="markup_sewing_dot_size" name="markup_sewing_dot_size" value="sewing_count"> <label for="markup_sewing_dot_size"> guideline dot size (pt)</label>
<input type="number" id="markup_sewing_dist_top" name="markup_sewing_dist_top" placeholder="6"> <label for="markup_sewing_dist_top"> distance from head to top hole (pt)</label> <br/>
<input type="number" id="markup_sewing_dist_bottom" name="markup_sewing_dist_bottom" placeholder="5"> <label for="markup_sewing_dist_bottom"> distance from tail to bottom hole (pt)</label> <br/>
<input type="number" id="markup_sewing_count" name="markup_sewing_count" placeholder="4"> <label for="2"> count of sewing stations</label> <br/>
<input type="number" id="markup_sewing_station_dist" name="markup_sewing_station_dist" placeholder="3"> <label for="markup_sewing_station_dist"> distance between points at each sewing station (pt)</label> <br/>
<input type="number" id="markup_sewing_dot_size" name="markup_sewing_dot_size" placeholder="2"> <label for="markup_sewing_dot_size"> guideline dot size (pt)</label>
</div>
</div>
</div>
Expand Down
28 changes: 25 additions & 3 deletions js/imposer.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,23 +243,45 @@ export const imposerMagic = {
});
}
},
_calcDimens: function(new_page) {
_calcDimens: function(new_page, x, y) {
return {
pW : new_page.getWidth() - window.book.physical.short_margin * 2,
pH : new_page.getHeight() - window.book.physical.long_margin * 2,
renderPage : this._renderPage.bind(this),
flip_short : document.getElementById("flip_paper_short").checked
}
},
_collectValueOrPlaceholder: function(el) {
const v = parseFloat(el.value)
return (isNaN(v)) ? parseFloat(el.placeholder) : v
},
_renderCrossHair: function(new_page, x, y) {
if (!document.getElementById("markup_crosshairs").checked)
return;
const len = this._collectValueOrPlaceholder(document.getElementById("markup_crosshairs_length"))
const weight = this._collectValueOrPlaceholder(document.getElementById("markup_crosshairs_weight"))
const color = PDFLib.rgb(0.75, 0.2, 0.2);
new_page.drawLine({
start: { x: x - len, y: y }, end: { x: x + len, y: y },
thickness: weight, color: color, opacity: 0.75,
});
new_page.drawLine({
start: { x: x, y: y - len }, end: { x: x, y: y + len },
thickness: weight, color: color, opacity: 0.75,
});
},
_handleSingle: function(new_page, pageMap, folio_list, sheet_index, is_front) {
this._renderPage(new_page, pageMap[folio_list[0]], 0, 0)
},
_handleFolio: function(new_page, pageMap, folio_list, sheet_index, is_front) {
const {pW, pH, renderPage, flip_short} = this._calcDimens(new_page)
const [cell_w, cell_h] = [pW, pH/2.0]
folio_list.forEach(function(f, i) {
renderPage(new_page, pageMap, f[(is_front) ? 0 : (flip_short) ? 2 : 1], 0, pH/2, (!is_front && !flip_short) ? BOTTOM_TO_LEFT : BOTTOM_TO_RIGHT)
renderPage(new_page, pageMap, f[(is_front) ? 3 : (flip_short) ? 1 : 2], 0, 0, (!is_front && !flip_short) ? BOTTOM_TO_LEFT : BOTTOM_TO_RIGHT)
renderPage(new_page, pageMap, f[(is_front) ? 0 : (flip_short) ? 2 : 1], 0, pH/2, cell_w, cell_h, (!is_front && !flip_short) ? BOTTOM_TO_LEFT : BOTTOM_TO_RIGHT)
renderPage(new_page, pageMap, f[(is_front) ? 3 : (flip_short) ? 1 : 2], 0, 0, cell_w, cell_h, (!is_front && !flip_short) ? BOTTOM_TO_LEFT : BOTTOM_TO_RIGHT)
})
this._renderCrossHair(new_page, pW, pH/2.0);
this._renderCrossHair(new_page, 0, pH/2.0);
},
_handleQuarto: function(new_page, pageMap, folio_list, sheet_index, is_front) {
const {pW, pH, renderPage, flip_short} = this._calcDimens(new_page)
Expand Down

0 comments on commit ceb508b

Please sign in to comment.