summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2020-12-28 14:35:59 +0100
committerDaniel Friesel <derf@finalrewind.org>2020-12-28 14:35:59 +0100
commit062456c25f078c3296c927640eb977dc828631ad (patch)
treec0d03371b5d680011c13d77eb25f757faf92297d
parent08ff22d0a5ad5dde52977c837588e058de0abe04 (diff)
export-carriage: double decker support
-rwxr-xr-xlib/export-carriage.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/export-carriage.py b/lib/export-carriage.py
index 88797b2..a0f6571 100755
--- a/lib/export-carriage.py
+++ b/lib/export-carriage.py
@@ -1,6 +1,7 @@
#!/usr/bin/env python3
import numpy as np
+import os
import subprocess
import sys
@@ -43,8 +44,19 @@ def main(infile, *outfiles):
ys = list()
for o in objects:
- if o.is_path() and o.h > 2 and o.h < 4 and o.w > 10:
+ if o.is_path() and o.h > 2 and o.h < 4 and o.w > 9:
ys.append(o.y)
+
+ ys = np.array(ys, dtype=np.int64)
+
+ if "double_decker_export" in os.environ:
+ # the first object is the "svg2" element describing the entire document
+ split = objects[0].h * 0.6
+ if os.environ["double_decker_export"] == "lower":
+ ys = ys[ys >= split]
+ else:
+ ys = ys[ys <= split]
+
bins = np.bincount(ys)
candidates = list(filter(lambda i: bins[i] > 2, range(len(bins))))