printrgb 1.1.8__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.
- printrgb-1.1.8/LICENSE +21 -0
- printrgb-1.1.8/PKG-INFO +45 -0
- printrgb-1.1.8/README.md +8 -0
- printrgb-1.1.8/pyproject.toml +28 -0
- printrgb-1.1.8/setup.cfg +4 -0
- printrgb-1.1.8/src/printrgb/__init__.py +8 -0
- printrgb-1.1.8/src/printrgb/__main__.py +33 -0
- printrgb-1.1.8/src/printrgb/printrgb.py +195 -0
- printrgb-1.1.8/src/printrgb/printrgb.pyi +23 -0
- printrgb-1.1.8/src/printrgb/py.typed +0 -0
- printrgb-1.1.8/src/printrgb.egg-info/PKG-INFO +45 -0
- printrgb-1.1.8/src/printrgb.egg-info/SOURCES.txt +13 -0
- printrgb-1.1.8/src/printrgb.egg-info/dependency_links.txt +1 -0
- printrgb-1.1.8/src/printrgb.egg-info/entry_points.txt +2 -0
- printrgb-1.1.8/src/printrgb.egg-info/top_level.txt +1 -0
printrgb-1.1.8/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 LuoTianyi-arm64
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
printrgb-1.1.8/PKG-INFO
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: printrgb
|
|
3
|
+
Version: 1.1.8
|
|
4
|
+
Summary: Print rainbow text in terminal with true-color
|
|
5
|
+
Author-email: LuoTianyi-arm64 <2153585992@qq.com>
|
|
6
|
+
License: # MIT License
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2026 LuoTianyi-arm64
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
in the Software without restriction, including without limitation the rights
|
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
furnished to do so, subject to the following conditions:
|
|
16
|
+
|
|
17
|
+
The above copyright notice and this permission notice shall be included in all
|
|
18
|
+
copies or substantial portions of the Software.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
+
SOFTWARE.
|
|
27
|
+
|
|
28
|
+
Project-URL: Homepage, https://github.com/LuoTianyi-arm64/printrgb
|
|
29
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
30
|
+
Classifier: Programming Language :: Python :: 3
|
|
31
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
32
|
+
Classifier: Operating System :: OS Independent
|
|
33
|
+
Requires-Python: >=3.10
|
|
34
|
+
Description-Content-Type: text/markdown
|
|
35
|
+
License-File: LICENSE
|
|
36
|
+
Dynamic: license-file
|
|
37
|
+
|
|
38
|
+
# printrgb
|
|
39
|
+
|
|
40
|
+
Print text in rainbow colors .
|
|
41
|
+
|
|
42
|
+
```python
|
|
43
|
+
pip install printrgb
|
|
44
|
+
python -c "from printrgb import printrgb; printrgb('Hello, world!', rainbow=True)"
|
|
45
|
+
```
|
printrgb-1.1.8/README.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "printrgb"
|
|
7
|
+
version = "1.1.8"
|
|
8
|
+
description = "Print rainbow text in terminal with true-color"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = {file = "LICENSE"}
|
|
11
|
+
authors = [{name = "LuoTianyi-arm64", email = "2153585992@qq.com"}]
|
|
12
|
+
classifiers = [
|
|
13
|
+
"License :: OSI Approved :: MIT License",
|
|
14
|
+
"Programming Language :: Python :: 3",
|
|
15
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
16
|
+
"Operating System :: OS Independent",
|
|
17
|
+
]
|
|
18
|
+
requires-python = ">=3.10"
|
|
19
|
+
|
|
20
|
+
[project.scripts]
|
|
21
|
+
printrgb = "printrgb.__main__:main"
|
|
22
|
+
|
|
23
|
+
[tool.setuptools.package-data]
|
|
24
|
+
printrgb = ["py.typed", "*.pyi"]
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
[project.urls]
|
|
28
|
+
Homepage = "https://github.com/LuoTianyi-arm64/printrgb"
|
printrgb-1.1.8/setup.cfg
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
|
|
2
|
+
import sys
|
|
3
|
+
from . import printrgb
|
|
4
|
+
|
|
5
|
+
version = "1.1.8"
|
|
6
|
+
|
|
7
|
+
def main() -> None:
|
|
8
|
+
argv = sys.argv
|
|
9
|
+
ask = ''
|
|
10
|
+
if argv:
|
|
11
|
+
if len(argv) == 2:
|
|
12
|
+
if argv[1] in ['-h','--help']:
|
|
13
|
+
ask = '''Argvs of Using printrgb
|
|
14
|
+
printrgb(*values: object,
|
|
15
|
+
foreground_color: list | tuple | None = None,
|
|
16
|
+
background_color: list | tuple | None = None,
|
|
17
|
+
sep: str = " ",
|
|
18
|
+
rainbow: bool = False,
|
|
19
|
+
angle_mode : Literal[\'inner\',\'init\',\'random\'] = \'random\',
|
|
20
|
+
end: str = "\\n",
|
|
21
|
+
file : object | None = None,
|
|
22
|
+
get_color : types.FunctionType | None = None,
|
|
23
|
+
flush: Literal[False] = False
|
|
24
|
+
swap_fbc: bool = False,
|
|
25
|
+
allow_rainbow_blank: bool = False(Using it when swap_fbc)'''
|
|
26
|
+
elif argv[1] in ['-v','--version']:
|
|
27
|
+
ask = f'printrgb {version} by LuoTainyi-arm64'
|
|
28
|
+
printrgb(ask, rainbow = True)
|
|
29
|
+
if not sys.stdin.isatty():
|
|
30
|
+
printrgb(sys.stdin.read(), rainbow = True)
|
|
31
|
+
|
|
32
|
+
if __name__ == "__main__":
|
|
33
|
+
main()
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import types
|
|
2
|
+
import random
|
|
3
|
+
import shutil
|
|
4
|
+
from typing import Literal
|
|
5
|
+
|
|
6
|
+
# const
|
|
7
|
+
rainbow_color = [(237, 138, 171), (238, 138, 169), (238, 138, 168), (239, 138, 166), (239, 138, 165), (239, 138, 163), (240, 138, 162), (240, 138, 160), (240, 138, 159), (240, 138, 157), (241, 139, 156), (241, 139, 154), (241, 139, 153), (241, 139, 151), (242, 139, 150), (242, 139, 149), (242, 139, 147), (242, 139, 146), (242, 139, 144), (242, 139, 143), (242, 140, 141), (242, 140, 140), (242, 140, 138), (242, 140, 137), (242, 140, 135), (242, 141, 134), (242, 141, 132), (242, 141, 131), (242, 141, 129), (242, 141, 128), (242, 142, 127), (242, 142, 125), (242, 142, 124), (242, 143, 122), (242, 143, 121), (241, 143, 119), (241, 143, 118), (241, 144, 117), (241, 144, 115), (240, 144, 114), (240, 145, 112), (240, 145, 111), (240, 145, 110), (239, 146, 108), (239, 146, 107), (239, 147, 106), (238, 147, 104), (238, 147, 103), (237, 148, 102), (237, 148, 101), (236, 149, 99), (236, 149, 98), (235, 150, 97), (235, 150, 96), (234, 150, 94), (234, 151, 93), (233, 151, 92), (233, 152, 91), (232, 152, 90), (232, 153, 89), (231, 153, 88), (230, 154, 86), (230, 154, 85), (229, 155, 84), (228, 155, 83), (228, 156, 82), (227, 156, 82), (226, 157, 81), (225, 157, 80), (224, 158, 79), (224, 158, 78), (223, 159, 77), (222, 160, 77), (221, 160, 76), (220, 161, 75), (219, 161, 74), (218, 162, 74), (218, 162, 73), (217, 163, 73), (216, 163, 72), (215, 164, 72), (214, 164, 71), (213, 165, 71), (212, 166, 71), (211, 166, 71), (210, 167, 70), (209, 167, 70), (207, 168, 70), (206, 168, 70), (205, 169, 70), (204, 169, 70), (203, 170, 70), (202, 171, 70), (201, 171, 70), (199, 172, 70), (198, 172, 71), (197, 173, 71), (196, 173, 71), (195, 174, 72), (193, 174, 72), (192, 175, 73), (191, 175, 73), (189, 176, 74), (188, 177, 74), (187, 177, 75), (185, 178, 76), (184, 178, 76), (183, 179, 77), (181, 179, 78), (180, 180, 79), (178, 180, 80), (177, 181, 81), (175, 181, 81), (174, 182, 82), (173, 182, 83), (171, 183, 84), (170, 183, 85), (168, 184, 87), (166, 184, 88), (165, 184, 89), (163, 185, 90), (162, 185, 91), (160, 186, 92), (159, 186, 93), (157, 187, 95), (155, 187, 96), (154, 188, 97), (152, 188, 98), (150, 188, 100), (149, 189, 101), (147, 189, 102), (145, 190, 104), (144, 190, 105), (142, 190, 106), (140, 191, 108), (138, 191, 109), (137, 191, 111), (135, 192, 112), (133, 192, 113), (131, 192, 115), (130, 193, 116), (128, 193, 118), (126, 193, 119), (124, 194, 121), (122, 194, 122), (120, 194, 124), (118, 195, 125), (117, 195, 127), (115, 195, 128), (113, 195, 130), (111, 196, 131), (109, 196, 133), (107, 196, 134), (105, 196, 136), (103, 196, 137), (101, 197, 139), (99, 197, 140), (97, 197, 142), (95, 197, 143), (93, 197, 145), (91, 198, 146), (89, 198, 148), (87, 198, 149), (85, 198, 151), (83, 198, 152), (81, 198, 154), (79, 198, 155), (77, 198, 157), (75, 199, 159), (73, 199, 160), (71, 199, 162), (69, 199, 163), (67, 199, 165), (65, 199, 166), (63, 199, 168), (60, 199, 169), (58, 199, 171), (56, 199, 172), (54, 199, 174), (52, 199, 175), (50, 199, 177), (48, 199, 178), (46, 199, 180), (44, 199, 181), (42, 199, 182), (40, 199, 184), (38, 199, 185), (36, 199, 187), (34, 198, 188), (32, 198, 190), (31, 198, 191), (29, 198, 192), (27, 198, 194), (26, 198, 195), (25, 198, 197), (24, 198, 198), (23, 197, 199), (22, 197, 201), (21, 197, 202), (21, 197, 203), (21, 197, 205), (21, 196, 206), (22, 196, 207), (22, 196, 208), (23, 196, 210), (24, 196, 211), (25, 195, 212), (26, 195, 213), (28, 195, 215), (29, 195, 216), (31, 194, 217), (33, 194, 218), (35, 194, 219), (36, 193, 220), (38, 193, 222), (40, 193, 223), (42, 193, 224), (44, 192, 225), (46, 192, 226), (48, 192, 227), (50, 191, 228), (52, 191, 229), (54, 191, 230), (56, 190, 231), (58, 190, 232), (60, 189, 233), (62, 189, 234), (64, 189, 234), (66, 188, 235), (68, 188, 236), (70, 187, 237), (72, 187, 238), (74, 187, 239), (76, 186, 239), (78, 186, 240), (80, 185, 241), (82, 185, 242), (84, 185, 242), (86, 184, 243), (88, 184, 244), (90, 183, 244), (92, 183, 245), (94, 182, 245), (96, 182, 246), (97, 181, 247), (99, 181, 247), (101, 181, 248), (103, 180, 248), (105, 180, 249), (107, 179, 249), (109, 179, 249), (110, 178, 250), (112, 178, 250), (114, 177, 251), (116, 177, 251), (117, 176, 251), (119, 176, 251), (121, 175, 252), (123, 175, 252), (124, 174, 252), (126, 174, 252), (128, 173, 252), (129, 173, 253), (131, 172, 253), (133, 172, 253), (135, 171, 253), (136, 171, 253), (138, 170, 253), (139, 170, 253), (141, 169, 253), (143, 169, 253), (144, 168, 253), (146, 168, 253), (147, 167, 253), (149, 167, 252), (151, 166, 252), (152, 166, 252), (154, 165, 252), (155, 165, 252), (157, 164, 251), (158, 164, 251), (160, 163, 251), (161, 163, 250), (163, 162, 250), (164, 162, 250), (165, 162, 249), (167, 161, 249), (168, 161, 248), (170, 160, 248), (171, 160, 248), (172, 159, 247), (174, 159, 246), (175, 158, 246), (177, 158, 245), (178, 157, 245), (179, 157, 244), (181, 156, 244), (182, 156, 243), (183, 155, 242), (184, 155, 242), (186, 155, 241), (187, 154, 240), (188, 154, 239), (189, 153, 239), (191, 153, 238), (192, 152, 237), (193, 152, 236), (194, 152, 235), (195, 151, 234), (197, 151, 234), (198, 150, 233), (199, 150, 232), (200, 150, 231), (201, 149, 230), (202, 149, 229), (203, 149, 228), (204, 148, 227), (205, 148, 226), (206, 147, 225), (207, 147, 224), (208, 147, 223), (209, 146, 222), (210, 146, 221), (211, 146, 219), (212, 145, 218), (213, 145, 217), (214, 145, 216), (215, 144, 215), (216, 144, 214), (217, 144, 212), (218, 144, 211), (219, 143, 210), (220, 143, 209), (220, 143, 208), (221, 142, 206), (222, 142, 205), (223, 142, 204), (224, 142, 203), (224, 141, 201), (225, 141, 200), (226, 141, 199), (227, 141, 197), (227, 141, 196), (228, 140, 195), (229, 140, 193), (229, 140, 192), (230, 140, 190), (231, 140, 189), (231, 140, 188), (232, 139, 186), (232, 139, 185), (233, 139, 184), (234, 139, 182), (234, 139, 181), (235, 139, 179), (235, 139, 178), (236, 139, 176), (236, 139, 175), (236, 139, 174), (237, 138, 172)]
|
|
8
|
+
|
|
9
|
+
def get_terminal_width() -> None:
|
|
10
|
+
return shutil.get_terminal_size().columns
|
|
11
|
+
|
|
12
|
+
def get_color_default(angle:int)-> tuple:
|
|
13
|
+
return rainbow_color[angle % 360] # type: ignore
|
|
14
|
+
class printrgb:
|
|
15
|
+
def __init__(self):
|
|
16
|
+
self.angle = 0
|
|
17
|
+
|
|
18
|
+
def __call__(self, *values: object,
|
|
19
|
+
foreground_color: list | tuple | None = None,
|
|
20
|
+
background_color: list | tuple | None = None,
|
|
21
|
+
sep: str = " ",
|
|
22
|
+
rainbow: bool = False,
|
|
23
|
+
angle_mode : Literal['inner','init','random'] = 'random',
|
|
24
|
+
end: str = "\n",
|
|
25
|
+
file : object | None = None,
|
|
26
|
+
get_color : types.FunctionType | None = None,
|
|
27
|
+
flush: Literal[False] = False,
|
|
28
|
+
swap_fbc: bool = False,
|
|
29
|
+
allow_rainbow_blank: bool = False) -> None:
|
|
30
|
+
get_color = get_color_default if get_color is None else get_color
|
|
31
|
+
if not rainbow:
|
|
32
|
+
esc = []
|
|
33
|
+
if foreground_color:
|
|
34
|
+
esc.append(f'38;2;{";".join(map(str, foreground_color))}')
|
|
35
|
+
if background_color:
|
|
36
|
+
esc.append(f'48;2;{";".join(map(str, background_color))}')
|
|
37
|
+
color_code = ";".join(esc)
|
|
38
|
+
if swap_fbc:
|
|
39
|
+
colored_text = f'\033[7m\033[{color_code}m{sep.join(map(str, values))}\033[0m'
|
|
40
|
+
else:
|
|
41
|
+
colored_text = f'\033[{color_code}m{sep.join(map(str, values))}\033[0m'
|
|
42
|
+
print(colored_text, sep = sep, end = end, file = file, flush = flush)
|
|
43
|
+
else:
|
|
44
|
+
if foreground_color or background_color:
|
|
45
|
+
print('\033[38;2;255;0;0mError,You can\'t print with rainbow and other color angle_mode in the same time.\033[0m')
|
|
46
|
+
else:
|
|
47
|
+
text = f'{sep.join(map(str, values))}'
|
|
48
|
+
if angle_mode == 'inner':
|
|
49
|
+
x = 0
|
|
50
|
+
y = 0
|
|
51
|
+
j = ''
|
|
52
|
+
k = 0
|
|
53
|
+
p = 0
|
|
54
|
+
for i in text:
|
|
55
|
+
p += 1
|
|
56
|
+
if i == '':
|
|
57
|
+
j += i
|
|
58
|
+
k = 1
|
|
59
|
+
elif k == 1:
|
|
60
|
+
if i == '[':
|
|
61
|
+
j += i
|
|
62
|
+
k = 2
|
|
63
|
+
else :
|
|
64
|
+
j = i
|
|
65
|
+
x += 1
|
|
66
|
+
if x == get_terminal_width():
|
|
67
|
+
x = 0
|
|
68
|
+
y += 1
|
|
69
|
+
printrgb(i,foreground_color=get_color(self.angle + x * 5 + y * 7),end = '',file = file,swap_fbc = swap_fbc)
|
|
70
|
+
k = 0
|
|
71
|
+
elif k > 1 :
|
|
72
|
+
if 64 <= ord(i) <= 126:
|
|
73
|
+
j += i
|
|
74
|
+
printrgb(j,foreground_color=get_color(self.angle + x * 5 + y * 7),end = '',file = file,swap_fbc = swap_fbc)
|
|
75
|
+
j = ''
|
|
76
|
+
k = 0
|
|
77
|
+
else :
|
|
78
|
+
j += i
|
|
79
|
+
elif i != '\n' :
|
|
80
|
+
if i == ' ' :
|
|
81
|
+
if allow_rainbow_blank:
|
|
82
|
+
printrgb(i,foreground_color=get_color(self.angle + x * 5 + y * 7),end = '',file = file,swap_fbc = swap_fbc)
|
|
83
|
+
else:
|
|
84
|
+
print(' ',end = '',file = file)
|
|
85
|
+
else:
|
|
86
|
+
printrgb(i,foreground_color=get_color(self.angle + x * 5 + y * 7),end = '',file = file,swap_fbc = swap_fbc)
|
|
87
|
+
x += 1
|
|
88
|
+
if x == get_terminal_width():
|
|
89
|
+
x = 0
|
|
90
|
+
y += 1
|
|
91
|
+
else:
|
|
92
|
+
x = 1
|
|
93
|
+
y += 1
|
|
94
|
+
print('',file = file)
|
|
95
|
+
self.angle += y * 7 + 14
|
|
96
|
+
elif angle_mode == 'init':
|
|
97
|
+
x = 0
|
|
98
|
+
y = 0
|
|
99
|
+
j = ''
|
|
100
|
+
k = 0
|
|
101
|
+
p = 0
|
|
102
|
+
for i in text:
|
|
103
|
+
p += 1
|
|
104
|
+
if i == '':
|
|
105
|
+
j += i
|
|
106
|
+
k = 1
|
|
107
|
+
elif k == 1:
|
|
108
|
+
if i == '[':
|
|
109
|
+
j += i
|
|
110
|
+
k = 2
|
|
111
|
+
else :
|
|
112
|
+
j = i
|
|
113
|
+
x += 1
|
|
114
|
+
if x == get_terminal_width():
|
|
115
|
+
x = 0
|
|
116
|
+
y += 1
|
|
117
|
+
printrgb(i,foreground_color=get_color(x * 5 + y * 7),end = '',file = file,swap_fbc = swap_fbc)
|
|
118
|
+
k = 0
|
|
119
|
+
elif k > 1 :
|
|
120
|
+
if 64 <= ord(i) <= 126:
|
|
121
|
+
j += i
|
|
122
|
+
printrgb(j,foreground_color=get_color(x * 5 + y * 7),end = '',file = file,swap_fbc = swap_fbc)
|
|
123
|
+
j = ''
|
|
124
|
+
k = 0
|
|
125
|
+
else :
|
|
126
|
+
j += i
|
|
127
|
+
elif i != '\n' :
|
|
128
|
+
if i == ' ' :
|
|
129
|
+
if allow_rainbow_blank:
|
|
130
|
+
printrgb(i,foreground_color=get_color(x * 5 + y * 7),end = '',file = file,swap_fbc = swap_fbc)
|
|
131
|
+
else:
|
|
132
|
+
print(' ',end = '',file = file)
|
|
133
|
+
else:
|
|
134
|
+
printrgb(i,foreground_color=get_color(x * 5 + y * 7),end = '',file = file,swap_fbc = swap_fbc)
|
|
135
|
+
x += 1
|
|
136
|
+
if x == get_terminal_width():
|
|
137
|
+
x = 0
|
|
138
|
+
y += 1
|
|
139
|
+
else:
|
|
140
|
+
x = 1
|
|
141
|
+
y += 1
|
|
142
|
+
print('',file = file)
|
|
143
|
+
self.angle += y * 7 + 14
|
|
144
|
+
else:
|
|
145
|
+
angle = random.randint(0,359)
|
|
146
|
+
x = 0
|
|
147
|
+
y = 0
|
|
148
|
+
j = ''
|
|
149
|
+
k = 0
|
|
150
|
+
p = 0
|
|
151
|
+
for i in text:
|
|
152
|
+
p += 1
|
|
153
|
+
if i == '':
|
|
154
|
+
j += i
|
|
155
|
+
k = 1
|
|
156
|
+
elif k == 1:
|
|
157
|
+
if i == '[':
|
|
158
|
+
j += i
|
|
159
|
+
k = 2
|
|
160
|
+
else :
|
|
161
|
+
j = i
|
|
162
|
+
x += 1
|
|
163
|
+
if x == get_terminal_width():
|
|
164
|
+
x = 0
|
|
165
|
+
y += 1
|
|
166
|
+
printrgb(i,foreground_color=get_color(angle + x * 5 + y * 7),end = '',file = file,swap_fbc = swap_fbc)
|
|
167
|
+
k = 0
|
|
168
|
+
elif k > 1 :
|
|
169
|
+
if 64 <= ord(i) <= 126:
|
|
170
|
+
j += i
|
|
171
|
+
printrgb(j,foreground_color=get_color(angle + x * 5 + y * 7),end = '',file = file,swap_fbc = swap_fbc)
|
|
172
|
+
j = ''
|
|
173
|
+
k = 0
|
|
174
|
+
else :
|
|
175
|
+
j += i
|
|
176
|
+
elif i != '\n' :
|
|
177
|
+
if i == ' ' :
|
|
178
|
+
if allow_rainbow_blank:
|
|
179
|
+
printrgb(i,foreground_color=get_color(angle + x * 5 + y * 7),end = '',file = file,swap_fbc = swap_fbc)
|
|
180
|
+
else:
|
|
181
|
+
print(' ',end = '',file = file)
|
|
182
|
+
else:
|
|
183
|
+
printrgb(i,foreground_color=get_color(angle + x * 5 + y * 7),end = '',file = file,swap_fbc = swap_fbc)
|
|
184
|
+
x += 1
|
|
185
|
+
if x == get_terminal_width():
|
|
186
|
+
x = 0
|
|
187
|
+
y += 1
|
|
188
|
+
else:
|
|
189
|
+
x = 1
|
|
190
|
+
y += 1
|
|
191
|
+
print('',file = file)
|
|
192
|
+
print(end,end = '',file = file)
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
printrgb = printrgb()
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# src/printrgb/printrgb.pyi
|
|
2
|
+
from typing import Literal, Callable, Any, TextIO
|
|
3
|
+
|
|
4
|
+
def get_color_default(angle: int) -> tuple[int, int, int]: ...
|
|
5
|
+
|
|
6
|
+
class printrgb:
|
|
7
|
+
def __call__(
|
|
8
|
+
self,
|
|
9
|
+
*values: object,
|
|
10
|
+
foreground_color: list[int] | tuple[int, int, int] | None = None,
|
|
11
|
+
background_color: list[int] | tuple[int, int, int] | None = None,
|
|
12
|
+
sep: str = " ",
|
|
13
|
+
rainbow: bool = False,
|
|
14
|
+
angle_mode: Literal['inner', 'init', 'random'] = 'random',
|
|
15
|
+
end: str = "\n",
|
|
16
|
+
file: TextIO | Any | None = None,
|
|
17
|
+
get_color: Callable[[int], tuple[int, int, int]] | None = None,
|
|
18
|
+
flush: Literal[False] = False,
|
|
19
|
+
swap_fbc: bool = False,
|
|
20
|
+
allow_rainbow_blank: bool = False,
|
|
21
|
+
) -> None: ...
|
|
22
|
+
|
|
23
|
+
printrgb: printrgb
|
|
File without changes
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: printrgb
|
|
3
|
+
Version: 1.1.8
|
|
4
|
+
Summary: Print rainbow text in terminal with true-color
|
|
5
|
+
Author-email: LuoTianyi-arm64 <2153585992@qq.com>
|
|
6
|
+
License: # MIT License
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2026 LuoTianyi-arm64
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
in the Software without restriction, including without limitation the rights
|
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
furnished to do so, subject to the following conditions:
|
|
16
|
+
|
|
17
|
+
The above copyright notice and this permission notice shall be included in all
|
|
18
|
+
copies or substantial portions of the Software.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
+
SOFTWARE.
|
|
27
|
+
|
|
28
|
+
Project-URL: Homepage, https://github.com/LuoTianyi-arm64/printrgb
|
|
29
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
30
|
+
Classifier: Programming Language :: Python :: 3
|
|
31
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
32
|
+
Classifier: Operating System :: OS Independent
|
|
33
|
+
Requires-Python: >=3.10
|
|
34
|
+
Description-Content-Type: text/markdown
|
|
35
|
+
License-File: LICENSE
|
|
36
|
+
Dynamic: license-file
|
|
37
|
+
|
|
38
|
+
# printrgb
|
|
39
|
+
|
|
40
|
+
Print text in rainbow colors .
|
|
41
|
+
|
|
42
|
+
```python
|
|
43
|
+
pip install printrgb
|
|
44
|
+
python -c "from printrgb import printrgb; printrgb('Hello, world!', rainbow=True)"
|
|
45
|
+
```
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
src/printrgb/__init__.py
|
|
5
|
+
src/printrgb/__main__.py
|
|
6
|
+
src/printrgb/printrgb.py
|
|
7
|
+
src/printrgb/printrgb.pyi
|
|
8
|
+
src/printrgb/py.typed
|
|
9
|
+
src/printrgb.egg-info/PKG-INFO
|
|
10
|
+
src/printrgb.egg-info/SOURCES.txt
|
|
11
|
+
src/printrgb.egg-info/dependency_links.txt
|
|
12
|
+
src/printrgb.egg-info/entry_points.txt
|
|
13
|
+
src/printrgb.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
printrgb
|