@@ -29,12 +29,12 @@ def n_check(
29
29
box : Cbox ,
30
30
terminals : list [Terminal ],
31
31
bom_data : list [BOMData ],
32
- ** kwargs ):
32
+ ** options ):
33
33
if len (terminals ) != n_terminals :
34
34
raise TerminalsError (
35
35
f"{ box .type } { box .id } component can only "
36
36
f"have { n_terminals } terminals" )
37
- return func (box , terminals , bom_data , ** kwargs )
37
+ return func (box , terminals , bom_data , ** options )
38
38
return n_check
39
39
return n_inner
40
40
@@ -45,15 +45,15 @@ def de_ambiguous(
45
45
box : Cbox ,
46
46
terminals : list [Terminal ],
47
47
bom_data : list [BOMData ],
48
- ** kwargs ):
48
+ ** options ):
49
49
if len (bom_data ) > 1 :
50
50
raise BOMError (
51
51
f"Ambiguous BOM data for { box .type } { box .id } : { bom_data !r} " )
52
52
return func (
53
53
box ,
54
54
terminals ,
55
55
bom_data [0 ] if bom_data else None ,
56
- ** kwargs )
56
+ ** options )
57
57
return de_ambiguous
58
58
59
59
@@ -64,7 +64,7 @@ def sort_terminals(
64
64
box : Cbox ,
65
65
terminals : list [Terminal ],
66
66
bom_data : list [BOMData ],
67
- ** kwargs ):
67
+ ** options ):
68
68
if len (terminals ) != 2 :
69
69
raise TerminalsError (
70
70
f"{ box .type } { box .id } component can only "
@@ -75,7 +75,7 @@ def sort_terminals(
75
75
box ,
76
76
terminals ,
77
77
bom_data ,
78
- ** kwargs )
78
+ ** options )
79
79
return sort_terminals
80
80
81
81
@@ -86,7 +86,7 @@ def resistor(
86
86
box : Cbox ,
87
87
terminals : list [Terminal ],
88
88
bom_data : BOMData | None ,
89
- ** kwargs ):
89
+ ** options ):
90
90
"Draw a resistor"
91
91
t1 , t2 = terminals [0 ].pt , terminals [1 ].pt
92
92
vec = t1 - t2
@@ -99,12 +99,12 @@ def resistor(
99
99
points .append (t1 - rect (i / 4 , angle ) +
100
100
pow (- 1 , i ) * rect (1 , quad_angle ) / 4 )
101
101
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 )
105
105
+ id_text (
106
106
box , bom_data , terminals , (("Ω" , False ), ("W" , False )),
107
- text_pt , ** kwargs ))
107
+ text_pt , ** options ))
108
108
109
109
110
110
@component ("C" , "CV" , "VC" )
@@ -114,7 +114,7 @@ def capacitor(
114
114
box : Cbox ,
115
115
terminals : list [Terminal ],
116
116
bom_data : BOMData | None ,
117
- ** kwargs ):
117
+ ** options ):
118
118
"Draw a capacitor"
119
119
t1 , t2 = terminals [0 ].pt , terminals [1 ].pt
120
120
mid = (t1 + t2 ) / 2
@@ -125,13 +125,13 @@ def capacitor(
125
125
(complex (.4 , .25 ), complex (- .4 , .25 )),
126
126
(complex (.4 , - .25 ), complex (- .4 , - .25 )),
127
127
], 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 )
132
132
+ id_text (
133
133
box , bom_data , terminals , (("F" , True ), ("V" , False )),
134
- text_pt , ** kwargs ))
134
+ text_pt , ** options ))
135
135
136
136
137
137
@component ("B" , "BT" , "BAT" )
@@ -141,7 +141,7 @@ def battery(
141
141
box : Cbox ,
142
142
terminals : list [Terminal ],
143
143
bom_data : BOMData | None ,
144
- ** kwargs ):
144
+ ** options ):
145
145
"Draw a battery cell"
146
146
t1 , t2 = terminals [0 ].pt , terminals [1 ].pt
147
147
mid = (t1 + t2 ) / 2
@@ -154,11 +154,11 @@ def battery(
154
154
(complex (.5 , - .16 ), complex (- .5 , - .16 )),
155
155
(complex (.25 , - .5 ), complex (- .25 , - .5 )),
156
156
], mid , angle )
157
- text_pt = make_text_point (t1 , t2 , ** kwargs )
157
+ text_pt = make_text_point (t1 , t2 , ** options )
158
158
return (id_text (
159
159
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 ))
162
162
163
163
164
164
@component ("D" , "LED" , "CR" , "IR" )
@@ -168,7 +168,7 @@ def diode(
168
168
box : Cbox ,
169
169
terminals : list [Terminal ],
170
170
bom_data : BOMData | None ,
171
- ** kwargs ):
171
+ ** options ):
172
172
"Draw a diode or LED"
173
173
t1 , t2 = terminals [0 ].pt , terminals [1 ].pt
174
174
mid = (t1 + t2 ) / 2
@@ -178,10 +178,10 @@ def diode(
178
178
(t1 , mid + rect (- .3 , angle )),
179
179
deep_transform ((- .3 - .3j , .3 - .3j ), mid , angle )]
180
180
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 ))
185
185
186
186
187
187
SIDE_TO_ANGLE_MAP = {
@@ -198,33 +198,33 @@ def integrated_circuit(
198
198
box : Cbox ,
199
199
terminals : list [Terminal ],
200
200
bom_data : BOMData | None ,
201
- ** kwargs ):
201
+ ** options ):
202
202
"Draw an IC"
203
- scale = kwargs .get ("scale" , 1 )
203
+ scale = options .get ("scale" , 1 )
204
204
sz = (box .p2 - box .p1 ) * scale
205
205
mid = (box .p2 + box .p1 ) * scale / 2
206
206
out = XML .rect (
207
207
x = box .p1 .real * scale ,
208
208
y = box .p1 .imag * scale ,
209
209
width = sz .real ,
210
210
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" ),
213
213
fill = "none" )
214
214
for term in terminals :
215
215
out += bunch_o_lines ([(
216
216
term .pt ,
217
217
term .pt + rect (1 , SIDE_TO_ANGLE_MAP [term .side ])
218
- )], ** kwargs )
218
+ )], ** options )
219
219
out += XML .text (
220
220
XML .tspan (f"{ box .type } { box .id } " , class_ = "cmp-id" ),
221
221
" " * bool (bom_data .data ),
222
222
XML .tspan (bom_data .data , class_ = "part-num" ),
223
223
x = mid .real ,
224
224
y = mid .imag ,
225
225
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" ))
228
228
print ("IC's in progress..." )
229
229
return out
230
230
@@ -258,12 +258,12 @@ def render_component(
258
258
box : Cbox ,
259
259
terminals : list [Terminal ],
260
260
bom_data : list [BOMData ],
261
- ** kwargs ):
261
+ ** options ):
262
262
"Render the component into an SVG string."
263
263
if box .type not in RENDERERS :
264
264
raise UnsupportedComponentError (box .type )
265
265
return XML .g (
266
- RENDERERS [box .type ](box , terminals , bom_data , ** kwargs ),
266
+ RENDERERS [box .type ](box , terminals , bom_data , ** options ),
267
267
class_ = f"component { box .type } "
268
268
)
269
269
0 commit comments