easygradients 0.1.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.
@@ -0,0 +1,34 @@
1
+ name: Put my code on PyPI
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - 'v*'
7
+
8
+ jobs:
9
+ build-and-put:
10
+ name: Build the package and send to PyPI
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - uses: actions/checkout@v4
14
+ - name: Get Python ready
15
+ uses: actions/setup-python@v5
16
+ with:
17
+ python-version: "3.x"
18
+ - name: Install the builder tool
19
+ run: >-
20
+ python -m
21
+ pip install
22
+ build
23
+ --user
24
+ - name: Make the files for distribution
25
+ run: >-
26
+ python -m
27
+ build
28
+ --sdist
29
+ --wheel
30
+ --outdir dist/
31
+ - name: Send everything to PyPI
32
+ uses: pypa/gh-action-pypi-publish@release/v1
33
+ with:
34
+ password: ${{ secrets.PYPI_TOKEN }}
@@ -0,0 +1,21 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ *$py.class
4
+ *.so
5
+ .Python
6
+ build/
7
+ develop-eggs/
8
+ dist/
9
+ downloads/
10
+ eggs/
11
+ .eggs/
12
+ lib/
13
+ lib64/
14
+ parts/
15
+ sdist/
16
+ var/
17
+ wheels/
18
+ *.egg-info/
19
+ .installed.cfg
20
+ *.egg
21
+ .pytest_cache/
@@ -0,0 +1 @@
1
+ 3.13
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 DraxonV1
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.
@@ -0,0 +1,120 @@
1
+ Metadata-Version: 2.4
2
+ Name: easygradients
3
+ Version: 0.1.0
4
+ Summary: A very good library to make your terminal very colorful and nice. easy to use also.
5
+ Project-URL: My GitHub, https://github.com/DraxonV1/EasyGradients
6
+ Author-email: DraxonV1 <drxxn@draxonshop.xyz>
7
+ License: MIT
8
+ License-File: LICENSE
9
+ Keywords: color,easy,gradient,nice-text,terminal
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Operating System :: OS Independent
12
+ Classifier: Programming Language :: Python :: 3
13
+ Requires-Python: >=3.12
14
+ Description-Content-Type: text/markdown
15
+
16
+ # EasyGradients 🌈
17
+
18
+ Hello friend! I made this library because I love colors in my terminal. It is very easy to use and even a small child can use it. No complex coding here, just simple things that work like magic!
19
+
20
+ ## How to Install this?
21
+
22
+ Just type this simple command in your black screen (terminal):
23
+
24
+ ```bash
25
+ pip install easygradients
26
+ ```
27
+
28
+ ## How to use it? (Examples for you)
29
+
30
+ First you must bring the library in your code:
31
+
32
+ ```python
33
+ import easygradients as eg
34
+ ```
35
+
36
+ ### 1. Simple Colors
37
+ If you want to make text red or green, just do this:
38
+
39
+ ```python
40
+ # Use hex code like this
41
+ print(eg.color("I am red color!", "#FF0000"))
42
+
43
+ # Or use simple numbers (RGB)
44
+ print(eg.color("I am green color!", (0, 255, 0)))
45
+ ```
46
+
47
+ ### 2. Beautiful Gradients
48
+ Gradient means many colors mixing together. It looks very nice!
49
+
50
+ ```python
51
+ # Mix red and blue
52
+ print(eg.gradient("Mixing colors wow!", ["#FF0000", "#0000FF"]))
53
+
54
+ # You can even use many colors
55
+ print(eg.gradient("So many colors!", ["#FF0000", "#FFFF00", "#00FF00", "#0000FF"]))
56
+ ```
57
+
58
+ ### 3. Using Presets (Shortcuts)
59
+ I have already made some nice color sets for you. You don't need to find hex codes!
60
+
61
+ ```python
62
+ print(eg.gradient("Sunset is looking good", "sunset"))
63
+ print(eg.gradient("Ocean is blue", "ocean"))
64
+ print(eg.gradient("I am hacker in matrix", "matrix"))
65
+ ```
66
+
67
+ ### 4. Background Colors
68
+ You can even change the back side of the text:
69
+
70
+ ```python
71
+ print(eg.bg_color("Black background here", "#000000"))
72
+ print(eg.bg_gradient("Gradient background is crazy!", ["#FF5F6D", "#FFC371"]))
73
+ ```
74
+
75
+ ### 5. Styling Text
76
+ Make it bold or italic or draw line under it:
77
+
78
+ ```python
79
+ print(eg.style("I am very BOLD", "bold"))
80
+ print(eg.style("I am leaning (italic)", "italic"))
81
+ print(eg.style("Line under me", "underline"))
82
+ ```
83
+
84
+ ### 6. Special Tricks
85
+ Some more things I added because I was bored:
86
+
87
+ ```python
88
+ # Rainbow!
89
+ print(eg.rainbow("FULL RAINBOW TEXT!!!"))
90
+
91
+ # Type like a movie hacker
92
+ eg.typewriter("System is hacking now... please wait...")
93
+
94
+ # Put text in the middle
95
+ print(eg.center("I am sitting in the middle"))
96
+
97
+ # Put text inside a box
98
+ print(eg.box("Special Message for you", border_col="gold"))
99
+ ```
100
+
101
+ ### 7. Random (If you are lazy)
102
+ If you can't choose color, let the computer choose:
103
+
104
+ ```python
105
+ # Computer will pick anything!
106
+ my_luck = eg.random(show_info=True)
107
+ print(eg.gradient("I don't know what color this is!", my_luck))
108
+
109
+ # Ask for random preset only
110
+ preset_luck = eg.random(what_you_want='preset', show_info=True)
111
+ print(eg.gradient("Random preset used!", preset_luck))
112
+ ```
113
+
114
+ ## All my Presets:
115
+ `rainbow`, `sunset`, `ocean`, `morning`, `matrix`, `fire`, `night`, `candy`, `neon`, `cool`, `hot`, `simple`, `grass`, `sky`, `blood`, `gold`.
116
+
117
+ ## License
118
+ It is MIT license. You can use it anywhere you want, I don't care! Just enjoy the colors.
119
+
120
+ Made with love by DraxonV1.
@@ -0,0 +1,105 @@
1
+ # EasyGradients 🌈
2
+
3
+ Hello friend! I made this library because I love colors in my terminal. It is very easy to use and even a small child can use it. No complex coding here, just simple things that work like magic!
4
+
5
+ ## How to Install this?
6
+
7
+ Just type this simple command in your black screen (terminal):
8
+
9
+ ```bash
10
+ pip install easygradients
11
+ ```
12
+
13
+ ## How to use it? (Examples for you)
14
+
15
+ First you must bring the library in your code:
16
+
17
+ ```python
18
+ import easygradients as eg
19
+ ```
20
+
21
+ ### 1. Simple Colors
22
+ If you want to make text red or green, just do this:
23
+
24
+ ```python
25
+ # Use hex code like this
26
+ print(eg.color("I am red color!", "#FF0000"))
27
+
28
+ # Or use simple numbers (RGB)
29
+ print(eg.color("I am green color!", (0, 255, 0)))
30
+ ```
31
+
32
+ ### 2. Beautiful Gradients
33
+ Gradient means many colors mixing together. It looks very nice!
34
+
35
+ ```python
36
+ # Mix red and blue
37
+ print(eg.gradient("Mixing colors wow!", ["#FF0000", "#0000FF"]))
38
+
39
+ # You can even use many colors
40
+ print(eg.gradient("So many colors!", ["#FF0000", "#FFFF00", "#00FF00", "#0000FF"]))
41
+ ```
42
+
43
+ ### 3. Using Presets (Shortcuts)
44
+ I have already made some nice color sets for you. You don't need to find hex codes!
45
+
46
+ ```python
47
+ print(eg.gradient("Sunset is looking good", "sunset"))
48
+ print(eg.gradient("Ocean is blue", "ocean"))
49
+ print(eg.gradient("I am hacker in matrix", "matrix"))
50
+ ```
51
+
52
+ ### 4. Background Colors
53
+ You can even change the back side of the text:
54
+
55
+ ```python
56
+ print(eg.bg_color("Black background here", "#000000"))
57
+ print(eg.bg_gradient("Gradient background is crazy!", ["#FF5F6D", "#FFC371"]))
58
+ ```
59
+
60
+ ### 5. Styling Text
61
+ Make it bold or italic or draw line under it:
62
+
63
+ ```python
64
+ print(eg.style("I am very BOLD", "bold"))
65
+ print(eg.style("I am leaning (italic)", "italic"))
66
+ print(eg.style("Line under me", "underline"))
67
+ ```
68
+
69
+ ### 6. Special Tricks
70
+ Some more things I added because I was bored:
71
+
72
+ ```python
73
+ # Rainbow!
74
+ print(eg.rainbow("FULL RAINBOW TEXT!!!"))
75
+
76
+ # Type like a movie hacker
77
+ eg.typewriter("System is hacking now... please wait...")
78
+
79
+ # Put text in the middle
80
+ print(eg.center("I am sitting in the middle"))
81
+
82
+ # Put text inside a box
83
+ print(eg.box("Special Message for you", border_col="gold"))
84
+ ```
85
+
86
+ ### 7. Random (If you are lazy)
87
+ If you can't choose color, let the computer choose:
88
+
89
+ ```python
90
+ # Computer will pick anything!
91
+ my_luck = eg.random(show_info=True)
92
+ print(eg.gradient("I don't know what color this is!", my_luck))
93
+
94
+ # Ask for random preset only
95
+ preset_luck = eg.random(what_you_want='preset', show_info=True)
96
+ print(eg.gradient("Random preset used!", preset_luck))
97
+ ```
98
+
99
+ ## All my Presets:
100
+ `rainbow`, `sunset`, `ocean`, `morning`, `matrix`, `fire`, `night`, `candy`, `neon`, `cool`, `hot`, `simple`, `grass`, `sky`, `blood`, `gold`.
101
+
102
+ ## License
103
+ It is MIT license. You can use it anywhere you want, I don't care! Just enjoy the colors.
104
+
105
+ Made with love by DraxonV1.
@@ -0,0 +1,4 @@
1
+ __version__ = "0.1.0"
2
+
3
+ from .core import color, gradient, random, style, bg_color, bg_gradient, rainbow, typewriter, center, box
4
+ from .presets import gradients
@@ -0,0 +1,138 @@
1
+ from . import utils as help_tools
2
+ from . import presets as my_styles
3
+ import shutil
4
+
5
+ STYLE_CODES = {
6
+ 'bold': '1',
7
+ 'dim': '2',
8
+ 'italic': '3',
9
+ 'underline': '4',
10
+ 'blink': '5',
11
+ 'reverse': '7',
12
+ 'hidden': '8',
13
+ 'strikethrough': '9'
14
+ }
15
+
16
+ def _put_rgb(r, g, b, back_ground=False):
17
+ layer_num = 48 if back_ground else 38
18
+ return f"\033[{layer_num};2;{r};{g};{b}m"
19
+
20
+ def _clear_all():
21
+ return "\033[0m"
22
+
23
+ def style(input_text, style_names):
24
+ if isinstance(style_names, str):
25
+ style_names = [style_names]
26
+
27
+ start_codes = ""
28
+ for s in style_names:
29
+ if s.lower() in STYLE_CODES:
30
+ start_codes += f"\033[{STYLE_CODES[s.lower()]}m"
31
+
32
+ return f"{start_codes}{input_text}{_clear_all()}"
33
+
34
+ def color(input_text, col_code, back_ground=False):
35
+ if isinstance(col_code, str):
36
+ if col_code.startswith('#'):
37
+ col_code = help_tools.hex_to_rgb(col_code)
38
+ elif col_code in my_styles.gradients:
39
+ col_code = help_tools.hex_to_rgb(my_styles.gradients[col_code][0])
40
+
41
+ r_val, g_val, b_val = col_code
42
+ return f"{_put_rgb(r_val, g_val, b_val, back_ground)}{input_text}{_clear_all()}"
43
+
44
+ def gradient(input_text, list_of_cols, back_ground=False):
45
+ if not input_text:
46
+ return ""
47
+
48
+ if isinstance(list_of_cols, str):
49
+ if list_of_cols in my_styles.gradients:
50
+ list_of_cols = my_styles.gradients[list_of_cols]
51
+ else:
52
+ list_of_cols = [list_of_cols]
53
+
54
+ real_rgb_list = []
55
+ for ek_col in list_of_cols:
56
+ if isinstance(ek_col, str) and ek_col.startswith('#'):
57
+ real_rgb_list.append(help_tools.hex_to_rgb(ek_col))
58
+ elif isinstance(ek_col, tuple):
59
+ real_rgb_list.append(ek_col)
60
+ else:
61
+ real_rgb_list.append((255, 255, 255))
62
+
63
+ every_step = help_tools.make_steps(real_rgb_list, len(input_text))
64
+
65
+ final_output = ""
66
+ for letter, rgb_val in zip(input_text, every_step):
67
+ rv, gv, bv = rgb_val
68
+ final_output += f"{_put_rgb(rv, gv, bv, back_ground)}{letter}"
69
+
70
+ final_output += _clear_all()
71
+ return final_output
72
+
73
+ def bg_color(input_text, col_code):
74
+ return color(input_text, col_code, back_ground=True)
75
+
76
+ def bg_gradient(input_text, list_of_cols):
77
+ return gradient(input_text, list_of_cols, back_ground=True)
78
+
79
+ def rainbow(input_text, back_ground=False):
80
+ return gradient(input_text, my_styles.gradients['rainbow'], back_ground=back_ground)
81
+
82
+ def random(what_you_want=None, show_info=False):
83
+ import random as radom_tool
84
+
85
+ output_val = None
86
+ messge = ""
87
+
88
+ if what_you_want == 'color':
89
+ output_val = help_tools.rand_col()
90
+ messge = f"Color: {output_val}"
91
+ elif what_you_want == 'gradient':
92
+ output_val = [help_tools.rand_col(), help_tools.rand_col()]
93
+ messge = f"Gradient: {output_val}"
94
+ elif what_you_want == 'preset':
95
+ output_val = radom_tool.choice(list(my_styles.gradients.keys()))
96
+ messge = f"Preset: {output_val}"
97
+ else:
98
+ luck = radom_tool.choice(['color', 'gradient', 'preset'])
99
+ if luck == 'color':
100
+ output_val = help_tools.rand_col()
101
+ messge = f"Color: {output_val}"
102
+ elif luck == 'gradient':
103
+ output_val = [help_tools.rand_col(), help_tools.rand_col()]
104
+ messge = f"Gradient: {output_val}"
105
+ else:
106
+ output_val = radom_tool.choice(list(my_styles.gradients.keys()))
107
+ messge = f"Preset: {output_val}"
108
+
109
+ if show_info:
110
+ print(f"I found this radom {messge} for you!")
111
+
112
+ return output_val
113
+
114
+ def typewriter(input_text, wait_time=0.05):
115
+ help_tools.slow_print(input_text, wait_time)
116
+
117
+ def center(input_text):
118
+ screen_width, _ = shutil.get_terminal_size()
119
+ return input_text.center(screen_width)
120
+
121
+ def box(input_text, border_col=None):
122
+ all_lines = input_text.split('\n')
123
+ max_len = max(len(ek_line) for ek_line in all_lines)
124
+
125
+ top_border = "+" + "-" * (max_len + 2) + "+"
126
+ bottom_border = "+" + "-" * (max_len + 2) + "+"
127
+
128
+ full_box = top_border + "\n"
129
+ for ek_line in all_lines:
130
+ full_box += "| " + ek_line.ljust(max_len) + " |\n"
131
+ full_box += bottom_border
132
+
133
+ if border_col:
134
+ if isinstance(border_col, list) or (isinstance(border_col, str) and border_col in my_styles.gradients):
135
+ return gradient(full_box, border_col)
136
+ else:
137
+ return color(full_box, border_col)
138
+ return full_box
@@ -0,0 +1,18 @@
1
+ gradients = {
2
+ 'rainbow': ['#FF0000', '#FF7F00', '#FFFF00', '#00FF00', '#0000FF', '#4B0082', '#9400D3'],
3
+ 'sunset': ['#FDC830', '#F37335'],
4
+ 'ocean': ['#2E3192', '#1BFFFF'],
5
+ 'morning': ['#FF5F6D', '#FFC371'],
6
+ 'matrix': ['#000000', '#00FF00', '#000000'],
7
+ 'fire': ['#f12711', '#f5af19'],
8
+ 'night': ['#2b5876', '#4e4376'],
9
+ 'candy': ['#D4145A', '#FBB03B'],
10
+ 'neon': ['#00F260', '#0575E6'],
11
+ 'cool': ['#2193b0', '#6dd5ed'],
12
+ 'hot': ['#ff416c', '#ff4b2b'],
13
+ 'simple': ['#000000', '#ffffff'],
14
+ 'grass': ['#11998e', '#38ef7d'],
15
+ 'sky': ['#00b4db', '#0083b0'],
16
+ 'blood': ['#870000', '#190a05'],
17
+ 'gold': ['#bf953f', '#fcf6ba', '#b38728']
18
+ }
@@ -0,0 +1,49 @@
1
+ import random
2
+ import time
3
+ import sys
4
+
5
+ def hex_to_rgb(hex_code):
6
+ hex_code = hex_code.lstrip('#')
7
+ return tuple(int(hex_code[i:i+2], 16) for i in (0, 2, 4))
8
+
9
+ def rand_col():
10
+ return (random.randint(0, 255), random.randint(0, 255), random.randint(0, 255))
11
+
12
+ def mixer(col1, col2, factor):
13
+ r = int(col1[0] + (col2[0] - col1[0]) * factor)
14
+ g = int(col1[1] + (col2[1] - col1[1]) * factor)
15
+ b = int(col1[2] + (col2[2] - col1[2]) * factor)
16
+ return (r, g, b)
17
+
18
+ def make_steps(all_cols, total_steps):
19
+ if total_steps < 2:
20
+ return [all_cols[0]] * total_steps
21
+ if len(all_cols) < 2:
22
+ return [all_cols[0]] * total_steps
23
+
24
+ final_list = []
25
+ sections = len(all_cols) - 1
26
+ steps_per_sec = total_steps // sections
27
+ extra_steps = total_steps % sections
28
+
29
+ for i in range(sections):
30
+ start_c = all_cols[i]
31
+ end_c = all_cols[i+1]
32
+
33
+ current_steps = steps_per_sec + (1 if i < extra_steps else 0)
34
+
35
+ for j in range(current_steps):
36
+ f = j / current_steps
37
+ final_list.append(mixer(start_c, end_c, f))
38
+
39
+ if len(final_list) < total_steps:
40
+ final_list.append(all_cols[-1])
41
+
42
+ return final_list[:total_steps]
43
+
44
+ def slow_print(my_text, my_speed=0.05):
45
+ for ek_char in my_text:
46
+ sys.stdout.write(ek_char)
47
+ sys.stdout.flush()
48
+ time.sleep(my_speed)
49
+ print()
@@ -0,0 +1,24 @@
1
+ [project]
2
+ name = "easygradients"
3
+ version = "0.1.0"
4
+ description = "A very good library to make your terminal very colorful and nice. easy to use also."
5
+ readme = "README.md"
6
+ requires-python = ">=3.12"
7
+ dependencies = []
8
+ authors = [
9
+ { name = "DraxonV1", email = "drxxn@draxonshop.xyz" }
10
+ ]
11
+ license = { text = "MIT" }
12
+ keywords = ["color", "gradient", "terminal", "nice-text", "easy"]
13
+ classifiers = [
14
+ "Programming Language :: Python :: 3",
15
+ "License :: OSI Approved :: MIT License",
16
+ "Operating System :: OS Independent",
17
+ ]
18
+
19
+ [project.urls]
20
+ "My GitHub" = "https://github.com/DraxonV1/EasyGradients"
21
+
22
+ [build-system]
23
+ requires = ["hatchling"]
24
+ build-backend = "hatchling.build"
@@ -0,0 +1,36 @@
1
+ import unittest
2
+ import easygradients as eg
3
+ from io import StringIO
4
+ import sys
5
+
6
+ class TestMyCode(unittest.TestCase):
7
+
8
+ def test_styling(self):
9
+ styled_txt = eg.style("hello", "bold")
10
+ self.assertIn("\033[1m", styled_txt)
11
+
12
+ def test_coloring(self):
13
+ colored_txt = eg.color("hello", "#FF0000")
14
+ self.assertIn("255;0;0", colored_txt)
15
+
16
+ def test_gradient_mixing(self):
17
+ grad_txt = eg.gradient("hello", ["#FF0000", "#0000FF"])
18
+ self.assertIn("\033[38;2;", grad_txt)
19
+
20
+ def test_radom_info(self):
21
+ temp_screen = StringIO()
22
+ sys.stdout = temp_screen
23
+ eg.random(show_info=True)
24
+ sys.stdout = sys.__stdout__
25
+ self.assertIn("I found this radom", temp_screen.getvalue())
26
+
27
+ def test_presets_work(self):
28
+ sun_txt = eg.gradient("hello", "sunset")
29
+ self.assertIn("\033[38;2;", sun_txt)
30
+
31
+ def test_making_box(self):
32
+ box_txt = eg.box("hi")
33
+ self.assertIn("+----+", box_txt)
34
+
35
+ if __name__ == '__main__':
36
+ unittest.main()