1
- import typing
2
-
3
1
strings = [
4
2
"""
3
+ straight rectangle
5
4
#########################
6
5
#########################
7
6
#########################
8
7
#########################
9
8
#########################
10
9
#########################""" ,
11
10
"""
11
+ rectangle with slot in it
12
12
#########################
13
13
#########################
14
14
#############
15
15
#########################
16
16
#########################
17
17
""" ,
18
18
"""
19
+ rectangle with notch
20
+ ###########
21
+ ###########
22
+ ##########
23
+ ###########
24
+ ###########""" ,
25
+ """
26
+ average triangle (op-amp)
19
27
#
20
28
###
21
29
#####
25
33
#
26
34
""" ,
27
35
"""
36
+ long triangle
28
37
#
29
38
######
30
39
###########
34
43
#
35
44
""" ,
36
45
"""
46
+ stubby triangle
37
47
#
38
48
#
39
49
#
49
59
#
50
60
""" ,
51
61
"""
62
+ half star (concave)
52
63
#
53
64
#
54
65
#
68
79
#
69
80
8000
code>
""" ,
70
81
"""
82
+ back end of xor gate
71
83
#
72
84
#
73
85
#
76
88
#
77
89
#""" ,
78
90
"""
91
+ or gate
79
92
######
80
93
########
81
94
#########
84
97
########
85
98
######""" ,
86
99
"""
100
+ and gate
101
+ #####
102
+ #######
103
+ #######
104
+ ########
105
+ #######
106
+ #######
107
+ #####
108
+ """ ,
109
+ """
110
+ not gate
111
+ #
112
+ ###
113
+ ##### ##
114
+ ###########
115
+ ##### ##
116
+ ###
117
+ #
118
+ """ ,
119
+ """
120
+ big O
87
121
###########
88
122
#############
89
123
###############
95
129
#############
96
130
###########""" ,
97
131
"""
132
+ thin thing 1
98
133
###############
99
134
###################""" ,
100
135
"""
136
+ thin thing 2
101
137
###############
102
138
###################
103
139
###############""" ,
104
140
"""
141
+ zigzag rectangle 1
105
142
################
106
143
################
107
144
################
111
148
################
112
149
################""" ,
113
150
"""
151
+ zigzag rectangle 2
114
152
# # # # # # # #
115
153
################
116
154
################
119
157
################
120
158
# # # # # # # #""" ,
121
159
"""
160
+ tilted rhombus
122
161
#
123
162
####
124
163
#######
137
176
####
138
177
#""" ,
139
178
"""
140
- ###########
141
- ###########
142
- ##########
143
- ###########
144
- ###########""" ]
145
-
146
- """
147
- idea for new algorithm
148
- * find all of the edge points
149
- * sort them by clockwise order around the perimeter
150
- * this is done not by sorting by angle around the centroid
151
- (that would only work for convex shapes) but by forming a list
152
- of edges between adjacent points and then walking the graph
153
- using a direction vector that is rotated only clockwise
154
- and starting from the rightmost point and starting down
155
- * handle the shapes that have holes in them by treating
156
- each edge as a separate shape, then merging the svgs
157
- * find all of the points that are concave
158
- * find all of the straight line points
159
- * assign each straight line point a distance from the nearest
160
- concave point
161
- * remove the concave points and straight line points that are closer
162
- than a threshold and are not a local maximum of distance
179
+ and just for the heck of it, a very big arrow
180
+ ##
181
+ ####
182
+ ######
183
+ ########
184
+ ##########
185
+ ############
186
+ ##############
187
+ ################
188
+ ##################
189
+ ####################
190
+ ######################
191
+ ########################
192
+ ##########################
193
+ ############################
194
+ ##############################
195
+ ################################
196
+ ##########
197
+ ##########
198
+ ##########
199
+ ##########
200
+ ##########
201
+ ##########
202
+ ##########
203
+ ##########
204
+ ##########
205
+ ##########
206
+ ##########
207
+ ##########
208
+ ##########
209
+ ##########
163
210
"""
211
+ ]
164
212
165
213
VN_DIRECTIONS : list [complex ] = [1 , 1j , - 1 , - 1j ]
166
214
DIRECTIONS : list [complex ] = [1 , 1 + 1j , 1j , - 1 + 1j , - 1 , - 1 - 1j , - 1j , 1 - 1j ]
@@ -182,21 +230,18 @@ def points_to_edges(
182
230
return edges
183
231
184
232
185
- T = typing .TypeVar ("T" )
186
-
187
-
188
- def cir (list : list [T ], is_forward : bool ) -> list [T ]:
233
+ def cir [T ](list : list [T ], is_forward : bool ) -> list [T ]:
189
234
if is_forward :
190
235
return list [1 :] + [list [0 ]]
191
236
else :
192
237
return [list [- 1 ]] + list [:- 1 ]
193
238
194
239
195
- def triples (v : list [T ]) -> list [tuple [T , T , T ]]:
240
+ def triples [ T ] (v : list [T ]) -> list [tuple [T , T , T ]]:
196
241
return list (zip (cir (v , False ), v , cir (v , True )))
197
242
198
243
199
- def fiveles (v : list [T ]) -> list [tuple [T , T , T ]]:
244
+ def fiveles [ T ] (v : list [T ]) -> list [tuple [T , T , T , T , T ]]:
200
245
x , y , z = cir (v , False ), v , cir (v , True )
201
246
return list (zip (cir (x , False ), x , y , z , cir (z , True )))
202
247
@@ -214,8 +259,7 @@ def cull_disallowed_edges(
214
259
continue
215
260
# if there are multiple directions out of here, find the gaps and
216
261
# only keep the ones on the sides of the gaps
217
- gaps = [p1 + d in all_points for d in DIRECTIONS ]
218
- tran_5 = fiveles (gaps )
262
+ tran_5 = fiveles ([p1 + d in all_points for d in DIRECTIONS ])
219
263
# im not quite sure what this is doing
220
264
fixed_edges [p1 ] = set (p1 + d for (d , (q , a , b , c , w ))
221
265
in zip (DIRECTIONS , tran_5 )
0 commit comments