ConsoleLib 1.1.1__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.
@@ -0,0 +1,88 @@
1
+ import os, sys, time
2
+ import subprocess as CMD
3
+ class Render:
4
+ @staticmethod
5
+ def DrawPic(points=None, width=80, height=25, clear_before_draw=False, default_char=' '):
6
+ if clear_before_draw:
7
+ os.system("cls" if os.name == "nt" else "clear")
8
+ field = [[default_char for _ in range(width)] for _ in range(height)]
9
+ if points:
10
+ for item in points:
11
+ if len(item) == 3:
12
+ x, y, char = item
13
+ if 0 <= x < width and 0 <= y < height:
14
+ field[y][x] = char
15
+ for row in field:
16
+ print(''.join(row))
17
+
18
+ @staticmethod
19
+ def draw_line(x1, y1, x2, y2, char='#', width=80, height=25, clear_before_draw=False):
20
+ points = []
21
+ dx = abs(x2 - x1)
22
+ dy = abs(y2 - y1)
23
+ sx = 1 if x1 < x2 else -1
24
+ sy = 1 if y1 < y2 else -1
25
+ err = dx - dy
26
+ while True:
27
+ points.append((x1, y1, char))
28
+ if x1 == x2 and y1 == y2:
29
+ break
30
+ e2 = err * 2
31
+ if e2 > -dy:
32
+ err -= dy
33
+ x1 += sx
34
+ if e2 < dx:
35
+ err += dx
36
+ y1 += sy
37
+ Render.DrawPic(points=points, width=width, height=height, clear_before_draw=clear_before_draw)
38
+
39
+ @staticmethod
40
+ def draw_circle(cx, cy, r, char='#', width=80, height=25, clear_before_draw=False):
41
+ import math
42
+ points = []
43
+ for angle in range(0, 360, 5):
44
+ rad = angle * 3.14159 / 180
45
+ x = int(cx + r * math.cos(rad))
46
+ y = int(cy + r * math.sin(rad))
47
+ points.append((x, y, char))
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)
75
+ class ConsoleInfo:
76
+ @staticmethod
77
+ def GetConsole():
78
+ return sys.stdout
79
+
80
+ @staticmethod
81
+ def GetPipVer():
82
+ try:
83
+ result = CMD.run(['python', '-m', 'pip', '--version'], capture_output=True, text=True, check=True)
84
+ return result.stdout.strip()
85
+ except CMD.CalledProcessError as e:
86
+ return f"Error: pip not found (code {e.returncode})"
87
+ except FileNotFoundError:
88
+ return "Error: Python not installed or not in PATH"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ConsoleLib
3
- Version: 1.1.1
3
+ Version: 1.2.1
4
4
  Summary: The library for easy and best control on the Console.
5
5
  Author-email: Suleiman <steal.apet@mail.ru>
6
6
  License: MIT
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ConsoleLib
3
- Version: 1.1.1
3
+ Version: 1.2.1
4
4
  Summary: The library for easy and best control on the Console.
5
5
  Author-email: Suleiman <steal.apet@mail.ru>
6
6
  License: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "ConsoleLib"
7
- version = "1.1.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"
@@ -1,34 +0,0 @@
1
- import os, sys, time
2
- import subprocess as CMD
3
-
4
- class Render:
5
- @staticmethod
6
- def DrawPic(default_char="■", points=None, width=80, height=25, clear_before_draw=False):
7
- if clear_before_draw:
8
- os.system("cls" if os.name == "nt" else "clear")
9
- if points is None:
10
- raise TypeError("Did You Forget To Write In Arguments: 'points=[POINTS_HERE]'?")
11
- if not isinstance(points, list):
12
- raise TypeError("Supports Only List, What In List Tuple!")
13
- field = [[' ' for _ in range(width)] for _ in range(height)]
14
- for item in points:
15
- x, y, custom_char = item
16
- if 0 <= x < width and 0 <= y < height:
17
- field[y][x] = custom_char
18
- for row in field:
19
- print(''.join(row))
20
-
21
- class ConsoleInfo:
22
- @staticmethod
23
- def GetConsole():
24
- return sys.stdout
25
-
26
- @staticmethod
27
- def GetPipVer():
28
- try:
29
- result = CMD.run(['python', '-m', 'pip', '--version'], capture_output=True, text=True, check=True)
30
- return result.stdout.strip()
31
- except CMD.CalledProcessError as e:
32
- return f"Error: pip not found (code {e.returncode})"
33
- except FileNotFoundError:
34
- return "Error: Python not installed or not in PATH"
File without changes
File without changes