Skip to content

Commit c2d1cfa

Browse files
options rename
1 parent 2717793 commit c2d1cfa

File tree

2 files changed

+37
-37
lines changed

2 files changed

+37
-37
lines changed

schemascii/components_render.py

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ def n_check(
2929
box: Cbox,
3030
terminals: list[Terminal],
3131
bom_data: list[BOMData],
32-
**kwargs):
32+
**options):
3333
if len(terminals) != n_terminals:
3434
raise TerminalsError(
3535
f"{box.type}{box.id} component can only "
3636
f"have {n_terminals} terminals")
37-
return func(box, terminals, bom_data, **kwargs)
37+
return func(box, terminals, bom_data, **options)
3838
return n_check
3939
return n_inner
4040

@@ -45,15 +45,15 @@ def de_ambiguous(
4545
box: Cbox,
4646
terminals: list[Terminal],
4747
bom_data: list[BOMData],
48-
**kwargs):
48+
**options):
4949
if len(bom_data) > 1:
5050
raise BOMError(
5151
f"Ambiguous BOM data for {box.type}{box.id}: {bom_data!r}")
5252
return func(
5353
box,
5454
terminals,
5555
bom_data[0] if bom_data else None,
56-
**kwargs)
56+
**options)
5757
return de_ambiguous
5858

5959

@@ -64,7 +64,7 @@ def sort_terminals(
6464
box: Cbox,
6565
terminals: list[Terminal],
6666
bom_data: list[BOMData],
67-
**kwargs):
67+
**options):
6868
if len(terminals) != 2:
6969
raise TerminalsError(
7070
f"{box.type}{box.id} component can only "
@@ -75,7 +75,7 @@ def sort_terminals(
7575
box,
7676
terminals,
7777
bom_data,
78-
**kwargs)
78+
**options)
7979
return sort_terminals
8080

8181

@@ -86,7 +86,7 @@ def resistor(
8686
box: Cbox,
8787
terminals: list[Terminal],
8888
bom_data: BOMData | None,
89-
**kwargs):
89+
**options):
9090
"Draw a resistor"
9191
t1, t2 = terminals[0].pt, terminals[1].pt
9292
vec = t1 - t2
@@ -99,12 +99,12 @@ def resistor(
9999
points.append(t1 - rect(i / 4, angle) +
100100
pow(-1, i) * rect(1, quad_angle) / 4)
101101
points.append(t2)
102-
text_pt = make_text_point(t1, t2, **kwargs)
103-
return (polylinegon(points, **kwargs)
104-
+ make_variable(mid, angle, "V" in box.type, **kwargs)
102+
text_pt = make_text_point(t1, t2, **options)
103+
return (polylinegon(points, **options)
104+
+ make_variable(mid, angle, "V" in box.type, **options)
105105
+ id_text(
106106
box, bom_data, terminals, (("Ω", False), ("W", False)),
107-
text_pt, **kwargs))
107+
text_pt, **options))
108108

109109

110110
@component("C", "CV", "VC")
@@ -114,7 +114,7 @@ def capacitor(
114114
box: Cbox,
115115
terminals: list[Terminal],
116116
bom_data: BOMData | None,
117-
**kwargs):
117+
**options):
118118
"Draw a capacitor"
119119
t1, t2 = terminals[0].pt, terminals[1].pt
120120
mid = (t1 + t2) / 2
@@ -125,13 +125,13 @@ def capacitor(
125125
(complex(.4, .25), complex(-.4, .25)),
126126
(complex(.4, -.25), complex(-.4, -.25)),
127127
], mid, angle)
128-
text_pt = make_text_point(t1, t2, **kwargs)
129-
return (bunch_o_lines(lines, **kwargs)
130-
+ make_plus(terminals, mid, angle, **kwargs)
131-
+ make_variable(mid, angle, "V" in box.type, **kwargs)
128+
text_pt = make_text_point(t1, t2, **options)
129+
return (bunch_o_lines(lines, **options)
130+
+ make_plus(terminals, mid, angle, **options)
131+
+ make_variable(mid, angle, "V" in box.type, **options)
132132
+ id_text(
133133
box, bom_data, terminals, (("F", True), ("V", False)),
134-
text_pt, **kwargs))
134+
text_pt, **options))
135135

136136

137137
@component("B", "BT", "BAT")
@@ -141,7 +141,7 @@ def battery(
141141
box: Cbox,
142142
terminals: list[Terminal],
143143
bom_data: BOMData | None,
144-
**kwargs):
144+
**options):
145145
"Draw a battery cell"
146146
t1, t2 = terminals[0].pt, terminals[1].pt
147147
mid = (t1 + t2) / 2
@@ -154,11 +154,11 @@ def battery(
154154
(complex(.5, -.16), complex(-.5, -.16)),
155155
(complex(.25, -.5), complex(-.25, -.5)),
156156
], mid, angle)
157-
text_pt = make_text_point(t1, t2, **kwargs)
157+
text_pt = make_text_point(t1, t2, **options)
158158
return (id_text(
159159
box, bom_data, terminals, (("V", False), ("Ah", False)),
160-
text_pt, **kwargs)
161-
+ bunch_o_lines(lines, **kwargs))
160+
text_pt, **options)
161+
+ bunch_o_lines(lines, **options))
162162

163163

164164
@component("D", "LED", "CR", "IR")
@@ -168,7 +168,7 @@ def diode(
168168
box: Cbox,
169169
terminals: list[Terminal],
170170
bom_data: BOMData | None,
171-
**kwargs):
171+
**options):
172172
"Draw a diode or LED"
173173
t1, t2 = terminals[0].pt, terminals[1].pt
174174
mid = (t1 + t2) / 2
@@ -178,10 +178,10 @@ def diode(
178178
(t1, mid + rect(-.3, angle)),
179179
deep_transform((-.3-.3j, .3-.3j), mid, angle)]
180180
triangle = deep_transform((-.3j, .3+.3j, -.3+.3j), mid, angle)
181-
text_pt = make_text_point(t1, t2, **kwargs)
182-
return (id_text(box, bom_data, terminals, None, text_pt, **kwargs)
183-
+ bunch_o_lines(lines, **kwargs)
184-
+ polylinegon(triangle, True, **kwargs))
181+
text_pt = make_text_point(t1, t2, **options)
182+
return (id_text(box, bom_data, terminals, None, text_pt, **options)
183+
+ bunch_o_lines(lines, **options)
184+
+ polylinegon(triangle, True, **options))
185185

186186

187187
SIDE_TO_ANGLE_MAP = {
@@ -198,33 +198,33 @@ def integrated_circuit(
198198
box: Cbox,
199199
terminals: list[Terminal],
200200
bom_data: BOMData | None,
201-
**kwargs):
201+
**options):
202202
"Draw an IC"
203-
scale = kwargs.get("scale", 1)
203+
scale = options.get("scale", 1)
204204
sz = (box.p2 - box.p1) * scale
205205
mid = (box.p2 + box.p1) * scale / 2
206206
out = XML.rect(
207207
x=box.p1.real * scale,
208208
y=box.p1.imag * scale,
209209
width=sz.real,
210210
height=sz.imag,
211-
stroke__width=kwargs.get("stroke_width", 1),
212-
stroke=kwargs.get("stroke", "black"),
211+
stroke__width=options.get("stroke_width", 1),
212+
stroke=options.get("stroke", "black"),
213213
fill="none")
214214
for term in terminals:
215215
out += bunch_o_lines([(
216216
term.pt,
217217
term.pt + rect(1, SIDE_TO_ANGLE_MAP[term.side])
218-
)], **kwargs)
218+
)], **options)
219219
out += XML.text(
220220
XML.tspan(f"{box.type}{box.id}", class_="cmp-id"),
221221
" " * bool(bom_data.data),
222222
XML.tspan(bom_data.data, class_="part-num"),
223223
x=mid.real,
224224
y=mid.imag,
225225
text__anchor="middle",
226-
font__size=kwargs.get("scale", 1),
227-
fill=kwargs.get("stroke", "black"))
226+
font__size=options.get("scale", 1),
227+
fill=options.get("stroke", "black"))
228228
print("IC's in progress...")
229229
return out
230230

@@ -258,12 +258,12 @@ def render_component(
258258
box: Cbox,
259259
terminals: list[Terminal],
260260
bom_data: list[BOMData],
261-
**kwargs):
261+
**options):
262262
"Render the component into an SVG string."
263263
if box.type not in RENDERERS:
264264
raise UnsupportedComponentError(box.type)
265265
return XML.g(
266-
RENDERERS[box.type](box, terminals, bom_data, **kwargs),
266+
RENDERERS[box.type](box, terminals, bom_data, **options),
267267
class_=f"component {box.type}"
268268
)
269269

schemascii/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,14 +192,14 @@ def make_plus(
192192
terminals: list[Terminal],
193193
center: complex,
194194
theta: float,
195-
**kwargs) -> str:
195+
**options) -> str:
196196
"Make a + sign if the terminals indicate the component is polarized."
197197
if all(t.flag != "+" for t in terminals):
198198
return ""
199199
return XML.g(
200200
bunch_o_lines(deep_transform(deep_transform(
201201
[(.125, -.125), (.125j, -.125j)], 0, theta),
202-
center + deep_transform(.33+.75j, 0, theta), 0), **kwargs),
202+
center + deep_transform(.33+.75j, 0, theta), 0), **options),
203203
class_="plus")
204204

205205

0 commit comments

Comments
 (0)