wraith 1.0.0__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.
- wraith-1.0.0/LICENSE +23 -0
- wraith-1.0.0/PKG-INFO +24 -0
- wraith-1.0.0/README.md +31 -0
- wraith-1.0.0/pyproject.toml +3 -0
- wraith-1.0.0/setup.cfg +4 -0
- wraith-1.0.0/setup.py +33 -0
- wraith-1.0.0/wraith.egg-info/PKG-INFO +24 -0
- wraith-1.0.0/wraith.egg-info/SOURCES.txt +10 -0
- wraith-1.0.0/wraith.egg-info/dependency_links.txt +1 -0
- wraith-1.0.0/wraith.egg-info/requires.txt +1 -0
- wraith-1.0.0/wraith.egg-info/top_level.txt +1 -0
- wraith-1.0.0/wraith.py +610 -0
wraith-1.0.0/LICENSE
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
Boost Software License - Version 1.0 - August 17th, 2003
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person or organization
|
|
4
|
+
obtaining a copy of the software and accompanying documentation covered by
|
|
5
|
+
this license (the "Software") to use, reproduce, display, distribute,
|
|
6
|
+
execute, and transmit the Software, and to prepare derivative works of the
|
|
7
|
+
Software, and to permit third-parties to whom the Software is furnished to
|
|
8
|
+
do so, all subject to the following:
|
|
9
|
+
|
|
10
|
+
The copyright notices in the Software and this entire statement, including
|
|
11
|
+
the above license grant, this restriction and the following disclaimer,
|
|
12
|
+
must be included in all copies of the Software, in whole or in part, and
|
|
13
|
+
all derivative works of the Software, unless such copies or derivative
|
|
14
|
+
works are solely in the form of machine-executable object code generated by
|
|
15
|
+
a source language processor.
|
|
16
|
+
|
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
|
20
|
+
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
|
21
|
+
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
|
22
|
+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
23
|
+
DEALINGS IN THE SOFTWARE.
|
wraith-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: wraith
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: All the power of Python...in the palm of your hand.
|
|
5
|
+
Author: Omer Drkić
|
|
6
|
+
Author-email: omerdrkic2501@gmail.com
|
|
7
|
+
License: Boost Software License 1.0
|
|
8
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
9
|
+
Classifier: Environment :: Console
|
|
10
|
+
Classifier: Framework :: Jupyter
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: License :: OSI Approved :: Boost Software License 1.0 (BSL-1.0)
|
|
13
|
+
Classifier: Natural Language :: English
|
|
14
|
+
Classifier: Operating System :: Microsoft
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Topic :: Software Development :: Interpreters
|
|
19
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
20
|
+
Classifier: Typing :: Typed
|
|
21
|
+
Requires-Python: >=3.10
|
|
22
|
+
License-File: LICENSE
|
|
23
|
+
|
|
24
|
+
Wraith is a module programmed by Omer Drkić that adds loads of new features and makes Python easier to use. The module adds some features that the developer felt like they were missing from Python. It also adds some extension to the 'math' library and to the actual Python environment, as well as some useful data manipulation tools.
|
wraith-1.0.0/README.md
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# All the power of Python...in the palm of your hand.
|
|
2
|
+
|
|
3
|
+
Wraith is a module programmed by Omer Drkić that adds loads of new features and makes Python easier to use. The module adds some features that the developer felt like they were missing from Python. It also adds some extension to the 'math' library and to the actual Python environment, as well as some useful data manipulation tools.
|
|
4
|
+
|
|
5
|
+
## History
|
|
6
|
+
|
|
7
|
+
Wraith was first created in 2022 for personal use, but now the developer has decided to recreate it even better and finally upload it to PyPI. Fun fact: the original name was actually Pynamic, but the developer found out that there was already a module named Pynamic on PyPI.
|
|
8
|
+
|
|
9
|
+
## Examples
|
|
10
|
+
|
|
11
|
+
The more detailed documentation on how to use Wraith is not yet available, but here are some of the most important and notable functions.
|
|
12
|
+
|
|
13
|
+
### `cls()`
|
|
14
|
+
|
|
15
|
+
The `cls()` function is added to make clearing the console output easier and quicker and it has no parameters at all.
|
|
16
|
+
|
|
17
|
+
### `wait(interval)`
|
|
18
|
+
|
|
19
|
+
The `wait()` function makes pausing the program quicker and it has only one parameter, the interval to pause the program for in seconds. For example, `wait(3)` makes the program wait for three seconds.
|
|
20
|
+
|
|
21
|
+
### `random(min, max)`
|
|
22
|
+
|
|
23
|
+
The `random()` function generates true random floating numbers and requires two parameters, the minimum value and the maximum value. It includes both ends during generation. For example, `random(3.2, 5)` generates a float between 3.2 and 5.
|
|
24
|
+
|
|
25
|
+
### `choose(*values)`
|
|
26
|
+
|
|
27
|
+
The `choose()` function returns a randomly chosen item from the specified list which can have as many items. For example, `choose("apple", "banana", "pear")` will return either "apple", "banana", or "pear".
|
|
28
|
+
|
|
29
|
+
## Support
|
|
30
|
+
|
|
31
|
+
If you have any suggestions or ideas, please share them with me through e-mail. If you have any critics, be sure to e-mail as well. Also, please report any bugs you find - that way you help the rest of the community. Thank you for using Wraith!
|
wraith-1.0.0/setup.cfg
ADDED
wraith-1.0.0/setup.py
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
from setuptools import setup
|
|
2
|
+
|
|
3
|
+
setup(
|
|
4
|
+
name = "wraith",
|
|
5
|
+
version = "1.0.0",
|
|
6
|
+
description = "All the power of Python...in the palm of your hand.",
|
|
7
|
+
long_description = "Wraith is a module programmed by Omer Drkić that adds loads of new features and makes Python easier to use. The module adds some features that the developer felt like they were missing from Python. It also adds some extension to the 'math' library and to the actual Python environment, as well as some useful data manipulation tools.",
|
|
8
|
+
author = "Omer Drkić",
|
|
9
|
+
author_email = "omerdrkic2501@gmail.com",
|
|
10
|
+
py_modules = [
|
|
11
|
+
"wraith"
|
|
12
|
+
],
|
|
13
|
+
classifiers = [
|
|
14
|
+
"Development Status :: 5 - Production/Stable",
|
|
15
|
+
"Environment :: Console",
|
|
16
|
+
"Framework :: Jupyter",
|
|
17
|
+
"Intended Audience :: Developers",
|
|
18
|
+
"License :: OSI Approved :: Boost Software License 1.0 (BSL-1.0)",
|
|
19
|
+
"Natural Language :: English",
|
|
20
|
+
"Operating System :: Microsoft",
|
|
21
|
+
"Programming Language :: Python :: 3.10",
|
|
22
|
+
"Programming Language :: Python :: 3.11",
|
|
23
|
+
"Programming Language :: Python :: 3.12",
|
|
24
|
+
"Topic :: Software Development :: Interpreters",
|
|
25
|
+
"Topic :: Software Development :: Libraries",
|
|
26
|
+
"Typing :: Typed"
|
|
27
|
+
],
|
|
28
|
+
license = "Boost Software License 1.0",
|
|
29
|
+
install_requires = [
|
|
30
|
+
"keyboard"
|
|
31
|
+
],
|
|
32
|
+
python_requires = ">=3.10"
|
|
33
|
+
)
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: wraith
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: All the power of Python...in the palm of your hand.
|
|
5
|
+
Author: Omer Drkić
|
|
6
|
+
Author-email: omerdrkic2501@gmail.com
|
|
7
|
+
License: Boost Software License 1.0
|
|
8
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
9
|
+
Classifier: Environment :: Console
|
|
10
|
+
Classifier: Framework :: Jupyter
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: License :: OSI Approved :: Boost Software License 1.0 (BSL-1.0)
|
|
13
|
+
Classifier: Natural Language :: English
|
|
14
|
+
Classifier: Operating System :: Microsoft
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Topic :: Software Development :: Interpreters
|
|
19
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
20
|
+
Classifier: Typing :: Typed
|
|
21
|
+
Requires-Python: >=3.10
|
|
22
|
+
License-File: LICENSE
|
|
23
|
+
|
|
24
|
+
Wraith is a module programmed by Omer Drkić that adds loads of new features and makes Python easier to use. The module adds some features that the developer felt like they were missing from Python. It also adds some extension to the 'math' library and to the actual Python environment, as well as some useful data manipulation tools.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
keyboard
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
wraith
|
wraith-1.0.0/wraith.py
ADDED
|
@@ -0,0 +1,610 @@
|
|
|
1
|
+
"""
|
|
2
|
+
A module programmed by Omer Drkić that adds loads of new features and makes Python easier to use.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import cmath as c
|
|
6
|
+
import keyboard as k
|
|
7
|
+
import math as m
|
|
8
|
+
import os as o
|
|
9
|
+
import random as r
|
|
10
|
+
import subprocess as s
|
|
11
|
+
import time as t
|
|
12
|
+
|
|
13
|
+
timer = t.time()
|
|
14
|
+
|
|
15
|
+
def ceil(value: float):
|
|
16
|
+
"""
|
|
17
|
+
Returns an integer higher than the specified floating point number.
|
|
18
|
+
"""
|
|
19
|
+
value = int(value) + 1
|
|
20
|
+
return value
|
|
21
|
+
|
|
22
|
+
def choose(*values):
|
|
23
|
+
"""
|
|
24
|
+
Returns a random item from the specified list.
|
|
25
|
+
"""
|
|
26
|
+
return r.choice(values)
|
|
27
|
+
|
|
28
|
+
def chooseindex(index: int, *values):
|
|
29
|
+
"""
|
|
30
|
+
Returns an item from the specified list using a zero-based index.
|
|
31
|
+
"""
|
|
32
|
+
return values[index]
|
|
33
|
+
|
|
34
|
+
def cls():
|
|
35
|
+
"""
|
|
36
|
+
Clears the previous console output.
|
|
37
|
+
"""
|
|
38
|
+
o.system("cls")
|
|
39
|
+
|
|
40
|
+
def find(string: str, character: str):
|
|
41
|
+
"""
|
|
42
|
+
Returns the number of times a character is repeated in the specified string.
|
|
43
|
+
"""
|
|
44
|
+
count = 0
|
|
45
|
+
for i in string:
|
|
46
|
+
if i == character:
|
|
47
|
+
count += 1
|
|
48
|
+
else:
|
|
49
|
+
pass
|
|
50
|
+
return count
|
|
51
|
+
|
|
52
|
+
def floor(value: float):
|
|
53
|
+
"""
|
|
54
|
+
Returns an integer lower than the specified floating point number.
|
|
55
|
+
"""
|
|
56
|
+
return int(value)
|
|
57
|
+
|
|
58
|
+
def key(key: int):
|
|
59
|
+
"""
|
|
60
|
+
Pauses the program until the requested key is pressed.
|
|
61
|
+
"""
|
|
62
|
+
if key == 0:
|
|
63
|
+
k.wait("escape")
|
|
64
|
+
elif key == 1:
|
|
65
|
+
k.wait("f1")
|
|
66
|
+
elif key == 2:
|
|
67
|
+
k.wait("f2")
|
|
68
|
+
elif key == 3:
|
|
69
|
+
k.wait("f3")
|
|
70
|
+
elif key == 4:
|
|
71
|
+
k.wait("f4")
|
|
72
|
+
elif key == 5:
|
|
73
|
+
k.wait("f5")
|
|
74
|
+
elif key == 6:
|
|
75
|
+
k.wait("f6")
|
|
76
|
+
elif key == 7:
|
|
77
|
+
k.wait("f7")
|
|
78
|
+
elif key == 8:
|
|
79
|
+
k.wait("f8")
|
|
80
|
+
elif key == 9:
|
|
81
|
+
k.wait("f9")
|
|
82
|
+
elif key == 10:
|
|
83
|
+
k.wait("f10")
|
|
84
|
+
elif key == 11:
|
|
85
|
+
k.wait("f11")
|
|
86
|
+
elif key == 12:
|
|
87
|
+
k.wait("f12")
|
|
88
|
+
elif key == 13:
|
|
89
|
+
k.wait("asciitilde")
|
|
90
|
+
elif key == 14:
|
|
91
|
+
k.wait("num 1")
|
|
92
|
+
elif key == 15:
|
|
93
|
+
k.wait("num 2")
|
|
94
|
+
elif key == 16:
|
|
95
|
+
k.wait("num 3")
|
|
96
|
+
elif key == 17:
|
|
97
|
+
k.wait("num 4")
|
|
98
|
+
elif key == 18:
|
|
99
|
+
k.wait("num 5")
|
|
100
|
+
elif key == 19:
|
|
101
|
+
k.wait("num 6")
|
|
102
|
+
elif key == 20:
|
|
103
|
+
k.wait("num 7")
|
|
104
|
+
elif key == 21:
|
|
105
|
+
k.wait("num 8")
|
|
106
|
+
elif key == 22:
|
|
107
|
+
k.wait("num 9")
|
|
108
|
+
elif key == 23:
|
|
109
|
+
k.wait("num 0")
|
|
110
|
+
elif key == 24:
|
|
111
|
+
k.wait("num minus")
|
|
112
|
+
elif key == 25:
|
|
113
|
+
k.wait("equal")
|
|
114
|
+
elif key == 26:
|
|
115
|
+
k.wait("tab")
|
|
116
|
+
elif key == 27:
|
|
117
|
+
k.wait("caps lock")
|
|
118
|
+
elif key == 28:
|
|
119
|
+
k.wait("left shift")
|
|
120
|
+
elif key == 29:
|
|
121
|
+
k.wait("left control")
|
|
122
|
+
elif key == 30:
|
|
123
|
+
k.wait("left win")
|
|
124
|
+
elif key == 31:
|
|
125
|
+
k.wait("left alt")
|
|
126
|
+
elif key == 32:
|
|
127
|
+
k.wait("space")
|
|
128
|
+
elif key == 33:
|
|
129
|
+
k.wait("alt gr")
|
|
130
|
+
elif key == 34:
|
|
131
|
+
k.wait("right win")
|
|
132
|
+
elif key == 35:
|
|
133
|
+
k.wait("menu")
|
|
134
|
+
elif key == 36:
|
|
135
|
+
k.wait("right control")
|
|
136
|
+
elif key == 37:
|
|
137
|
+
k.wait("right shift")
|
|
138
|
+
elif key == 38:
|
|
139
|
+
k.wait("return")
|
|
140
|
+
elif key == 39:
|
|
141
|
+
k.wait("backspace")
|
|
142
|
+
elif key == 40:
|
|
143
|
+
k.wait("q")
|
|
144
|
+
elif key == 41:
|
|
145
|
+
k.wait("w")
|
|
146
|
+
elif key == 42:
|
|
147
|
+
k.wait("e")
|
|
148
|
+
elif key == 43:
|
|
149
|
+
k.wait("r")
|
|
150
|
+
elif key == 44:
|
|
151
|
+
k.wait("t")
|
|
152
|
+
elif key == 45:
|
|
153
|
+
k.wait("y")
|
|
154
|
+
elif key == 46:
|
|
155
|
+
k.wait("u")
|
|
156
|
+
elif key == 47:
|
|
157
|
+
k.wait("i")
|
|
158
|
+
elif key == 48:
|
|
159
|
+
k.wait("o")
|
|
160
|
+
elif key == 49:
|
|
161
|
+
k.wait("p")
|
|
162
|
+
elif key == 50:
|
|
163
|
+
k.wait("a")
|
|
164
|
+
elif key == 51:
|
|
165
|
+
k.wait("s")
|
|
166
|
+
elif key == 52:
|
|
167
|
+
k.wait("d")
|
|
168
|
+
elif key == 53:
|
|
169
|
+
k.wait("f")
|
|
170
|
+
elif key == 54:
|
|
171
|
+
k.wait("g")
|
|
172
|
+
elif key == 55:
|
|
173
|
+
k.wait("h")
|
|
174
|
+
elif key == 56:
|
|
175
|
+
k.wait("j")
|
|
176
|
+
elif key == 57:
|
|
177
|
+
k.wait("k")
|
|
178
|
+
elif key == 58:
|
|
179
|
+
k.wait("l")
|
|
180
|
+
elif key == 59:
|
|
181
|
+
k.wait("z")
|
|
182
|
+
elif key == 60:
|
|
183
|
+
k.wait("x")
|
|
184
|
+
elif key == 61:
|
|
185
|
+
k.wait("c")
|
|
186
|
+
elif key == 62:
|
|
187
|
+
k.wait("v")
|
|
188
|
+
elif key == 63:
|
|
189
|
+
k.wait("b")
|
|
190
|
+
elif key == 64:
|
|
191
|
+
k.wait("n")
|
|
192
|
+
elif key == 65:
|
|
193
|
+
k.wait("m")
|
|
194
|
+
elif key == 66:
|
|
195
|
+
k.wait("bracketleft")
|
|
196
|
+
elif key == 67:
|
|
197
|
+
k.wait("bracketright")
|
|
198
|
+
elif key == 68:
|
|
199
|
+
k.wait("semicolon")
|
|
200
|
+
elif key == 69:
|
|
201
|
+
k.wait("apostrophe")
|
|
202
|
+
elif key == 70:
|
|
203
|
+
k.wait("backslash")
|
|
204
|
+
elif key == 71:
|
|
205
|
+
k.wait("comma")
|
|
206
|
+
elif key == 72:
|
|
207
|
+
k.wait("dot")
|
|
208
|
+
elif key == 73:
|
|
209
|
+
k.wait("slash")
|
|
210
|
+
elif key == 74:
|
|
211
|
+
k.wait("up arrow")
|
|
212
|
+
elif key == 75:
|
|
213
|
+
k.wait("left arrow")
|
|
214
|
+
elif key == 76:
|
|
215
|
+
k.wait("down arrow")
|
|
216
|
+
elif key == 77:
|
|
217
|
+
k.wait("right arrow")
|
|
218
|
+
elif key == 78:
|
|
219
|
+
k.wait("num lock")
|
|
220
|
+
elif key == 79:
|
|
221
|
+
k.wait("num add")
|
|
222
|
+
elif key == 80:
|
|
223
|
+
k.wait("num sub")
|
|
224
|
+
elif key == 81:
|
|
225
|
+
k.wait("num multiply")
|
|
226
|
+
elif key == 82:
|
|
227
|
+
k.wait("num divide")
|
|
228
|
+
elif key == 83:
|
|
229
|
+
k.wait("num enter")
|
|
230
|
+
elif key == 84:
|
|
231
|
+
k.wait("insert")
|
|
232
|
+
elif key == 85:
|
|
233
|
+
k.wait("delete")
|
|
234
|
+
elif key == 86:
|
|
235
|
+
k.wait("home")
|
|
236
|
+
elif key == 87:
|
|
237
|
+
k.wait("end")
|
|
238
|
+
elif key == 88:
|
|
239
|
+
k.wait("page up")
|
|
240
|
+
elif key == 89:
|
|
241
|
+
k.wait("page down")
|
|
242
|
+
elif key == 90:
|
|
243
|
+
k.wait("print screen")
|
|
244
|
+
elif key == 91:
|
|
245
|
+
k.wait("scroll lock")
|
|
246
|
+
elif key == 92:
|
|
247
|
+
k.wait("pause break")
|
|
248
|
+
|
|
249
|
+
def random(min: float, max: float):
|
|
250
|
+
"""
|
|
251
|
+
Returns a random float inside the specified range, including the lowest end but not the highest.
|
|
252
|
+
"""
|
|
253
|
+
return r.uniform(min, max)
|
|
254
|
+
|
|
255
|
+
def replace(string: str, character: str, replace: str):
|
|
256
|
+
"""
|
|
257
|
+
Replaces all the instances of a character in the specified string.
|
|
258
|
+
"""
|
|
259
|
+
replaced = ""
|
|
260
|
+
for i in string:
|
|
261
|
+
if i == character:
|
|
262
|
+
replaced += replace
|
|
263
|
+
else:
|
|
264
|
+
replaced += i
|
|
265
|
+
return replaced
|
|
266
|
+
|
|
267
|
+
def round(value: float):
|
|
268
|
+
"""
|
|
269
|
+
Rounds the specified float to the closest integer.
|
|
270
|
+
"""
|
|
271
|
+
if value * 10 >= (int(value) * 10) + 5:
|
|
272
|
+
return ceil(value)
|
|
273
|
+
else:
|
|
274
|
+
return floor(value)
|
|
275
|
+
|
|
276
|
+
def roundtodp(value: float, dp: int):
|
|
277
|
+
"""
|
|
278
|
+
Rounds the floating point number to the specified number of decimal places.
|
|
279
|
+
"""
|
|
280
|
+
return int(value * (10 ** dp)) / 10 ** dp
|
|
281
|
+
|
|
282
|
+
def run(path: str):
|
|
283
|
+
"""
|
|
284
|
+
Runs an external Python script.
|
|
285
|
+
"""
|
|
286
|
+
s.call(["python", f"{path}.py"])
|
|
287
|
+
|
|
288
|
+
def time():
|
|
289
|
+
"""
|
|
290
|
+
Returns the number of seconds that passed since the beginning of the program.
|
|
291
|
+
"""
|
|
292
|
+
return int(t.time() - timer)
|
|
293
|
+
|
|
294
|
+
def tstamp():
|
|
295
|
+
"""
|
|
296
|
+
Returns the number of seconds that passed since epoch.
|
|
297
|
+
"""
|
|
298
|
+
return int(t.time())
|
|
299
|
+
|
|
300
|
+
def wait(interval: float):
|
|
301
|
+
"""
|
|
302
|
+
Pauses the program for the given number of seconds.
|
|
303
|
+
"""
|
|
304
|
+
t.sleep(interval)
|
|
305
|
+
|
|
306
|
+
def zeropad(value: int, digits: int):
|
|
307
|
+
"""
|
|
308
|
+
Pads the specified number out to the given number of digits by adding zeroes to the left, then returns the number as a string.
|
|
309
|
+
"""
|
|
310
|
+
value = str(value)
|
|
311
|
+
string = ""
|
|
312
|
+
zeroes = digits - len(value)
|
|
313
|
+
for i in range(zeroes):
|
|
314
|
+
string += "0"
|
|
315
|
+
string += value
|
|
316
|
+
return string
|
|
317
|
+
|
|
318
|
+
class mathclass:
|
|
319
|
+
pi = 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
|
|
320
|
+
"""
|
|
321
|
+
Represents the value of Archimedes' Constant (π).
|
|
322
|
+
"""
|
|
323
|
+
|
|
324
|
+
e = 2.7182818284590452353602874713526624977572470936999595749669676277240766303535475945713821785251664274
|
|
325
|
+
"""
|
|
326
|
+
Represents the value of Euler's Number (e).
|
|
327
|
+
"""
|
|
328
|
+
|
|
329
|
+
def acos(x: float):
|
|
330
|
+
"""
|
|
331
|
+
Calculates the arc cosine of X.
|
|
332
|
+
"""
|
|
333
|
+
return m.acos(x)
|
|
334
|
+
|
|
335
|
+
def acosh(x: float):
|
|
336
|
+
"""
|
|
337
|
+
Calculates the inverse hyperbolic cosine of X.
|
|
338
|
+
"""
|
|
339
|
+
return m.acosh(x)
|
|
340
|
+
|
|
341
|
+
def asin(x: float):
|
|
342
|
+
"""
|
|
343
|
+
Calculates the arc sine of X.
|
|
344
|
+
"""
|
|
345
|
+
return m.asin(x)
|
|
346
|
+
|
|
347
|
+
def asinh(x: float):
|
|
348
|
+
"""
|
|
349
|
+
Calculates the inverse hyperbolic sine of X.
|
|
350
|
+
"""
|
|
351
|
+
return m.asinh(x)
|
|
352
|
+
|
|
353
|
+
def atan(x: float):
|
|
354
|
+
"""
|
|
355
|
+
Calculates the arc tangent of X.
|
|
356
|
+
"""
|
|
357
|
+
return m.atan(x)
|
|
358
|
+
|
|
359
|
+
def atanh(x: float):
|
|
360
|
+
"""
|
|
361
|
+
Calculates the inverse hyperbolic tangent of X.
|
|
362
|
+
"""
|
|
363
|
+
return m.atanh(x)
|
|
364
|
+
|
|
365
|
+
def cbrt(x: float):
|
|
366
|
+
"""
|
|
367
|
+
Calculates the cube root of X.
|
|
368
|
+
"""
|
|
369
|
+
return m.cbrt(x)
|
|
370
|
+
|
|
371
|
+
def clamp(x: float, a: float, b: float):
|
|
372
|
+
"""
|
|
373
|
+
Clamps the specified value.
|
|
374
|
+
"""
|
|
375
|
+
if x < a:
|
|
376
|
+
return a
|
|
377
|
+
elif x > b:
|
|
378
|
+
return b
|
|
379
|
+
else:
|
|
380
|
+
return x
|
|
381
|
+
|
|
382
|
+
def cos(x: float):
|
|
383
|
+
"""
|
|
384
|
+
Calculates the cosine of X.
|
|
385
|
+
"""
|
|
386
|
+
return m.cos(x)
|
|
387
|
+
|
|
388
|
+
def cosh(x: float):
|
|
389
|
+
"""
|
|
390
|
+
Calculates the hyperbolic cosine of X.
|
|
391
|
+
"""
|
|
392
|
+
return m.cosh(x)
|
|
393
|
+
|
|
394
|
+
def cosp(x: float, a: float, b: float):
|
|
395
|
+
"""
|
|
396
|
+
Interpolates the cosine of A to B by X.
|
|
397
|
+
"""
|
|
398
|
+
return (a + b + (a - b) * m.cos(x * 180)) / 2
|
|
399
|
+
|
|
400
|
+
def cubic(x: float, a: float, b: float, c: float, d: float):
|
|
401
|
+
"""
|
|
402
|
+
Cubically nterpolates through A, B, C and D by X.
|
|
403
|
+
"""
|
|
404
|
+
return math.lerp(math.qarp(a, b, c, x), math.qarp(b, c, d, x), x)
|
|
405
|
+
|
|
406
|
+
def distance(x1: float, x2: float, y1: float, y2: float):
|
|
407
|
+
"""
|
|
408
|
+
Calculates the distance between two points in a 2D environment.
|
|
409
|
+
"""
|
|
410
|
+
return m.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2)
|
|
411
|
+
|
|
412
|
+
def exp(x: float):
|
|
413
|
+
"""
|
|
414
|
+
Returns e (Euler's Number) to the power of X.
|
|
415
|
+
"""
|
|
416
|
+
return math.e ** x
|
|
417
|
+
|
|
418
|
+
def lerp(x: float, a: float, b: float):
|
|
419
|
+
"""
|
|
420
|
+
Linearly interpolates A to B by X.
|
|
421
|
+
"""
|
|
422
|
+
return a + x * (b - a)
|
|
423
|
+
|
|
424
|
+
def ln(x: float):
|
|
425
|
+
"""
|
|
426
|
+
Returns the base e logarithm of X.
|
|
427
|
+
"""
|
|
428
|
+
return m.log(x, math.e)
|
|
429
|
+
|
|
430
|
+
def log(x: float, l: float):
|
|
431
|
+
"""
|
|
432
|
+
Returns the specified base logarithm of X.
|
|
433
|
+
"""
|
|
434
|
+
return m.log(x, l)
|
|
435
|
+
|
|
436
|
+
def log10(x: float):
|
|
437
|
+
"""
|
|
438
|
+
Returns the base 10 logarithm of X.
|
|
439
|
+
"""
|
|
440
|
+
return m.log10(x)
|
|
441
|
+
|
|
442
|
+
def pol(a: int, b: int):
|
|
443
|
+
"""
|
|
444
|
+
Converts the specified complex number (A, B) from rectangular coordinates to polar coordinates.
|
|
445
|
+
"""
|
|
446
|
+
return c.polar(a, b)
|
|
447
|
+
|
|
448
|
+
def qarp(x: float, a: float, b: float, c: float):
|
|
449
|
+
"""
|
|
450
|
+
Quadriatically interpolates through A, B and C by X.
|
|
451
|
+
"""
|
|
452
|
+
return math.lerp(math.lerp(a, b, x), math.lerp(b, c, x), x)
|
|
453
|
+
|
|
454
|
+
def rec(r: float, p: float):
|
|
455
|
+
"""
|
|
456
|
+
Converts the specified complex number (R, Φ) from polar coordinates to rectangular coordinates.
|
|
457
|
+
"""
|
|
458
|
+
return c.rect(r, p)
|
|
459
|
+
|
|
460
|
+
def sign(x):
|
|
461
|
+
"""
|
|
462
|
+
Returns 1 for positive values, -1 for negative values or 0 for zero.
|
|
463
|
+
"""
|
|
464
|
+
if x > 0:
|
|
465
|
+
return 1
|
|
466
|
+
elif x < 0:
|
|
467
|
+
return - 1
|
|
468
|
+
else:
|
|
469
|
+
return 0
|
|
470
|
+
|
|
471
|
+
def sin(x: float):
|
|
472
|
+
"""
|
|
473
|
+
Calculates the sine of X.
|
|
474
|
+
"""
|
|
475
|
+
return m.sin(x)
|
|
476
|
+
|
|
477
|
+
def sinh(x: float):
|
|
478
|
+
"""
|
|
479
|
+
Calculates the hyperbolic sine of X.
|
|
480
|
+
"""
|
|
481
|
+
return m.sinh(x)
|
|
482
|
+
|
|
483
|
+
def sqrt(x: float):
|
|
484
|
+
"""
|
|
485
|
+
Calculates the square root of X.
|
|
486
|
+
"""
|
|
487
|
+
return m.sqrt(x)
|
|
488
|
+
|
|
489
|
+
def tan(x: float):
|
|
490
|
+
"""
|
|
491
|
+
Calculates the tangent of X.
|
|
492
|
+
"""
|
|
493
|
+
return m.tan(x)
|
|
494
|
+
|
|
495
|
+
def tanh(x: float):
|
|
496
|
+
"""
|
|
497
|
+
Calculates the hyperbolic tangent of X.
|
|
498
|
+
"""
|
|
499
|
+
return m.tanh(x)
|
|
500
|
+
|
|
501
|
+
def unlerp(a: float, b: float, y: float):
|
|
502
|
+
"""
|
|
503
|
+
Linearly interpolates A to B by Y, e.g. the reverses lerping.
|
|
504
|
+
"""
|
|
505
|
+
return (y - a) / (b - a)
|
|
506
|
+
|
|
507
|
+
class drawclass:
|
|
508
|
+
def line(length: int, formation: int = 0, fixed_width: bool = True):
|
|
509
|
+
"""
|
|
510
|
+
Draws a line in the console using full block characters.
|
|
511
|
+
"""
|
|
512
|
+
if fixed_width:
|
|
513
|
+
if formation == 0:
|
|
514
|
+
for i in range(length):
|
|
515
|
+
print("██", end = "")
|
|
516
|
+
elif formation == 1:
|
|
517
|
+
indent = 0
|
|
518
|
+
for i in range(length):
|
|
519
|
+
for i in range(indent):
|
|
520
|
+
print(" ", end = "")
|
|
521
|
+
print("██", end = "\n")
|
|
522
|
+
indent += 1
|
|
523
|
+
elif formation == 2:
|
|
524
|
+
for i in range(length):
|
|
525
|
+
print("██", end = "\n")
|
|
526
|
+
elif formation == 3:
|
|
527
|
+
indent = length - 1
|
|
528
|
+
for i in range(length):
|
|
529
|
+
for i in range(indent):
|
|
530
|
+
print(" ", end = "")
|
|
531
|
+
print("██", end = "\n")
|
|
532
|
+
indent -= 1
|
|
533
|
+
else:
|
|
534
|
+
if formation == 0:
|
|
535
|
+
for i in range(length):
|
|
536
|
+
print("█", end = "")
|
|
537
|
+
elif formation == 1:
|
|
538
|
+
indent = 0
|
|
539
|
+
for i in range(length):
|
|
540
|
+
for i in range(indent):
|
|
541
|
+
print(" ", end = "")
|
|
542
|
+
print("█", end = "\n")
|
|
543
|
+
indent += 1
|
|
544
|
+
elif formation == 2:
|
|
545
|
+
for i in range(length):
|
|
546
|
+
print("█", end = "\n")
|
|
547
|
+
elif formation == 3:
|
|
548
|
+
indent = length - 1
|
|
549
|
+
for i in range(length):
|
|
550
|
+
for i in range(indent):
|
|
551
|
+
print(" ", end = "")
|
|
552
|
+
print("█", end = "\n")
|
|
553
|
+
indent -= 1
|
|
554
|
+
print()
|
|
555
|
+
|
|
556
|
+
def rect(width: int, height: int, fixed_width: bool = True):
|
|
557
|
+
"""
|
|
558
|
+
Draws a rectangle in the console using full block characters.
|
|
559
|
+
"""
|
|
560
|
+
if fixed_width:
|
|
561
|
+
for i in range(height):
|
|
562
|
+
for i in range(width):
|
|
563
|
+
print("██", end = "")
|
|
564
|
+
print()
|
|
565
|
+
else:
|
|
566
|
+
for i in range(height):
|
|
567
|
+
for i in range(width):
|
|
568
|
+
print("█", end = "")
|
|
569
|
+
print()
|
|
570
|
+
print()
|
|
571
|
+
|
|
572
|
+
def rectb(width: int, height: int, fixed_width: bool = True):
|
|
573
|
+
"""
|
|
574
|
+
Draws a rectangle border in the console using full block characters.
|
|
575
|
+
"""
|
|
576
|
+
if fixed_width:
|
|
577
|
+
for i in range(width):
|
|
578
|
+
print("██", end = "")
|
|
579
|
+
print()
|
|
580
|
+
for i in range(height):
|
|
581
|
+
print("██", end = "")
|
|
582
|
+
for i in range(2, width):
|
|
583
|
+
print(" ", end = "")
|
|
584
|
+
print("██", end = "")
|
|
585
|
+
print()
|
|
586
|
+
for i in range(width):
|
|
587
|
+
print("██", end = "")
|
|
588
|
+
else:
|
|
589
|
+
for i in range(width):
|
|
590
|
+
print("█", end = "")
|
|
591
|
+
print()
|
|
592
|
+
for i in range(height):
|
|
593
|
+
print("█", end = "")
|
|
594
|
+
for i in range(2, width):
|
|
595
|
+
print(" ", end = "")
|
|
596
|
+
print("█", end = "")
|
|
597
|
+
print()
|
|
598
|
+
for i in range(width):
|
|
599
|
+
print("█", end = "")
|
|
600
|
+
print()
|
|
601
|
+
|
|
602
|
+
math = mathclass
|
|
603
|
+
"""
|
|
604
|
+
A sub-class of Wraith that extends the math library.
|
|
605
|
+
"""
|
|
606
|
+
|
|
607
|
+
draw = drawclass
|
|
608
|
+
"""
|
|
609
|
+
A sub-class of Wraith that adds in-console drawing functions.
|
|
610
|
+
"""
|