chore: init
This commit is contained in:
commit
edb31d2d31
13 changed files with 531 additions and 0 deletions
25
svg_columns.py
Normal file
25
svg_columns.py
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
"""Parse column rectangles from template.svg."""
|
||||
import re
|
||||
|
||||
|
||||
def parse_column_rects(svg_path):
|
||||
with open(svg_path) as f:
|
||||
content = f.read()
|
||||
blocks = re.findall(r"<rect[^>]+>", content)
|
||||
cols = []
|
||||
for block in blocks:
|
||||
x = float(re.search(r'x="([^"]+)"', block).group(1))
|
||||
y = float(re.search(r'y="([^"]+)"', block).group(1))
|
||||
w = float(re.search(r'width="([^"]+)"', block).group(1))
|
||||
h = float(re.search(r'height="([^"]+)"', block).group(1))
|
||||
cols.append({"x": x, "y": y, "w": w, "h": h})
|
||||
return cols
|
||||
|
||||
|
||||
def column_bounds(cols):
|
||||
return [(c["x"], c["x"] + c["w"]) for c in cols]
|
||||
|
||||
|
||||
def row_bounds(num_rows, table_y, table_height):
|
||||
step = table_height / num_rows
|
||||
return [(table_y + i * step, table_y + (i + 1) * step) for i in range(num_rows)]
|
||||
Loading…
Add table
Add a link
Reference in a new issue