FovesColor 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,222 @@
1
+ .ilina
2
+ mygo.py
3
+ temp
4
+
5
+ # Byte-compiled / optimized / DLL files
6
+ __pycache__/
7
+ *.py[codz]
8
+ *$py.class
9
+
10
+ # C extensions
11
+ *.so
12
+
13
+ # Distribution / packaging
14
+ .Python
15
+ build/
16
+ develop-eggs/
17
+ dist/
18
+ downloads/
19
+ eggs/
20
+ .eggs/
21
+ lib/
22
+ lib64/
23
+ parts/
24
+ sdist/
25
+ var/
26
+ wheels/
27
+ share/python-wheels/
28
+ *.egg-info/
29
+ .installed.cfg
30
+ *.egg
31
+ MANIFEST
32
+
33
+ # PyInstaller
34
+ # Usually these files are written by a python script from a template
35
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
36
+ *.manifest
37
+ *.spec
38
+
39
+ # Installer logs
40
+ pip-log.txt
41
+ pip-delete-this-directory.txt
42
+
43
+ # Unit test / coverage reports
44
+ htmlcov/
45
+ .tox/
46
+ .nox/
47
+ .coverage
48
+ .coverage.*
49
+ .cache
50
+ nosetests.xml
51
+ coverage.xml
52
+ *.cover
53
+ *.py.cover
54
+ .hypothesis/
55
+ .pytest_cache/
56
+ cover/
57
+
58
+ # Translations
59
+ *.mo
60
+ *.pot
61
+
62
+ # Django stuff:
63
+ *.log
64
+ local_settings.py
65
+ db.sqlite3
66
+ db.sqlite3-journal
67
+
68
+ # Flask stuff:
69
+ instance/
70
+ .webassets-cache
71
+
72
+ # Scrapy stuff:
73
+ .scrapy
74
+
75
+ # Sphinx documentation
76
+ docs/_build/
77
+
78
+ # PyBuilder
79
+ .pybuilder/
80
+ target/
81
+
82
+ # Jupyter Notebook
83
+ .ipynb_checkpoints
84
+
85
+ # IPython
86
+ profile_default/
87
+ ipython_config.py
88
+
89
+ # pyenv
90
+ # For a library or package, you might want to ignore these files since the code is
91
+ # intended to run in multiple environments; otherwise, check them in:
92
+ # .python-version
93
+
94
+ # pipenv
95
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
96
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
97
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
98
+ # install all needed dependencies.
99
+ # Pipfile.lock
100
+
101
+ # UV
102
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
103
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
104
+ # commonly ignored for libraries.
105
+ # uv.lock
106
+
107
+ # poetry
108
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
109
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
110
+ # commonly ignored for libraries.
111
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
112
+ # poetry.lock
113
+ # poetry.toml
114
+
115
+ # pdm
116
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
117
+ # pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
118
+ # https://pdm-project.org/en/latest/usage/project/#working-with-version-control
119
+ # pdm.lock
120
+ # pdm.toml
121
+ .pdm-python
122
+ .pdm-build/
123
+
124
+ # pixi
125
+ # Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
126
+ # pixi.lock
127
+ # Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
128
+ # in the .venv directory. It is recommended not to include this directory in version control.
129
+ .pixi
130
+
131
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
132
+ __pypackages__/
133
+
134
+ # Celery stuff
135
+ celerybeat-schedule
136
+ celerybeat.pid
137
+
138
+ # Redis
139
+ *.rdb
140
+ *.aof
141
+ *.pid
142
+
143
+ # RabbitMQ
144
+ mnesia/
145
+ rabbitmq/
146
+ rabbitmq-data/
147
+
148
+ # ActiveMQ
149
+ activemq-data/
150
+
151
+ # SageMath parsed files
152
+ *.sage.py
153
+
154
+ # Environments
155
+ .env
156
+ .envrc
157
+ .venv
158
+ env/
159
+ venv/
160
+ ENV/
161
+ env.bak/
162
+ venv.bak/
163
+
164
+ # Spyder project settings
165
+ .spyderproject
166
+ .spyproject
167
+
168
+ # Rope project settings
169
+ .ropeproject
170
+
171
+ # mkdocs documentation
172
+ /site
173
+
174
+ # mypy
175
+ .mypy_cache/
176
+ .dmypy.json
177
+ dmypy.json
178
+
179
+ # Pyre type checker
180
+ .pyre/
181
+
182
+ # pytype static type analyzer
183
+ .pytype/
184
+
185
+ # Cython debug symbols
186
+ cython_debug/
187
+
188
+ # PyCharm
189
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
190
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
191
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
192
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
193
+ # .idea/
194
+
195
+ # Abstra
196
+ # Abstra is an AI-powered process automation framework.
197
+ # Ignore directories containing user credentials, local state, and settings.
198
+ # Learn more at https://abstra.io/docs
199
+ .abstra/
200
+
201
+ # Visual Studio Code
202
+ # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
203
+ # that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
204
+ # and can be added to the global gitignore or merged into this file. However, if you prefer,
205
+ # you could uncomment the following to ignore the entire vscode folder
206
+ # .vscode/
207
+ # Temporary file for partial code execution
208
+ tempCodeRunnerFile.py
209
+
210
+ # Ruff stuff:
211
+ .ruff_cache/
212
+
213
+ # PyPI configuration file
214
+ .pypirc
215
+
216
+ # Marimo
217
+ marimo/_static/
218
+ marimo/_lsp/
219
+ __marimo__/
220
+
221
+ # Streamlit
222
+ .streamlit/secrets.toml
@@ -0,0 +1 @@
1
+ from colors import color_whell, hsl_to_rgb, rgb_tuple_to_hex
@@ -0,0 +1,64 @@
1
+ def hsl_to_rgb(h: int, s: int, l: int) -> tuple[int, int, int]:
2
+ """
3
+ 将HSL颜色转换为RGB颜色
4
+
5
+ 参数:
6
+ h: 色相 (0-360)
7
+ s: 饱和度 (0-100)
8
+ l: 亮度 (0-100)
9
+
10
+ 返回:
11
+ tuple[int, int, int]: RGB颜色值,每个分量范围0-255
12
+ """
13
+ # 将HSL值转换为0-1范围
14
+ h_norm = h / 360.0
15
+ s_norm = s / 100.0
16
+ l_norm = l / 100.0
17
+
18
+ # 如果饱和度为0,则是灰色
19
+ if s_norm == 0:
20
+ r = g = b = l_norm
21
+ else:
22
+ # 计算临时变量
23
+ def hue_to_rgb(p: float, q: float, t: float) -> float:
24
+ if t < 0:
25
+ t += 1
26
+ if t > 1:
27
+ t -= 1
28
+ if t < 1/6:
29
+ return p + (q - p) * 6 * t
30
+ if t < 1/2:
31
+ return q
32
+ if t < 2/3:
33
+ return p + (q - p) * (2/3 - t) * 6
34
+ return p
35
+
36
+ q = l_norm * (1 + s_norm) if l_norm < 0.5 else l_norm + s_norm - l_norm * s_norm
37
+ p = 2 * l_norm - q
38
+
39
+ r = hue_to_rgb(p, q, h_norm + 1/3)
40
+ g = hue_to_rgb(p, q, h_norm)
41
+ b = hue_to_rgb(p, q, h_norm - 1/3)
42
+
43
+ # 将RGB值转换为0-255范围并四舍五入
44
+ return (int(round(r * 255)), int(round(g * 255)), int(round(b * 255)))
45
+
46
+ def rgb_tuple_to_hex(rgb: tuple[int, int, int]|list[tuple[int, int, int]]) -> str|list[str]:
47
+ """
48
+ 将RGB元组转换为十六进制颜色字符串,支持批量调用
49
+
50
+ 参数:
51
+ rgb: RGB元组,每个分量范围0-255
52
+
53
+ 返回:
54
+ str: 十六进制颜色字符串,例如'#RRGGBB'
55
+ """
56
+ if isinstance(rgb, list):
57
+ return [f'#{i[0]:02x}{i[1]:02x}{i[2]:02x}' for i in rgb]
58
+ else:
59
+ return f'#{rgb[0]:02x}{rgb[1]:02x}{rgb[2]:02x}'
60
+
61
+
62
+ def color_whell(split: int, s: int, l: int) -> list[tuple[int, int, int]]:
63
+ """ 将色轮分为 split 等分,然后按给定的饱和度和亮度生成颜色 """
64
+ return [hsl_to_rgb(int(i * 360 / split), s, l) for i in range(split)]
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Foves7017
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,79 @@
1
+ Metadata-Version: 2.4
2
+ Name: FovesColor
3
+ Version: 0.1.0
4
+ Summary: 四叶的颜色管理工具
5
+ Project-URL: Repository, https://github.com/Foves7017/FovesLib
6
+ Author: Foves7017
7
+ License: MIT License
8
+
9
+ Copyright (c) 2026 Foves7017
10
+
11
+ Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ of this software and associated documentation files (the "Software"), to deal
13
+ in the Software without restriction, including without limitation the rights
14
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
+ copies of the Software, and to permit persons to whom the Software is
16
+ furnished to do so, subject to the following conditions:
17
+
18
+ The above copyright notice and this permission notice shall be included in all
19
+ copies or substantial portions of the Software.
20
+
21
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27
+ SOFTWARE.
28
+ License-File: LICENSE
29
+ Requires-Python: >=3.12
30
+ Description-Content-Type: text/markdown
31
+
32
+ # FovesColor
33
+ 包括一系列和颜色相关的工具。
34
+
35
+ 可使用 pip 安装或下载源码使用:
36
+ ```BASH
37
+ pip install FovesColor
38
+ ```
39
+
40
+ 项目主页:
41
+ https://github.com/Foves7017/FovesLib
42
+
43
+
44
+ ## `hsl_to_rgb(h, s, l)`
45
+
46
+ 将 HSL 颜色转换为 RGB。
47
+
48
+ | 参数 | 类型 | 范围 | 说明 |
49
+ |------|------|------|------|
50
+ | `h` | `int` | 0–360 | 色相 |
51
+ | `s` | `int` | 0–100 | 饱和度 |
52
+ | `l` | `int` | 0–100 | 亮度 |
53
+
54
+ 返回 `tuple[int, int, int]`,每个分量范围 0–255。
55
+
56
+
57
+ ## `rgb_tuple_to_hex(rgb)`
58
+
59
+ 将 RGB 元组转换为 `#RRGGBB` 十六进制字符串。**支持单个和批量**——传入列表自动返回列表。
60
+
61
+ | 参数 | 类型 | 说明 |
62
+ |------|------|------|
63
+ | `rgb` | `tuple[int,int,int]` | 单个 RGB 颜色 |
64
+ | `rgb` | `list[tuple[int,int,int]]` | 批量 RGB 颜色 |
65
+
66
+ 返回 `str`(单个)或 `list[str]`(批量)。
67
+
68
+
69
+ ## `color_whell(split, s, l)`
70
+
71
+ 将色轮均分为 `split` 等份,按指定饱和度和亮度生成 RGB 颜色列表。
72
+
73
+ | 参数 | 类型 | 范围 | 说明 |
74
+ |------|------|------|------|
75
+ | `split` | `int` | ≥1 | 色轮分割份数 |
76
+ | `s` | `int` | 0–100 | 饱和度 |
77
+ | `l` | `int` | 0–100 | 亮度 |
78
+
79
+ 返回 `list[tuple[int, int, int]]`。
@@ -0,0 +1,48 @@
1
+ # FovesColor
2
+ 包括一系列和颜色相关的工具。
3
+
4
+ 可使用 pip 安装或下载源码使用:
5
+ ```BASH
6
+ pip install FovesColor
7
+ ```
8
+
9
+ 项目主页:
10
+ https://github.com/Foves7017/FovesLib
11
+
12
+
13
+ ## `hsl_to_rgb(h, s, l)`
14
+
15
+ 将 HSL 颜色转换为 RGB。
16
+
17
+ | 参数 | 类型 | 范围 | 说明 |
18
+ |------|------|------|------|
19
+ | `h` | `int` | 0–360 | 色相 |
20
+ | `s` | `int` | 0–100 | 饱和度 |
21
+ | `l` | `int` | 0–100 | 亮度 |
22
+
23
+ 返回 `tuple[int, int, int]`,每个分量范围 0–255。
24
+
25
+
26
+ ## `rgb_tuple_to_hex(rgb)`
27
+
28
+ 将 RGB 元组转换为 `#RRGGBB` 十六进制字符串。**支持单个和批量**——传入列表自动返回列表。
29
+
30
+ | 参数 | 类型 | 说明 |
31
+ |------|------|------|
32
+ | `rgb` | `tuple[int,int,int]` | 单个 RGB 颜色 |
33
+ | `rgb` | `list[tuple[int,int,int]]` | 批量 RGB 颜色 |
34
+
35
+ 返回 `str`(单个)或 `list[str]`(批量)。
36
+
37
+
38
+ ## `color_whell(split, s, l)`
39
+
40
+ 将色轮均分为 `split` 等份,按指定饱和度和亮度生成 RGB 颜色列表。
41
+
42
+ | 参数 | 类型 | 范围 | 说明 |
43
+ |------|------|------|------|
44
+ | `split` | `int` | ≥1 | 色轮分割份数 |
45
+ | `s` | `int` | 0–100 | 饱和度 |
46
+ | `l` | `int` | 0–100 | 亮度 |
47
+
48
+ 返回 `list[tuple[int, int, int]]`。
@@ -0,0 +1,20 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "FovesColor"
7
+ version = "0.1.0"
8
+ description = "四叶的颜色管理工具"
9
+ readme = "README.md"
10
+ license = {file = "LICENSE"}
11
+ authors = [
12
+ {name = "Foves7017"}
13
+ ]
14
+ requires-python = ">=3.12"
15
+
16
+ [project.urls]
17
+ Repository = "https://github.com/Foves7017/FovesLib"
18
+
19
+ [tool.hatch.build.targets.wheel]
20
+ packages = ["FovesColor"]