summaryrefslogtreecommitdiff
path: root/chip_design/solution-to-latex.py
diff options
context:
space:
mode:
Diffstat (limited to 'chip_design/solution-to-latex.py')
-rwxr-xr-xchip_design/solution-to-latex.py26
1 files changed, 12 insertions, 14 deletions
diff --git a/chip_design/solution-to-latex.py b/chip_design/solution-to-latex.py
index 798267a..6c74f4c 100755
--- a/chip_design/solution-to-latex.py
+++ b/chip_design/solution-to-latex.py
@@ -70,6 +70,11 @@ def print_boxes():
attrs = ','.join(attrs)
+ # HACK: print coords for debugging
+ if sys.argv[-1] == 'debug':
+ print(x, y, w, h)
+ continue
+
# For easier detection, reduce box dimension (add margin)
margin = 0.01
x += margin
@@ -80,22 +85,15 @@ def print_boxes():
tpl = r"\draw[{attrs}] ({x}, {y}) rectangle ({x2}, {y2});"
print(tpl.strip().format(**vars()))
+ # Reset for printing text
+ x, y, w, h = component
+ x2, y2 = x + w, y + h
+
# Draw number for debugging
tx = x + w/2
ty = y + h/2
- text = r"%s\\(%s x %s)" % (i, w, h)
+ text = r"%s\\(%s,%s)\\(%s x %s)" % (i, x, y, w, h)
print(r'\node[align=center] at (%f,%f) {%s};' % (tx, ty, text))
-def print_grid():
- # XXX currently hard-coding grid size
- print(r'\draw[step=1,gray,very thin] (0, 0) grid (30, 30);')
-
-if not True:
- # Complete picture
- print(r'\begin{tikzpicture}')
- print_grid()
- print_boxes()
- print(r'\end{tikzpicture}')
-else:
- # Just the boxes.
- print_boxes()
+# Just the boxes.
+print_boxes()