ConsoleFramework 2.0.2__tar.gz → 2.0.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {consoleframework-2.0.2 → consoleframework-2.0.4}/ConsoleFramework/__init__.py +270 -61
- {consoleframework-2.0.2 → consoleframework-2.0.4}/ConsoleFramework.egg-info/PKG-INFO +1 -1
- {consoleframework-2.0.2 → consoleframework-2.0.4}/ConsoleFramework.egg-info/SOURCES.txt +1 -3
- {consoleframework-2.0.2 → consoleframework-2.0.4}/PKG-INFO +1 -1
- {consoleframework-2.0.2 → consoleframework-2.0.4}/setup.py +1 -1
- consoleframework-2.0.2/MANIFEST.in +0 -4
- {consoleframework-2.0.2 → consoleframework-2.0.4}/ConsoleFramework.egg-info/dependency_links.txt +0 -0
- {consoleframework-2.0.2 → consoleframework-2.0.4}/ConsoleFramework.egg-info/not-zip-safe +0 -0
- {consoleframework-2.0.2 → consoleframework-2.0.4}/ConsoleFramework.egg-info/top_level.txt +0 -0
- {consoleframework-2.0.2 → consoleframework-2.0.4}/LICENSE +0 -0
- {consoleframework-2.0.2 → consoleframework-2.0.4}/setup.cfg +0 -0
|
@@ -19,6 +19,8 @@ import stat
|
|
|
19
19
|
import subprocess as CMD
|
|
20
20
|
import threading
|
|
21
21
|
import urllib.request
|
|
22
|
+
import urllib.parse
|
|
23
|
+
import base64
|
|
22
24
|
class Colors:
|
|
23
25
|
RESET = "\033[0m"
|
|
24
26
|
RED = "\033[31m"
|
|
@@ -67,15 +69,39 @@ class Render:
|
|
|
67
69
|
field = [[default_char for _ in range(width)] for _ in range(height)]
|
|
68
70
|
if points:
|
|
69
71
|
for item in points:
|
|
70
|
-
if len(item)
|
|
71
|
-
x, y, char = item
|
|
72
|
+
if len(item) >= 3:
|
|
73
|
+
x, y, char = item[0], item[1], item[2]
|
|
72
74
|
if 0 <= x < width and 0 <= y < height:
|
|
73
|
-
|
|
75
|
+
if len(item) == 4:
|
|
76
|
+
color = item[3]
|
|
77
|
+
field[y][x] = f"{color}{char}{Colors.RESET}"
|
|
78
|
+
elif len(item) == 5:
|
|
79
|
+
color, bg = item[3], item[4]
|
|
80
|
+
field[y][x] = f"{color}{bg}{char}{Colors.RESET}"
|
|
81
|
+
else:
|
|
82
|
+
field[y][x] = char
|
|
74
83
|
for row in field:
|
|
75
84
|
print(''.join(row))
|
|
76
|
-
|
|
77
85
|
@staticmethod
|
|
78
|
-
def
|
|
86
|
+
def _apply_color(points, color=None, bg=None):
|
|
87
|
+
if color is None and bg is None:
|
|
88
|
+
return points
|
|
89
|
+
result = []
|
|
90
|
+
for p in points:
|
|
91
|
+
if len(p) == 3:
|
|
92
|
+
x, y, char = p
|
|
93
|
+
if color and bg:
|
|
94
|
+
result.append((x, y, char, color, bg))
|
|
95
|
+
elif color:
|
|
96
|
+
result.append((x, y, char, color))
|
|
97
|
+
else:
|
|
98
|
+
result.append((x, y, char, Colors.BG_BLACK + bg))
|
|
99
|
+
else:
|
|
100
|
+
result.append(p)
|
|
101
|
+
return result
|
|
102
|
+
|
|
103
|
+
@staticmethod
|
|
104
|
+
def get_line_points(x1, y1, x2, y2, char='#', color=None, bg=None):
|
|
79
105
|
points = []
|
|
80
106
|
dx = abs(x2 - x1)
|
|
81
107
|
dy = abs(y2 - y1)
|
|
@@ -93,29 +119,29 @@ class Render:
|
|
|
93
119
|
if e2 < dx:
|
|
94
120
|
err += dx
|
|
95
121
|
y1 += sy
|
|
96
|
-
return points
|
|
97
|
-
|
|
122
|
+
return Render._apply_color(points, color, bg)
|
|
123
|
+
|
|
98
124
|
@staticmethod
|
|
99
|
-
def get_circle_points(cx, cy, r, char='#'):
|
|
125
|
+
def get_circle_points(cx, cy, r, char='#', color=None, bg=None):
|
|
100
126
|
points = []
|
|
101
127
|
for angle in range(0, 360, 5):
|
|
102
128
|
rad = angle * math.pi / 180
|
|
103
129
|
x = int(cx + r * math.cos(rad))
|
|
104
130
|
y = int(cy + r * math.sin(rad))
|
|
105
131
|
points.append((x, y, char))
|
|
106
|
-
return points
|
|
107
|
-
|
|
132
|
+
return Render._apply_color(points, color, bg)
|
|
133
|
+
|
|
108
134
|
@staticmethod
|
|
109
|
-
def get_filled_circle_points(cx, cy, r, char='#'):
|
|
135
|
+
def get_filled_circle_points(cx, cy, r, char='#', color=None, bg=None):
|
|
110
136
|
points = []
|
|
111
137
|
for y in range(cy - r, cy + r + 1):
|
|
112
138
|
for x in range(cx - r, cx + r + 1):
|
|
113
139
|
if (x - cx) ** 2 + (y - cy) ** 2 <= r ** 2:
|
|
114
140
|
points.append((x, y, char))
|
|
115
|
-
return points
|
|
116
|
-
|
|
141
|
+
return Render._apply_color(points, color, bg)
|
|
142
|
+
|
|
117
143
|
@staticmethod
|
|
118
|
-
def get_rect_points(x1, y1, x2, y2, char='#'):
|
|
144
|
+
def get_rect_points(x1, y1, x2, y2, char='#', color=None, bg=None):
|
|
119
145
|
points = []
|
|
120
146
|
for x in range(x1, x2 + 1):
|
|
121
147
|
points.append((x, y1, char))
|
|
@@ -123,26 +149,37 @@ class Render:
|
|
|
123
149
|
for y in range(y1, y2 + 1):
|
|
124
150
|
points.append((x1, y, char))
|
|
125
151
|
points.append((x2, y, char))
|
|
126
|
-
return points
|
|
127
|
-
|
|
152
|
+
return Render._apply_color(points, color, bg)
|
|
153
|
+
|
|
128
154
|
@staticmethod
|
|
129
|
-
def get_fill_rect_points(x1, y1, x2, y2, char='#'):
|
|
155
|
+
def get_fill_rect_points(x1, y1, x2, y2, char='#', color=None, bg=None):
|
|
130
156
|
points = []
|
|
131
157
|
for y in range(y1, y2 + 1):
|
|
132
158
|
for x in range(x1, x2 + 1):
|
|
133
159
|
points.append((x, y, char))
|
|
134
|
-
return points
|
|
135
|
-
|
|
160
|
+
return Render._apply_color(points, color, bg)
|
|
161
|
+
|
|
162
|
+
@staticmethod
|
|
163
|
+
def get_text_points(x, y, text, char=None, color=None, bg=None):
|
|
164
|
+
points = []
|
|
165
|
+
if char is None:
|
|
166
|
+
for i, ch in enumerate(text):
|
|
167
|
+
points.append((x + i, y, ch))
|
|
168
|
+
else:
|
|
169
|
+
for i in range(len(text)):
|
|
170
|
+
points.append((x + i, y, char))
|
|
171
|
+
return Render._apply_color(points, color, bg)
|
|
172
|
+
|
|
136
173
|
@staticmethod
|
|
137
|
-
def get_triangle_points(x1, y1, x2, y2, x3, y3, char='#'):
|
|
174
|
+
def get_triangle_points(x1, y1, x2, y2, x3, y3, char='#', color=None, bg=None):
|
|
138
175
|
points = []
|
|
139
176
|
points.extend(Render.get_line_points(x1, y1, x2, y2, char))
|
|
140
177
|
points.extend(Render.get_line_points(x2, y2, x3, y3, char))
|
|
141
178
|
points.extend(Render.get_line_points(x3, y3, x1, y1, char))
|
|
142
|
-
return points
|
|
143
|
-
|
|
179
|
+
return Render._apply_color(points, color, bg)
|
|
180
|
+
|
|
144
181
|
@staticmethod
|
|
145
|
-
def get_filled_triangle_points(x1, y1, x2, y2, x3, y3, char='#'):
|
|
182
|
+
def get_filled_triangle_points(x1, y1, x2, y2, x3, y3, char='#', color=None, bg=None):
|
|
146
183
|
points = []
|
|
147
184
|
min_x = min(x1, x2, x3)
|
|
148
185
|
max_x = max(x1, x2, x3)
|
|
@@ -152,19 +189,19 @@ class Render:
|
|
|
152
189
|
for x in range(min_x, max_x + 1):
|
|
153
190
|
if Render._point_in_triangle(x, y, x1, y1, x2, y2, x3, y3):
|
|
154
191
|
points.append((x, y, char))
|
|
155
|
-
return points
|
|
156
|
-
|
|
192
|
+
return Render._apply_color(points, color, bg)
|
|
193
|
+
|
|
157
194
|
@staticmethod
|
|
158
|
-
def get_heart_points(cx, cy, size=5, char='#'):
|
|
195
|
+
def get_heart_points(cx, cy, size=5, char='#', color=None, bg=None):
|
|
159
196
|
points = []
|
|
160
197
|
for y in range(-size, size + 1):
|
|
161
198
|
for x in range(-size, size + 1):
|
|
162
199
|
if ((x * x + y * y - size * size) ** 3 <= size * size * x * x * y * y * 0.5):
|
|
163
200
|
points.append((cx + x, cy - y, char))
|
|
164
|
-
return points
|
|
165
|
-
|
|
201
|
+
return Render._apply_color(points, color, bg)
|
|
202
|
+
|
|
166
203
|
@staticmethod
|
|
167
|
-
def get_star_points(cx, cy, radius=5, points_count=5, char='*'):
|
|
204
|
+
def get_star_points(cx, cy, radius=5, points_count=5, char='*', color=None, bg=None):
|
|
168
205
|
points = []
|
|
169
206
|
angle = -math.pi / 2
|
|
170
207
|
step = math.pi / points_count
|
|
@@ -184,18 +221,28 @@ class Render:
|
|
|
184
221
|
p3 = outer_points[(i + 1) % points_count]
|
|
185
222
|
points.extend(Render.get_line_points(int(p1[0]), int(p1[1]), int(p2[0]), int(p2[1]), char))
|
|
186
223
|
points.extend(Render.get_line_points(int(p2[0]), int(p2[1]), int(p3[0]), int(p3[1]), char))
|
|
187
|
-
return points
|
|
188
|
-
|
|
224
|
+
return Render._apply_color(points, color, bg)
|
|
225
|
+
|
|
189
226
|
@staticmethod
|
|
190
|
-
def
|
|
227
|
+
def get_bezier_points(x1, y1, x2, y2, x3, y3, steps=20, char='#', color=None, bg=None):
|
|
228
|
+
points = []
|
|
229
|
+
for t in range(steps + 1):
|
|
230
|
+
t = t / steps
|
|
231
|
+
x = (1 - t) ** 2 * x1 + 2 * (1 - t) * t * x2 + t ** 2 * x3
|
|
232
|
+
y = (1 - t) ** 2 * y1 + 2 * (1 - t) * t * y2 + t ** 2 * y3
|
|
233
|
+
points.append((int(x), int(y), char))
|
|
234
|
+
return Render._apply_color(points, color, bg)
|
|
235
|
+
|
|
236
|
+
@staticmethod
|
|
237
|
+
def get_wave_points(cx, cy, amplitude=5, length=20, char='~', color=None, bg=None):
|
|
191
238
|
points = []
|
|
192
239
|
for x in range(length):
|
|
193
240
|
y = cy + int(amplitude * math.sin(x * 0.5))
|
|
194
241
|
points.append((cx + x, y, char))
|
|
195
|
-
return points
|
|
196
|
-
|
|
242
|
+
return Render._apply_color(points, color, bg)
|
|
243
|
+
|
|
197
244
|
@staticmethod
|
|
198
|
-
def get_spiral_points(cx, cy, turns=3, radius=10, step=0.1, char='*'):
|
|
245
|
+
def get_spiral_points(cx, cy, turns=3, radius=10, step=0.1, char='*', color=None, bg=None):
|
|
199
246
|
points = []
|
|
200
247
|
angle = 0
|
|
201
248
|
r = 0
|
|
@@ -205,28 +252,18 @@ class Render:
|
|
|
205
252
|
points.append((x, y, char))
|
|
206
253
|
angle += step
|
|
207
254
|
r += step * 2
|
|
208
|
-
return points
|
|
209
|
-
|
|
210
|
-
@staticmethod
|
|
211
|
-
def get_bezier_points(x1, y1, x2, y2, x3, y3, steps=20, char='#'):
|
|
212
|
-
points = []
|
|
213
|
-
for t in range(steps + 1):
|
|
214
|
-
t = t / steps
|
|
215
|
-
x = (1 - t) ** 2 * x1 + 2 * (1 - t) * t * x2 + t ** 2 * x3
|
|
216
|
-
y = (1 - t) ** 2 * y1 + 2 * (1 - t) * t * y2 + t ** 2 * y3
|
|
217
|
-
points.append((int(x), int(y), char))
|
|
218
|
-
return points
|
|
219
|
-
|
|
255
|
+
return Render._apply_color(points, color, bg)
|
|
256
|
+
|
|
220
257
|
@staticmethod
|
|
221
|
-
def get_grid_points(x1, y1, x2, y2, step=2, char='+'):
|
|
258
|
+
def get_grid_points(x1, y1, x2, y2, step=2, char='+', color=None, bg=None):
|
|
222
259
|
points = []
|
|
223
260
|
for x in range(x1, x2 + 1, step):
|
|
224
261
|
for y in range(y1, y2 + 1, step):
|
|
225
262
|
points.append((x, y, char))
|
|
226
|
-
return points
|
|
227
|
-
|
|
263
|
+
return Render._apply_color(points, color, bg)
|
|
264
|
+
|
|
228
265
|
@staticmethod
|
|
229
|
-
def get_noise_points(cx, cy, radius, count=50, char='.'):
|
|
266
|
+
def get_noise_points(cx, cy, radius, count=50, char='.', color=None, bg=None):
|
|
230
267
|
points = []
|
|
231
268
|
for _ in range(count):
|
|
232
269
|
angle = random.uniform(0, 2 * math.pi)
|
|
@@ -234,8 +271,9 @@ class Render:
|
|
|
234
271
|
x = int(cx + r * math.cos(angle))
|
|
235
272
|
y = int(cy + r * math.sin(angle))
|
|
236
273
|
points.append((x, y, char))
|
|
237
|
-
return points
|
|
238
|
-
|
|
274
|
+
return Render._apply_color(points, color, bg)
|
|
275
|
+
|
|
276
|
+
# ---- 3D ----
|
|
239
277
|
@staticmethod
|
|
240
278
|
def _point_in_triangle(px, py, x1, y1, x2, y2, x3, y3):
|
|
241
279
|
def sign(a, b, c):
|
|
@@ -247,7 +285,7 @@ class Render:
|
|
|
247
285
|
has_neg = (d1 < 0) or (d2 < 0) or (d3 < 0)
|
|
248
286
|
has_pos = (d1 > 0) or (d2 > 0) or (d3 > 0)
|
|
249
287
|
return not (has_neg and has_pos)
|
|
250
|
-
|
|
288
|
+
|
|
251
289
|
@staticmethod
|
|
252
290
|
def _rotx(x, y, z, angle):
|
|
253
291
|
rad = math.radians(angle)
|
|
@@ -256,7 +294,7 @@ class Render:
|
|
|
256
294
|
y_new = y * cos_a - z * sin_a
|
|
257
295
|
z_new = y * sin_a + z * cos_a
|
|
258
296
|
return x, y_new, z_new
|
|
259
|
-
|
|
297
|
+
|
|
260
298
|
@staticmethod
|
|
261
299
|
def _roty(x, y, z, angle):
|
|
262
300
|
rad = math.radians(angle)
|
|
@@ -265,7 +303,7 @@ class Render:
|
|
|
265
303
|
x_new = x * cos_a + z * sin_a
|
|
266
304
|
z_new = -x * sin_a + z * cos_a
|
|
267
305
|
return x_new, y, z_new
|
|
268
|
-
|
|
306
|
+
|
|
269
307
|
@staticmethod
|
|
270
308
|
def _rotz(x, y, z, angle):
|
|
271
309
|
rad = math.radians(angle)
|
|
@@ -274,7 +312,7 @@ class Render:
|
|
|
274
312
|
x_new = x * cos_a - y * sin_a
|
|
275
313
|
y_new = x * sin_a + y * cos_a
|
|
276
314
|
return x_new, y_new, z
|
|
277
|
-
|
|
315
|
+
|
|
278
316
|
@staticmethod
|
|
279
317
|
def _project_3d(x, y, z, rotx, roty, rotz, scale, cx, cy):
|
|
280
318
|
x, y, z = Render._rotx(x, y, z, rotx)
|
|
@@ -283,9 +321,9 @@ class Render:
|
|
|
283
321
|
x2d = int(x * scale + cx)
|
|
284
322
|
y2d = int(-y * scale + cy)
|
|
285
323
|
return x2d, y2d
|
|
286
|
-
|
|
324
|
+
|
|
287
325
|
@staticmethod
|
|
288
|
-
def get_cube_3d_points(size=5, rotx=0, roty=0, rotz=0, scale=10, cx=40, cy=12, char='#'):
|
|
326
|
+
def get_cube_3d_points(size=5, rotx=0, roty=0, rotz=0, scale=10, cx=40, cy=12, char='#', color=None, bg=None):
|
|
289
327
|
s = size / 2
|
|
290
328
|
vertices = [
|
|
291
329
|
(-s, -s, -s), (s, -s, -s), (s, s, -s), (-s, s, -s),
|
|
@@ -305,7 +343,143 @@ class Render:
|
|
|
305
343
|
x1, y1 = projected[edge[0]]
|
|
306
344
|
x2, y2 = projected[edge[1]]
|
|
307
345
|
points.extend(Render.get_line_points(x1, y1, x2, y2, char))
|
|
308
|
-
return points
|
|
346
|
+
return Render._apply_color(points, color, bg)
|
|
347
|
+
|
|
348
|
+
@staticmethod
|
|
349
|
+
def get_pyramid_3d_points(size=5, rotx=0, roty=0, rotz=0, scale=10, cx=40, cy=12, char='#', color=None, bg=None):
|
|
350
|
+
s = size / 2
|
|
351
|
+
vertices = [
|
|
352
|
+
(-s, -s, -s), (s, -s, -s), (s, -s, s), (-s, -s, s),
|
|
353
|
+
(0, s, 0)
|
|
354
|
+
]
|
|
355
|
+
edges = [
|
|
356
|
+
(0,1), (1,2), (2,3), (3,0),
|
|
357
|
+
(0,4), (1,4), (2,4), (3,4)
|
|
358
|
+
]
|
|
359
|
+
points = []
|
|
360
|
+
projected = []
|
|
361
|
+
for v in vertices:
|
|
362
|
+
x2d, y2d = Render._project_3d(v[0], v[1], v[2], rotx, roty, rotz, scale, cx, cy)
|
|
363
|
+
projected.append((x2d, y2d))
|
|
364
|
+
for edge in edges:
|
|
365
|
+
x1, y1 = projected[edge[0]]
|
|
366
|
+
x2, y2 = projected[edge[1]]
|
|
367
|
+
points.extend(Render.get_line_points(x1, y1, x2, y2, char))
|
|
368
|
+
return Render._apply_color(points, color, bg)
|
|
369
|
+
|
|
370
|
+
@staticmethod
|
|
371
|
+
def get_cylinder_3d_points(radius=5, height=10, segments=12, rotx=0, roty=0, rotz=0, scale=10, cx=40, cy=12, char='#', color=None, bg=None):
|
|
372
|
+
points = []
|
|
373
|
+
top_points = []
|
|
374
|
+
bottom_points = []
|
|
375
|
+
for i in range(segments):
|
|
376
|
+
rad = i / segments * 2 * math.pi
|
|
377
|
+
x = radius * math.cos(rad)
|
|
378
|
+
z = radius * math.sin(rad)
|
|
379
|
+
top_points.append((x, height/2, z))
|
|
380
|
+
bottom_points.append((x, -height/2, z))
|
|
381
|
+
all_vertices = top_points + bottom_points
|
|
382
|
+
projected = []
|
|
383
|
+
for v in all_vertices:
|
|
384
|
+
x2d, y2d = Render._project_3d(v[0], v[1], v[2], rotx, roty, rotz, scale, cx, cy)
|
|
385
|
+
projected.append((x2d, y2d))
|
|
386
|
+
for i in range(segments):
|
|
387
|
+
j = (i + 1) % segments
|
|
388
|
+
x1, y1 = projected[i]
|
|
389
|
+
x2, y2 = projected[j]
|
|
390
|
+
points.extend(Render.get_line_points(x1, y1, x2, y2, char))
|
|
391
|
+
x1, y1 = projected[i + segments]
|
|
392
|
+
x2, y2 = projected[j + segments]
|
|
393
|
+
points.extend(Render.get_line_points(x1, y1, x2, y2, char))
|
|
394
|
+
x1, y1 = projected[i]
|
|
395
|
+
x2, y2 = projected[i + segments]
|
|
396
|
+
points.extend(Render.get_line_points(x1, y1, x2, y2, char))
|
|
397
|
+
return Render._apply_color(points, color, bg)
|
|
398
|
+
|
|
399
|
+
@staticmethod
|
|
400
|
+
def get_sphere_3d_points(radius=5, segments=12, rotx=0, roty=0, rotz=0, scale=10, cx=40, cy=12, char='#', color=None, bg=None):
|
|
401
|
+
points = []
|
|
402
|
+
for i in range(segments):
|
|
403
|
+
theta = i / segments * math.pi
|
|
404
|
+
for j in range(segments):
|
|
405
|
+
phi = j / segments * 2 * math.pi
|
|
406
|
+
x = radius * math.sin(theta) * math.cos(phi)
|
|
407
|
+
y = radius * math.cos(theta)
|
|
408
|
+
z = radius * math.sin(theta) * math.sin(phi)
|
|
409
|
+
x2d, y2d = Render._project_3d(x, y, z, rotx, roty, rotz, scale, cx, cy)
|
|
410
|
+
points.append((x2d, y2d, char))
|
|
411
|
+
return Render._apply_color(points, color, bg)
|
|
412
|
+
|
|
413
|
+
@staticmethod
|
|
414
|
+
def get_cone_3d_points(radius=5, height=10, segments=12, rotx=0, roty=0, rotz=0, scale=10, cx=40, cy=12, char='#', color=None, bg=None):
|
|
415
|
+
points = []
|
|
416
|
+
base_points = []
|
|
417
|
+
for i in range(segments):
|
|
418
|
+
rad = i / segments * 2 * math.pi
|
|
419
|
+
x = radius * math.cos(rad)
|
|
420
|
+
z = radius * math.sin(rad)
|
|
421
|
+
base_points.append((x, -height/2, z))
|
|
422
|
+
apex = (0, height/2, 0)
|
|
423
|
+
all_vertices = base_points + [apex]
|
|
424
|
+
projected = []
|
|
425
|
+
for v in all_vertices:
|
|
426
|
+
x2d, y2d = Render._project_3d(v[0], v[1], v[2], rotx, roty, rotz, scale, cx, cy)
|
|
427
|
+
projected.append((x2d, y2d))
|
|
428
|
+
for i in range(segments):
|
|
429
|
+
j = (i + 1) % segments
|
|
430
|
+
x1, y1 = projected[i]
|
|
431
|
+
x2, y2 = projected[j]
|
|
432
|
+
points.extend(Render.get_line_points(x1, y1, x2, y2, char))
|
|
433
|
+
x1, y1 = projected[i]
|
|
434
|
+
x2, y2 = projected[-1]
|
|
435
|
+
points.extend(Render.get_line_points(x1, y1, x2, y2, char))
|
|
436
|
+
return Render._apply_color(points, color, bg)
|
|
437
|
+
|
|
438
|
+
@staticmethod
|
|
439
|
+
def get_torus_3d_points(radius=8, tube=3, segments=16, rotx=0, roty=0, rotz=0, scale=10, cx=40, cy=12, char='#', color=None, bg=None):
|
|
440
|
+
points = []
|
|
441
|
+
for i in range(segments):
|
|
442
|
+
theta = i / segments * 2 * math.pi
|
|
443
|
+
for j in range(segments):
|
|
444
|
+
phi = j / segments * 2 * math.pi
|
|
445
|
+
x = (radius + tube * math.cos(phi)) * math.cos(theta)
|
|
446
|
+
y = tube * math.sin(phi)
|
|
447
|
+
z = (radius + tube * math.cos(phi)) * math.sin(theta)
|
|
448
|
+
x2d, y2d = Render._project_3d(x, y, z, rotx, roty, rotz, scale, cx, cy)
|
|
449
|
+
points.append((x2d, y2d, char))
|
|
450
|
+
return Render._apply_color(points, color, bg)
|
|
451
|
+
|
|
452
|
+
@staticmethod
|
|
453
|
+
def get_ico_sphere_3d_points(radius=5, rotx=0, roty=0, rotz=0, scale=10, cx=40, cy=12, char='#', color=None, bg=None):
|
|
454
|
+
points = []
|
|
455
|
+
phi = (1 + math.sqrt(5)) / 2
|
|
456
|
+
vertices = [
|
|
457
|
+
(-1, phi, 0), ( 1, phi, 0), (-1, -phi, 0), ( 1, -phi, 0),
|
|
458
|
+
( 0, -1, phi), ( 0, 1, phi), ( 0, -1, -phi), ( 0, 1, -phi),
|
|
459
|
+
( phi, 0, -1), ( phi, 0, 1), (-phi, 0, -1), (-phi, 0, 1)
|
|
460
|
+
]
|
|
461
|
+
vertices = [(x * radius / 1.618, y * radius / 1.618, z * radius / 1.618) for x, y, z in vertices]
|
|
462
|
+
edges = [
|
|
463
|
+
(0,1), (0,4), (0,5), (0,10), (0,11),
|
|
464
|
+
(1,2), (1,5), (1,7), (1,8), (1,9),
|
|
465
|
+
(2,3), (2,6), (2,7), (2,10), (2,11),
|
|
466
|
+
(3,4), (3,6), (3,8), (3,9), (3,11),
|
|
467
|
+
(4,5), (4,9), (4,11),
|
|
468
|
+
(5,7), (5,9),
|
|
469
|
+
(6,7), (6,10),
|
|
470
|
+
(7,8),
|
|
471
|
+
(8,9), (8,10),
|
|
472
|
+
(10,11)
|
|
473
|
+
]
|
|
474
|
+
projected = []
|
|
475
|
+
for v in vertices:
|
|
476
|
+
x2d, y2d = Render._project_3d(v[0], v[1], v[2], rotx, roty, rotz, scale, cx, cy)
|
|
477
|
+
projected.append((x2d, y2d))
|
|
478
|
+
for edge in edges:
|
|
479
|
+
x1, y1 = projected[edge[0]]
|
|
480
|
+
x2, y2 = projected[edge[1]]
|
|
481
|
+
points.extend(Render.get_line_points(x1, y1, x2, y2, char))
|
|
482
|
+
return Render._apply_color(points, color, bg)
|
|
309
483
|
|
|
310
484
|
class Animate:
|
|
311
485
|
@staticmethod
|
|
@@ -578,4 +752,39 @@ class Channel:
|
|
|
578
752
|
data = self.connection.recv(1024).decode().strip()
|
|
579
753
|
return data
|
|
580
754
|
except Exception:
|
|
581
|
-
return None
|
|
755
|
+
return None
|
|
756
|
+
|
|
757
|
+
class Web:
|
|
758
|
+
def UploadPaste(text, title="My Paste"):
|
|
759
|
+
def _get_api_key():
|
|
760
|
+
return base64.b64decode("NXZsdjk3eFlXdGtuLTBvUzcxbi1Wa01jVVpRQzJZV2Y=".encode("utf-8")).decode("utf-8")
|
|
761
|
+
api_key = _get_api_key()
|
|
762
|
+
data = {
|
|
763
|
+
'api_dev_key': api_key,
|
|
764
|
+
'api_option': 'paste',
|
|
765
|
+
'api_paste_code': text,
|
|
766
|
+
'api_paste_name': title,
|
|
767
|
+
'api_paste_private': '0',
|
|
768
|
+
'api_paste_expire_date': 'N',
|
|
769
|
+
}
|
|
770
|
+
encoded_data = urllib.parse.urlencode(data).encode('utf-8')
|
|
771
|
+
req = urllib.request.Request(
|
|
772
|
+
"https://pastebin.com/api/api_post.php",
|
|
773
|
+
data=encoded_data,
|
|
774
|
+
method="POST",
|
|
775
|
+
headers={
|
|
776
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
|
|
777
|
+
}
|
|
778
|
+
)
|
|
779
|
+
try:
|
|
780
|
+
with urllib.request.urlopen(req) as response:
|
|
781
|
+
result = response.read().decode('utf-8')
|
|
782
|
+
if result.startswith("https://pastebin.com/"):
|
|
783
|
+
paste_id = result.split("/")[-1]
|
|
784
|
+
return f"https://pastebin.com/raw/{paste_id}"
|
|
785
|
+
else:
|
|
786
|
+
return f"Pastebin error: {result}"
|
|
787
|
+
except urllib.error.HTTPError as e:
|
|
788
|
+
return f"HTTP Error {e.code}: {e.reason}"
|
|
789
|
+
except Exception as e:
|
|
790
|
+
return f"Error: {e}"
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
LICENSE
|
|
2
|
-
MANIFEST.in
|
|
3
2
|
setup.py
|
|
4
3
|
ConsoleFramework/__init__.py
|
|
5
4
|
ConsoleFramework.egg-info/PKG-INFO
|
|
6
5
|
ConsoleFramework.egg-info/SOURCES.txt
|
|
7
6
|
ConsoleFramework.egg-info/dependency_links.txt
|
|
8
7
|
ConsoleFramework.egg-info/not-zip-safe
|
|
9
|
-
ConsoleFramework.egg-info/top_level.txt
|
|
10
|
-
consoleframework/__init__.py
|
|
8
|
+
ConsoleFramework.egg-info/top_level.txt
|
|
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
|
|
|
2
2
|
|
|
3
3
|
setup(
|
|
4
4
|
name="ConsoleFramework",
|
|
5
|
-
version="2.0.
|
|
5
|
+
version="2.0.4",
|
|
6
6
|
description="The best Console Library of the Python.",
|
|
7
7
|
long_description="ConsoleFramework - Pure Python library for console rendering, animations, processes and more. In this module ONLY standart python, no other modules.",
|
|
8
8
|
long_description_content_type="text/plain",
|
{consoleframework-2.0.2 → consoleframework-2.0.4}/ConsoleFramework.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|