ConsoleLib 1.0.0__tar.gz → 1.2.1__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.
- {consolelib-1.0.0 → consolelib-1.2.1}/ConsoleLib/__init__.py +33 -15
- {consolelib-1.0.0 → consolelib-1.2.1}/ConsoleLib.egg-info/PKG-INFO +1 -1
- {consolelib-1.0.0 → consolelib-1.2.1}/PKG-INFO +1 -1
- {consolelib-1.0.0 → consolelib-1.2.1}/pyproject.toml +1 -1
- {consolelib-1.0.0 → consolelib-1.2.1}/ConsoleLib.egg-info/SOURCES.txt +0 -0
- {consolelib-1.0.0 → consolelib-1.2.1}/ConsoleLib.egg-info/dependency_links.txt +0 -0
- {consolelib-1.0.0 → consolelib-1.2.1}/ConsoleLib.egg-info/top_level.txt +0 -0
- {consolelib-1.0.0 → consolelib-1.2.1}/README.md +0 -0
- {consolelib-1.0.0 → consolelib-1.2.1}/setup.cfg +0 -0
|
@@ -2,37 +2,27 @@ import os, sys, time
|
|
|
2
2
|
import subprocess as CMD
|
|
3
3
|
class Render:
|
|
4
4
|
@staticmethod
|
|
5
|
-
def DrawPic(
|
|
6
|
-
points=None,
|
|
7
|
-
width=80,
|
|
8
|
-
height=25,
|
|
9
|
-
clear_before_draw=False,
|
|
10
|
-
default_char=' '
|
|
11
|
-
):
|
|
5
|
+
def DrawPic(points=None, width=80, height=25, clear_before_draw=False, default_char=' '):
|
|
12
6
|
if clear_before_draw:
|
|
13
7
|
os.system("cls" if os.name == "nt" else "clear")
|
|
14
|
-
|
|
15
8
|
field = [[default_char for _ in range(width)] for _ in range(height)]
|
|
16
|
-
|
|
17
9
|
if points:
|
|
18
10
|
for item in points:
|
|
19
11
|
if len(item) == 3:
|
|
20
12
|
x, y, char = item
|
|
21
13
|
if 0 <= x < width and 0 <= y < height:
|
|
22
14
|
field[y][x] = char
|
|
23
|
-
|
|
24
15
|
for row in field:
|
|
25
16
|
print(''.join(row))
|
|
26
17
|
|
|
27
18
|
@staticmethod
|
|
28
|
-
def draw_line(x1, y1, x2, y2, char='#', width=80, height=25,clear_before_draw=False):
|
|
19
|
+
def draw_line(x1, y1, x2, y2, char='#', width=80, height=25, clear_before_draw=False):
|
|
29
20
|
points = []
|
|
30
21
|
dx = abs(x2 - x1)
|
|
31
22
|
dy = abs(y2 - y1)
|
|
32
23
|
sx = 1 if x1 < x2 else -1
|
|
33
24
|
sy = 1 if y1 < y2 else -1
|
|
34
25
|
err = dx - dy
|
|
35
|
-
|
|
36
26
|
while True:
|
|
37
27
|
points.append((x1, y1, char))
|
|
38
28
|
if x1 == x2 and y1 == y2:
|
|
@@ -45,15 +35,43 @@ class Render:
|
|
|
45
35
|
err += dx
|
|
46
36
|
y1 += sy
|
|
47
37
|
Render.DrawPic(points=points, width=width, height=height, clear_before_draw=clear_before_draw)
|
|
38
|
+
|
|
48
39
|
@staticmethod
|
|
49
|
-
def draw_circle(cx, cy, r, char='#', width=80, height=25,clear_before_draw=False):
|
|
40
|
+
def draw_circle(cx, cy, r, char='#', width=80, height=25, clear_before_draw=False):
|
|
41
|
+
import math
|
|
50
42
|
points = []
|
|
51
43
|
for angle in range(0, 360, 5):
|
|
52
44
|
rad = angle * 3.14159 / 180
|
|
53
|
-
x = int(cx + r * cos(rad))
|
|
54
|
-
y = int(cy + r * sin(rad))
|
|
45
|
+
x = int(cx + r * math.cos(rad))
|
|
46
|
+
y = int(cy + r * math.sin(rad))
|
|
55
47
|
points.append((x, y, char))
|
|
56
48
|
Render.DrawPic(points=points, width=width, height=height, clear_before_draw=clear_before_draw)
|
|
49
|
+
|
|
50
|
+
@staticmethod
|
|
51
|
+
def draw_rect(x1, y1, x2, y2, char='#', width=80, height=25, clear_before_draw=False):
|
|
52
|
+
points = []
|
|
53
|
+
for x in range(x1, x2 + 1):
|
|
54
|
+
points.append((x, y1, char))
|
|
55
|
+
points.append((x, y2, char))
|
|
56
|
+
for y in range(y1, y2 + 1):
|
|
57
|
+
points.append((x1, y, char))
|
|
58
|
+
points.append((x2, y, char))
|
|
59
|
+
Render.DrawPic(points=points, width=width, height=height, clear_before_draw=clear_before_draw)
|
|
60
|
+
|
|
61
|
+
@staticmethod
|
|
62
|
+
def fill_rect(x1, y1, x2, y2, char='#', width=80, height=25, clear_before_draw=False):
|
|
63
|
+
points = []
|
|
64
|
+
for y in range(y1, y2 + 1):
|
|
65
|
+
for x in range(x1, x2 + 1):
|
|
66
|
+
points.append((x, y, char))
|
|
67
|
+
Render.DrawPic(points=points, width=width, height=height, clear_before_draw=clear_before_draw)
|
|
68
|
+
|
|
69
|
+
@staticmethod
|
|
70
|
+
def draw_text(x, y, text, width=80, height=25, clear_before_draw=False):
|
|
71
|
+
points = []
|
|
72
|
+
for i, char in enumerate(text):
|
|
73
|
+
points.append((x + i, y, char))
|
|
74
|
+
Render.DrawPic(points=points, width=width, height=height, clear_before_draw=clear_before_draw)
|
|
57
75
|
class ConsoleInfo:
|
|
58
76
|
@staticmethod
|
|
59
77
|
def GetConsole():
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "ConsoleLib"
|
|
7
|
-
version = "1.
|
|
7
|
+
version = "1.2.1"
|
|
8
8
|
description = "The library for easy and best control on the Console."
|
|
9
9
|
authors = [{name = "Suleiman", email = "steal.apet@mail.ru"}]
|
|
10
10
|
readme = "README.md"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|