easygradients 0.1.0__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.
@@ -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
easygradients/core.py ADDED
@@ -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
+ }
easygradients/utils.py ADDED
@@ -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,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,8 @@
1
+ easygradients/__init__.py,sha256=mouSHsiIWcrGnk6Fx4zjFf_FPVrjgPLuKFzzJlJypl0,160
2
+ easygradients/core.py,sha256=w8ZnUaW9FH98kmsTzZfBaFZEOPh8-X6FYtePKI--hPQ,4521
3
+ easygradients/presets.py,sha256=ws5BJSAmi-fuMyxltNj_A_x1E9i1NSK4Dck_-v4wgv0,682
4
+ easygradients/utils.py,sha256=4QQQWjEcmW57ffAutVfqu4QZXL41dSPV-SBkOOfeWG8,1410
5
+ easygradients-0.1.0.dist-info/METADATA,sha256=1GT1qye2kZ2yrv4_OByiahFIngqYDLP_bBGmUA9t-0o,3364
6
+ easygradients-0.1.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
7
+ easygradients-0.1.0.dist-info/licenses/LICENSE,sha256=WAU1V5E6i8jFRifknrjA-GIU0pSFneeovkCFL93kI4w,1065
8
+ easygradients-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.28.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -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.