color-ascii-magic-genai 0.0.1__tar.gz → 0.0.2__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: color_ascii_magic_genai
3
- Version: 0.0.1
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
  ```
@@ -14,4 +14,7 @@ pip install color_ascii_magic_genai
14
14
  from color_ascii_magic_genai import colorize_text
15
15
 
16
16
  print(colorize_text("Hello World", color="red"))
17
+ print(colorize_text("Random Color", color="random"))
18
+ print(colorize_text("Rainbow Text", color="rainbow"))
19
+
17
20
  ```
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "color_ascii_magic_genai"
7
- version = "0.0.1"
7
+ version = "0.0.2"
8
8
  authors = [
9
9
  { name="Prasoon Kumar", email="prasoonkumar@example.com" },
10
10
  ]
@@ -23,3 +23,10 @@ dependencies = [
23
23
 
24
24
  [project.urls]
25
25
  "Homepage" = "https://github.com/example/color_ascii_magic_genai"
26
+
27
+ [tool.hatch.build]
28
+ exclude = [
29
+ "venv",
30
+ "demo.py",
31
+ ]
32
+
@@ -0,0 +1,42 @@
1
+ from art import text2art
2
+ from termcolor import colored
3
+ import random
4
+
5
+ def colorize_text(text: str, color: str = 'white', font: str = 'block') -> str:
6
+ """
7
+ Generates ASCII art from text and colorizes it.
8
+
9
+ Args:
10
+ text (str): The text to convert to ASCII art.
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).
13
+ font (str): The font style for ASCII art.
14
+
15
+ Returns:
16
+ str: Colored ASCII art string.
17
+ """
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
+
37
+ return colored(ascii_art, color)
38
+
39
+ def available_colors():
40
+ """Returns a list of available colors."""
41
+ return ['red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white']
42
+
@@ -1,21 +0,0 @@
1
- from art import text2art
2
- from termcolor import colored
3
-
4
- def colorize_text(text: str, color: str = 'white', font: str = 'block') -> str:
5
- """
6
- Generates ASCII art from text and colorizes it.
7
-
8
- Args:
9
- text (str): The text to convert to ASCII art.
10
- color (str): The color to apply. Supported colors: red, green, yellow, blue, magenta, cyan, white.
11
- font (str): The font style for ASCII art.
12
-
13
- Returns:
14
- str: Colored ASCII art string.
15
- """
16
- ascii_art = text2art(text, font=font)
17
- return colored(ascii_art, color)
18
-
19
- def available_colors():
20
- """Returns a list of available colors."""
21
- return ['red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white']