FovesColor 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.
FovesColor/__init__.py ADDED
@@ -0,0 +1 @@
1
+ from colors import color_whell, hsl_to_rgb, rgb_tuple_to_hex
FovesColor/colors.py ADDED
@@ -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,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,6 @@
1
+ FovesColor/__init__.py,sha256=AK1lnPef0ZIJlu-C2rzTT1Dm1jooh1MhTDtn3B2NFNk,60
2
+ FovesColor/colors.py,sha256=HroexMJrN8rTL2x7tbRoP5ApAmFS4iGS4ZUG-dstQGE,2071
3
+ fovescolor-0.1.0.dist-info/METADATA,sha256=0ItAmh8X1wnZibyQvr5Z0v8Gd-7Atx8V_uHlNRfsoP8,2712
4
+ fovescolor-0.1.0.dist-info/WHEEL,sha256=mffPy8wBnZQn2VnJUU5jE99KsxaSfiyMHV9Yt0aLVxs,87
5
+ fovescolor-0.1.0.dist-info/licenses/LICENSE,sha256=lXz0pZeICx_-HWjVeatkJhfuZp5Wd4jOPYzVs57mLfM,1087
6
+ fovescolor-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.30.1
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -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.