color-ascii-magic-genai 0.0.1__py3-none-any.whl → 0.0.2__py3-none-any.whl
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.
- color_ascii_magic_genai/__init__.py +21 -0
- {color_ascii_magic_genai-0.0.1.dist-info → color_ascii_magic_genai-0.0.2.dist-info}/METADATA +4 -1
- color_ascii_magic_genai-0.0.2.dist-info/RECORD +4 -0
- color_ascii_magic_genai-0.0.1.dist-info/RECORD +0 -4
- {color_ascii_magic_genai-0.0.1.dist-info → color_ascii_magic_genai-0.0.2.dist-info}/WHEEL +0 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
from art import text2art
|
|
2
2
|
from termcolor import colored
|
|
3
|
+
import random
|
|
3
4
|
|
|
4
5
|
def colorize_text(text: str, color: str = 'white', font: str = 'block') -> str:
|
|
5
6
|
"""
|
|
@@ -8,14 +9,34 @@ def colorize_text(text: str, color: str = 'white', font: str = 'block') -> str:
|
|
|
8
9
|
Args:
|
|
9
10
|
text (str): The text to convert to ASCII art.
|
|
10
11
|
color (str): The color to apply. Supported colors: red, green, yellow, blue, magenta, cyan, white.
|
|
12
|
+
Also supports 'random' (random color for whole text) and 'rainbow' (random per character).
|
|
11
13
|
font (str): The font style for ASCII art.
|
|
12
14
|
|
|
13
15
|
Returns:
|
|
14
16
|
str: Colored ASCII art string.
|
|
15
17
|
"""
|
|
16
18
|
ascii_art = text2art(text, font=font)
|
|
19
|
+
|
|
20
|
+
if color == 'random':
|
|
21
|
+
color = random.choice(available_colors())
|
|
22
|
+
return colored(ascii_art, color)
|
|
23
|
+
|
|
24
|
+
if color == 'rainbow':
|
|
25
|
+
colored_chars = []
|
|
26
|
+
for char in ascii_art:
|
|
27
|
+
# color only non-whitespace characters to avoid weird background issues depending on terminal
|
|
28
|
+
# actually, termcolor colored() on space is fine usually, but let's be safe or just color everything?
|
|
29
|
+
# random.choice on every char
|
|
30
|
+
if char.strip():
|
|
31
|
+
c = random.choice(available_colors())
|
|
32
|
+
colored_chars.append(colored(char, c))
|
|
33
|
+
else:
|
|
34
|
+
colored_chars.append(char)
|
|
35
|
+
return "".join(colored_chars)
|
|
36
|
+
|
|
17
37
|
return colored(ascii_art, color)
|
|
18
38
|
|
|
19
39
|
def available_colors():
|
|
20
40
|
"""Returns a list of available colors."""
|
|
21
41
|
return ['red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white']
|
|
42
|
+
|
{color_ascii_magic_genai-0.0.1.dist-info → color_ascii_magic_genai-0.0.2.dist-info}/METADATA
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: color_ascii_magic_genai
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.2
|
|
4
4
|
Summary: A small example package for generating colored ASCII art
|
|
5
5
|
Project-URL: Homepage, https://github.com/example/color_ascii_magic_genai
|
|
6
6
|
Author-email: Prasoon Kumar <prasoonkumar@example.com>
|
|
@@ -28,4 +28,7 @@ pip install color_ascii_magic_genai
|
|
|
28
28
|
from color_ascii_magic_genai import colorize_text
|
|
29
29
|
|
|
30
30
|
print(colorize_text("Hello World", color="red"))
|
|
31
|
+
print(colorize_text("Random Color", color="random"))
|
|
32
|
+
print(colorize_text("Rainbow Text", color="rainbow"))
|
|
33
|
+
|
|
31
34
|
```
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
color_ascii_magic_genai/__init__.py,sha256=qGcpbdTvr6rA-1_hMxrhrRYPTXOgWA4kTUrYePrdm6Y,1559
|
|
2
|
+
color_ascii_magic_genai-0.0.2.dist-info/METADATA,sha256=SGFgc3Wx3TxeGEyrKhgxvgaoaAS3toZyOcPAuKZWusY,902
|
|
3
|
+
color_ascii_magic_genai-0.0.2.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
4
|
+
color_ascii_magic_genai-0.0.2.dist-info/RECORD,,
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
color_ascii_magic_genai/__init__.py,sha256=hx_wik8qsxtBLjeuXbVdb5vhHKn6CkzvQjhquQQPWrw,715
|
|
2
|
-
color_ascii_magic_genai-0.0.1.dist-info/METADATA,sha256=NohnDNYhED4eQPCc4QwK0dLliZ7UxMKV7lCCSrsQIxc,794
|
|
3
|
-
color_ascii_magic_genai-0.0.1.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
4
|
-
color_ascii_magic_genai-0.0.1.dist-info/RECORD,,
|
|
File without changes
|