home · contact · privacy
Bookmaker: more refactoring.
authorChristian Heller <c.heller@plomlompom.de>
Sun, 24 Sep 2023 18:40:23 +0000 (20:40 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Sun, 24 Sep 2023 18:40:23 +0000 (20:40 +0200)
bookmaker.py

index 8df8814afbaeb496245d0b1be3e8af9aa178dc9e..1c7240a8fd8c5d29d6357d57e54a2affee2e65b4 100755 (executable)
@@ -87,6 +87,7 @@ CUT_WIDTH = 1.05 * POINTS_PER_CM
 MIDDLE_POINT_DEPTH = 0.4 * POINTS_PER_CM
 SPINE_LIMIT = 1 * POINTS_PER_CM
 QUARTER_SCALE_FACTOR = 0.5
+PAGE_ORDER = (3,0,7,4,1,2,5,6)
 
 # some helpers
 class HandledException(Exception):
@@ -331,6 +332,7 @@ def main():
             print(f"built page number {i+1} (of {len(pages_to_add)})")
 
     else:
+        # --nup4 output
         print("-n: building 4-input-pages-per-output-page book")
         print(f"-m: applying printable-area margin of {args.print_margin}cm")
         if args.analyze:
@@ -351,23 +353,10 @@ def main():
             i += 1
             if i == 8:
                 i = 0
-                new_i_order += [8 * n_eights + 3,
-                                8 * n_eights + 0,
-                                8 * n_eights + 7,
-                                8 * n_eights + 4,
-                                8 * n_eights + 1,
-                                8 * n_eights + 2,
-                                8 * n_eights + 5,
-                                8 * n_eights + 6]
+                for n in PAGE_ORDER:
+                    new_i_order += [8 * n_eights + n]
+                    new_page_order += [eight_pack[n]]
                 n_eights += 1
-                new_page_order += [eight_pack[3]]  # page front, upper left
-                new_page_order += [eight_pack[0]]  # page front, upper right
-                new_page_order += [eight_pack[7]]  # page front, lower left
-                new_page_order += [eight_pack[4]]  # page front, lower right
-                new_page_order += [eight_pack[1]]  # page back, upper left
-                new_page_order += [eight_pack[2]]  # page back, upper right
-                new_page_order += [eight_pack[5]]  # page back, lower left
-                new_page_order += [eight_pack[6]]  # page back, lower right
         i = 0
         page_count = 0
         front_page = True