Skip to content

Commit 3aec23e

Browse files
some better jack renderind
1 parent 44df3c9 commit 3aec23e

File tree

5 files changed

+83
-13
lines changed

5 files changed

+83
-13
lines changed

schemascii/components_render.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ def jack(
315315
t1 = terminals[0].pt
316316
t2 = t1 + rect(1, SIDE_TO_ANGLE_MAP[terminals[0].side])
317317
sc_t2 = t2 * scale
318-
sc_text_pt = sc_t2 + rect(scale, SIDE_TO_ANGLE_MAP[terminals[0].side])
318+
sc_text_pt = sc_t2 + rect(scale / 2, SIDE_TO_ANGLE_MAP[terminals[0].side])
319319
style = "input" if terminals[0].side in (
320320
Side.LEFT, Side.TOP) else "output"
321321
if any(bom_data.data.endswith(x)

schemascii/edgemarks.py

+2-7
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,8 @@ def flags(p: complex, s: Side) -> Flag | None:
3737
c = grid.get(p)
3838
if c in ' -|()*':
3939
return None
40-
if s in (Side.TOP, Side.BOTTOM):
41-
grid.setmask(p, '|')
42-
return Flag(p, c, s)
43-
if s in (Side.LEFT, Side.RIGHT):
44-
grid.setmask(p, '-')
45-
return Flag(p, c, s)
46-
return None
40+
grid.setmask(p, '*')
41+
return Flag(p, c, s)
4742
return flags
4843

4944

schemascii/utils.py

+12-4
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,9 @@ def find_dots(points: list[tuple[complex, complex]]) -> list[complex]:
145145
"Finds all the points where there are 4 or more connecting wires."
146146
seen = {}
147147
for p1, p2 in points:
148+
if p1 == p2:
149+
# Skip zero-length wires
150+
continue
148151
if p1 not in seen:
149152
seen[p1] = 1
150153
else:
@@ -202,17 +205,22 @@ def id_text(
202205
for x, (y, six) in zip(text.split(","), unit))
203206
classy = "cmp-value"
204207
data = XML.tspan(text, class_=classy)
208+
if len(terminals) > 1:
209+
textach = "start" if (
210+
any(Side.BOTTOM == t.side for t in terminals)
211+
or any(Side.TOP == t.side for t in terminals)
212+
) else "middle"
213+
else:
214+
textach = "middle" if terminals[0].side in (
215+
Side.TOP, Side.BOTTOM) else "start"
205216
return XML.text(
206217
(XML.tspan(f"{box.type}{box.id}", class_="cmp-id")
207218
* bool("L" in label_style)),
208219
" " * (bool(data) and "L" in label_style),
209220
data * bool("V" in label_style),
210221
x=point.real,
211222
y=point.imag,
212-
text__anchor="start" if (
213-
any(Side.BOTTOM == t.side for t in terminals)
214-
or any(Side.TOP == t.side for t in terminals)
215-
) else "middle",
223+
text__anchor=textach,
216224
font__size=options["scale"],
217225
fill=options["stroke"])
218226

scripts/release.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def writefile(file, text):
3939
re.sub(r'__version__ = "[\d.]+"',
4040
f'__version__ = "{args.version}"', init_text))
4141

42-
42+
cmd("scripts/docs.py")
4343
cmd("python3 -m build --sdist")
4444
cmd("python3 -m build --wheel")
4545

test_data/all_gates_3t.txt

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
Q:nfet: R:1k !label=V!!padding=30!
2+
J1:A J2:B J4:VCC,circle J5:gnd,circle
3+
J1 J2 J4 J5
4+
| | | |
5+
| | *-R-----*----------J1001 J1001:NAND
6+
| | | | d
7+
*----------------gQ
8+
| | | | s
9+
| | | | d
10+
| *-------------gQ
11+
| | | | s
12+
| | | *--*
13+
| | | |
14+
| | *-R-----*---*------J1002 J1002:NOR
15+
| | | | d d
16+
*----------------gQ *gQ
17+
| | | | s | s
18+
| | | *--*-|-*
19+
| *-----------|----*
20+
| | | |
21+
| | *-R---------*------J1003 J1003:XNOR
22+
| | | | |
23+
| | | | d-*
24+
*----------------*-gQ |
25+
| | | | | s |
26+
| *--------------*-* |
27+
| | | | || |
28+
| | | | || d-*
29+
| | | | |*gQ
30+
| | | | | s
31+
| | | | *--*
32+
| | | |
33+
| | *-R-------*--------J1004 J1004:AND
34+
| | | | d
35+
| | *-R-----*gQ
36+
| | | | d s
37+
*----------------gQ |
38+
| | | | s |
39+
| | | | d |
40+
| *-------------gQ |
41+
| | | | s |
42+
| | | *--*-*
43+
| | | |
44+
| | *-R-----------*----J1005 J1005:OR
45+
| | | | d
46+
| | *-R-----*---*gQ
47+
| | | | d d s
48+
*----------------gQ *gQ |
49+
| | | | s | s |
50+
| | | *--*-|-*-*
51+
| *-----------|----*
52+
| | | |
53+
| | *-R-----------*----J1006 J1006:XOR
54+
| | | | |
55+
| | *-R---------* |
56+
| | | | | |
57+
| | | | d-* |
58+
*----------------*-gQ | |
59+
| | | | | s | |
60+
| *--------------*-* | |
61+
| | | | || | d
62+
| | | | || d-*gQ
63+
| | | | |*gQ s
64+
| | | | | s |
65+
| | | | *--* |
66+
| | | *--------*
67+
| | | |

0 commit comments

Comments
 (0)