Skip to content

Commit 0ee990c

Browse files
fix side angle and box sizing
still need to add IC labels to pins
1 parent 23fea8d commit 0ee990c

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

schemascii/components_render.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,14 @@ def diode(
181181
+ polylinegon(triangle, True, **kwargs))
182182

183183

184+
SIDE_TO_ANGLE_MAP = {
185+
Side.RIGHT: pi,
186+
Side.TOP: pi / 2,
187+
Side.LEFT: 0,
188+
Side.RIGHT: 3 * pi / 2,
189+
}
190+
191+
184192
@component("U", "IC")
185193
@no_ambiguous
186194
def integrated_circuit(
@@ -190,10 +198,10 @@ def integrated_circuit(
190198
**kwargs):
191199
"Draw an IC"
192200
scale = kwargs.get("scale", 1)
193-
sz = (box.p2 - box.p1 + 2) * scale
201+
sz = (box.p2 - box.p1) * scale
194202
mid = (box.p2 + box.p1) * scale / 2
195203
out = XML.rect(
196-
x=box.p1.real * scale - scale,
204+
x=box.p1.real * scale,
197205
y=box.p1.imag * scale,
198206
width=sz.real,
199207
height=sz.imag,
@@ -202,7 +210,7 @@ def integrated_circuit(
202210
for term in terminals:
203211
out += bunch_o_lines([(
204212
term.pt,
205-
term.pt + rect(1, term.side * pi / 2)
213+
term.pt + rect(1, SIDE_TO_ANGLE_MAP[term.side])
206214
)], **kwargs)
207215
out += XML.text(
208216
XML.tspan(f"{box.type}{box.id}", class_="cmp-id"),

0 commit comments

Comments
 (0)