e2D 2.0.0__cp313-cp313-win_amd64.whl → 2.0.1__cp313-cp313-win_amd64.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.
- e2D/__init__.py +199 -72
- e2D/__init__.pyi +145 -0
- e2D/ccolors.c +34514 -0
- e2D/ccolors.cp313-win_amd64.pyd +0 -0
- e2D/ccolors.pyi +51 -0
- e2D/ccolors.pyx +350 -0
- e2D/color_defs.py +238 -0
- e2D/colors.py +380 -0
- e2D/colors.pyi +104 -0
- e2D/commons.py +38 -10
- e2D/commons.pyi +79 -0
- e2D/cvectors.c +152 -152
- e2D/cvectors.cp313-win_amd64.pyd +0 -0
- e2D/cvectors.pyi +243 -0
- e2D/devices.py +19 -6
- e2D/devices.pyi +65 -0
- e2D/plots.py +55 -29
- e2D/plots.pyi +238 -0
- e2D/shapes.py +81 -44
- e2D/shapes.pyi +272 -0
- e2D/test_colors.py +122 -0
- e2D/text_renderer.py +46 -16
- e2D/text_renderer.pyi +118 -0
- e2D/types.py +58 -0
- e2D/types.pyi +61 -0
- e2D/vectors.py +153 -61
- e2D/vectors.pyi +106 -0
- e2D/winrec.py +275 -0
- e2D/winrec.pyi +87 -0
- {e2d-2.0.0.dist-info → e2d-2.0.1.dist-info}/METADATA +43 -15
- e2d-2.0.1.dist-info/RECORD +46 -0
- {e2d-2.0.0.dist-info → e2d-2.0.1.dist-info}/WHEEL +1 -1
- e2d-2.0.0.dist-info/RECORD +0 -26
- {e2d-2.0.0.dist-info → e2d-2.0.1.dist-info}/licenses/LICENSE +0 -0
- {e2d-2.0.0.dist-info → e2d-2.0.1.dist-info}/top_level.txt +0 -0
|
Binary file
|
e2D/ccolors.pyi
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"""Type stubs for Cython color operations"""
|
|
2
|
+
|
|
3
|
+
import numpy as np
|
|
4
|
+
from numpy.typing import NDArray
|
|
5
|
+
|
|
6
|
+
def batch_lerp_colors(
|
|
7
|
+
colors1: NDArray[np.float32],
|
|
8
|
+
colors2: NDArray[np.float32],
|
|
9
|
+
t: float
|
|
10
|
+
) -> NDArray[np.float32]: ...
|
|
11
|
+
|
|
12
|
+
def batch_multiply_colors(
|
|
13
|
+
colors: NDArray[np.float32],
|
|
14
|
+
factor: float
|
|
15
|
+
) -> NDArray[np.float32]: ...
|
|
16
|
+
|
|
17
|
+
def batch_add_colors(
|
|
18
|
+
colors1: NDArray[np.float32],
|
|
19
|
+
colors2: NDArray[np.float32]
|
|
20
|
+
) -> NDArray[np.float32]: ...
|
|
21
|
+
|
|
22
|
+
def batch_grayscale(
|
|
23
|
+
colors: NDArray[np.float32]
|
|
24
|
+
) -> NDArray[np.float32]: ...
|
|
25
|
+
|
|
26
|
+
def batch_invert(
|
|
27
|
+
colors: NDArray[np.float32]
|
|
28
|
+
) -> NDArray[np.float32]: ...
|
|
29
|
+
|
|
30
|
+
def batch_rgb_to_hsv(
|
|
31
|
+
colors: NDArray[np.float32]
|
|
32
|
+
) -> NDArray[np.float32]: ...
|
|
33
|
+
|
|
34
|
+
def batch_hsv_to_rgb(
|
|
35
|
+
colors: NDArray[np.float32]
|
|
36
|
+
) -> NDArray[np.float32]: ...
|
|
37
|
+
|
|
38
|
+
def batch_rotate_hue(
|
|
39
|
+
colors: NDArray[np.float32],
|
|
40
|
+
degrees: float
|
|
41
|
+
) -> NDArray[np.float32]: ...
|
|
42
|
+
|
|
43
|
+
def batch_saturate(
|
|
44
|
+
colors: NDArray[np.float32],
|
|
45
|
+
amount: float
|
|
46
|
+
) -> NDArray[np.float32]: ...
|
|
47
|
+
|
|
48
|
+
def generate_gradient(
|
|
49
|
+
colors: NDArray[np.float32],
|
|
50
|
+
steps: int
|
|
51
|
+
) -> NDArray[np.float32]: ...
|
e2D/ccolors.pyx
ADDED
|
@@ -0,0 +1,350 @@
|
|
|
1
|
+
# cython: language_level=3
|
|
2
|
+
# cython: boundscheck=False
|
|
3
|
+
# cython: wraparound=False
|
|
4
|
+
# cython: cdivision=True
|
|
5
|
+
"""
|
|
6
|
+
Cython-optimized color operations for e2D
|
|
7
|
+
High-performance batch conversions and color space transformations
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
cimport cython
|
|
11
|
+
from libc.math cimport fmin, fmax, fmod, floor
|
|
12
|
+
import numpy as np
|
|
13
|
+
cimport numpy as cnp
|
|
14
|
+
|
|
15
|
+
cnp.import_array()
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@cython.boundscheck(False)
|
|
19
|
+
@cython.wraparound(False)
|
|
20
|
+
cdef inline float clamp(float val, float min_val, float max_val) nogil:
|
|
21
|
+
"""Clamp value between min and max"""
|
|
22
|
+
return fmin(fmax(val, min_val), max_val)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
@cython.boundscheck(False)
|
|
26
|
+
@cython.wraparound(False)
|
|
27
|
+
def batch_lerp_colors(
|
|
28
|
+
float[:, :] colors1,
|
|
29
|
+
float[:, :] colors2,
|
|
30
|
+
float t
|
|
31
|
+
) -> cnp.ndarray:
|
|
32
|
+
"""
|
|
33
|
+
Batch linear interpolation between two color arrays
|
|
34
|
+
colors1, colors2: shape (N, 4) RGBA float arrays
|
|
35
|
+
t: interpolation factor (0.0-1.0)
|
|
36
|
+
Returns: shape (N, 4) interpolated colors
|
|
37
|
+
"""
|
|
38
|
+
cdef int n = colors1.shape[0]
|
|
39
|
+
cdef int i, j
|
|
40
|
+
cdef float[:, :] result = np.empty((n, 4), dtype=np.float32)
|
|
41
|
+
|
|
42
|
+
with nogil:
|
|
43
|
+
for i in range(n):
|
|
44
|
+
for j in range(4):
|
|
45
|
+
result[i, j] = colors1[i, j] + (colors2[i, j] - colors1[i, j]) * t
|
|
46
|
+
|
|
47
|
+
return np.asarray(result)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
@cython.boundscheck(False)
|
|
51
|
+
@cython.wraparound(False)
|
|
52
|
+
def batch_multiply_colors(float[:, :] colors, float factor) -> cnp.ndarray:
|
|
53
|
+
"""
|
|
54
|
+
Multiply RGB channels by factor (preserves alpha)
|
|
55
|
+
colors: shape (N, 4) RGBA float array
|
|
56
|
+
factor: multiplication factor
|
|
57
|
+
Returns: shape (N, 4) multiplied colors
|
|
58
|
+
"""
|
|
59
|
+
cdef int n = colors.shape[0]
|
|
60
|
+
cdef int i
|
|
61
|
+
cdef float[:, :] result = np.empty((n, 4), dtype=np.float32)
|
|
62
|
+
|
|
63
|
+
with nogil:
|
|
64
|
+
for i in range(n):
|
|
65
|
+
result[i, 0] = clamp(colors[i, 0] * factor, 0.0, 1.0)
|
|
66
|
+
result[i, 1] = clamp(colors[i, 1] * factor, 0.0, 1.0)
|
|
67
|
+
result[i, 2] = clamp(colors[i, 2] * factor, 0.0, 1.0)
|
|
68
|
+
result[i, 3] = colors[i, 3]
|
|
69
|
+
|
|
70
|
+
return np.asarray(result)
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
@cython.boundscheck(False)
|
|
74
|
+
@cython.wraparound(False)
|
|
75
|
+
def batch_add_colors(float[:, :] colors1, float[:, :] colors2) -> cnp.ndarray:
|
|
76
|
+
"""
|
|
77
|
+
Add two color arrays (clamped to 1.0)
|
|
78
|
+
colors1, colors2: shape (N, 4) RGBA float arrays
|
|
79
|
+
Returns: shape (N, 4) added colors
|
|
80
|
+
"""
|
|
81
|
+
cdef int n = colors1.shape[0]
|
|
82
|
+
cdef int i, j
|
|
83
|
+
cdef float[:, :] result = np.empty((n, 4), dtype=np.float32)
|
|
84
|
+
|
|
85
|
+
with nogil:
|
|
86
|
+
for i in range(n):
|
|
87
|
+
for j in range(4):
|
|
88
|
+
result[i, j] = clamp(colors1[i, j] + colors2[i, j], 0.0, 1.0)
|
|
89
|
+
|
|
90
|
+
return np.asarray(result)
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
@cython.boundscheck(False)
|
|
94
|
+
@cython.wraparound(False)
|
|
95
|
+
def batch_grayscale(float[:, :] colors) -> cnp.ndarray:
|
|
96
|
+
"""
|
|
97
|
+
Convert colors to grayscale using luminance formula
|
|
98
|
+
colors: shape (N, 4) RGBA float array
|
|
99
|
+
Returns: shape (N, 4) grayscale colors (alpha preserved)
|
|
100
|
+
"""
|
|
101
|
+
cdef int n = colors.shape[0]
|
|
102
|
+
cdef int i
|
|
103
|
+
cdef float gray
|
|
104
|
+
cdef float[:, :] result = np.empty((n, 4), dtype=np.float32)
|
|
105
|
+
|
|
106
|
+
with nogil:
|
|
107
|
+
for i in range(n):
|
|
108
|
+
gray = 0.2989 * colors[i, 0] + 0.5870 * colors[i, 1] + 0.1140 * colors[i, 2]
|
|
109
|
+
result[i, 0] = gray
|
|
110
|
+
result[i, 1] = gray
|
|
111
|
+
result[i, 2] = gray
|
|
112
|
+
result[i, 3] = colors[i, 3]
|
|
113
|
+
|
|
114
|
+
return np.asarray(result)
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
@cython.boundscheck(False)
|
|
118
|
+
@cython.wraparound(False)
|
|
119
|
+
def batch_invert(float[:, :] colors) -> cnp.ndarray:
|
|
120
|
+
"""
|
|
121
|
+
Invert RGB channels (preserves alpha)
|
|
122
|
+
colors: shape (N, 4) RGBA float array
|
|
123
|
+
Returns: shape (N, 4) inverted colors
|
|
124
|
+
"""
|
|
125
|
+
cdef int n = colors.shape[0]
|
|
126
|
+
cdef int i
|
|
127
|
+
cdef float[:, :] result = np.empty((n, 4), dtype=np.float32)
|
|
128
|
+
|
|
129
|
+
with nogil:
|
|
130
|
+
for i in range(n):
|
|
131
|
+
result[i, 0] = 1.0 - colors[i, 0]
|
|
132
|
+
result[i, 1] = 1.0 - colors[i, 1]
|
|
133
|
+
result[i, 2] = 1.0 - colors[i, 2]
|
|
134
|
+
result[i, 3] = colors[i, 3]
|
|
135
|
+
|
|
136
|
+
return np.asarray(result)
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
@cython.boundscheck(False)
|
|
140
|
+
@cython.wraparound(False)
|
|
141
|
+
cdef inline void rgb_to_hsv_fast(float r, float g, float b, float* h, float* s, float* v) nogil:
|
|
142
|
+
"""Fast RGB to HSV conversion"""
|
|
143
|
+
cdef float cmax = fmax(r, fmax(g, b))
|
|
144
|
+
cdef float cmin = fmin(r, fmin(g, b))
|
|
145
|
+
cdef float delta = cmax - cmin
|
|
146
|
+
|
|
147
|
+
v[0] = cmax
|
|
148
|
+
|
|
149
|
+
if cmax == 0.0:
|
|
150
|
+
s[0] = 0.0
|
|
151
|
+
h[0] = 0.0
|
|
152
|
+
return
|
|
153
|
+
|
|
154
|
+
s[0] = delta / cmax
|
|
155
|
+
|
|
156
|
+
if delta == 0.0:
|
|
157
|
+
h[0] = 0.0
|
|
158
|
+
return
|
|
159
|
+
|
|
160
|
+
if cmax == r:
|
|
161
|
+
h[0] = fmod((g - b) / delta, 6.0)
|
|
162
|
+
elif cmax == g:
|
|
163
|
+
h[0] = (b - r) / delta + 2.0
|
|
164
|
+
else:
|
|
165
|
+
h[0] = (r - g) / delta + 4.0
|
|
166
|
+
|
|
167
|
+
h[0] /= 6.0
|
|
168
|
+
if h[0] < 0.0:
|
|
169
|
+
h[0] += 1.0
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
@cython.boundscheck(False)
|
|
173
|
+
@cython.wraparound(False)
|
|
174
|
+
cdef inline void hsv_to_rgb_fast(float h, float s, float v, float* r, float* g, float* b) nogil:
|
|
175
|
+
"""Fast HSV to RGB conversion"""
|
|
176
|
+
if s == 0.0:
|
|
177
|
+
r[0] = v
|
|
178
|
+
g[0] = v
|
|
179
|
+
b[0] = v
|
|
180
|
+
return
|
|
181
|
+
|
|
182
|
+
cdef float h6 = h * 6.0
|
|
183
|
+
cdef int i = <int>floor(h6)
|
|
184
|
+
cdef float f = h6 - i
|
|
185
|
+
cdef float p = v * (1.0 - s)
|
|
186
|
+
cdef float q = v * (1.0 - s * f)
|
|
187
|
+
cdef float t = v * (1.0 - s * (1.0 - f))
|
|
188
|
+
|
|
189
|
+
if i == 0:
|
|
190
|
+
r[0] = v
|
|
191
|
+
g[0] = t
|
|
192
|
+
b[0] = p
|
|
193
|
+
elif i == 1:
|
|
194
|
+
r[0] = q
|
|
195
|
+
g[0] = v
|
|
196
|
+
b[0] = p
|
|
197
|
+
elif i == 2:
|
|
198
|
+
r[0] = p
|
|
199
|
+
g[0] = v
|
|
200
|
+
b[0] = t
|
|
201
|
+
elif i == 3:
|
|
202
|
+
r[0] = p
|
|
203
|
+
g[0] = q
|
|
204
|
+
b[0] = v
|
|
205
|
+
elif i == 4:
|
|
206
|
+
r[0] = t
|
|
207
|
+
g[0] = p
|
|
208
|
+
b[0] = v
|
|
209
|
+
else:
|
|
210
|
+
r[0] = v
|
|
211
|
+
g[0] = p
|
|
212
|
+
b[0] = q
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
@cython.boundscheck(False)
|
|
216
|
+
@cython.wraparound(False)
|
|
217
|
+
def batch_rgb_to_hsv(float[:, :] colors) -> cnp.ndarray:
|
|
218
|
+
"""
|
|
219
|
+
Convert RGB colors to HSV
|
|
220
|
+
colors: shape (N, 4) RGBA float array
|
|
221
|
+
Returns: shape (N, 4) HSVA float array (alpha preserved)
|
|
222
|
+
"""
|
|
223
|
+
cdef int n = colors.shape[0]
|
|
224
|
+
cdef int i
|
|
225
|
+
cdef float h, s, v
|
|
226
|
+
cdef float[:, :] result = np.empty((n, 4), dtype=np.float32)
|
|
227
|
+
|
|
228
|
+
with nogil:
|
|
229
|
+
for i in range(n):
|
|
230
|
+
rgb_to_hsv_fast(colors[i, 0], colors[i, 1], colors[i, 2], &h, &s, &v)
|
|
231
|
+
result[i, 0] = h
|
|
232
|
+
result[i, 1] = s
|
|
233
|
+
result[i, 2] = v
|
|
234
|
+
result[i, 3] = colors[i, 3]
|
|
235
|
+
|
|
236
|
+
return np.asarray(result)
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
@cython.boundscheck(False)
|
|
240
|
+
@cython.wraparound(False)
|
|
241
|
+
def batch_hsv_to_rgb(float[:, :] colors) -> cnp.ndarray:
|
|
242
|
+
"""
|
|
243
|
+
Convert HSV colors to RGB
|
|
244
|
+
colors: shape (N, 4) HSVA float array
|
|
245
|
+
Returns: shape (N, 4) RGBA float array (alpha preserved)
|
|
246
|
+
"""
|
|
247
|
+
cdef int n = colors.shape[0]
|
|
248
|
+
cdef int i
|
|
249
|
+
cdef float r, g, b
|
|
250
|
+
cdef float[:, :] result = np.empty((n, 4), dtype=np.float32)
|
|
251
|
+
|
|
252
|
+
with nogil:
|
|
253
|
+
for i in range(n):
|
|
254
|
+
hsv_to_rgb_fast(colors[i, 0], colors[i, 1], colors[i, 2], &r, &g, &b)
|
|
255
|
+
result[i, 0] = r
|
|
256
|
+
result[i, 1] = g
|
|
257
|
+
result[i, 2] = b
|
|
258
|
+
result[i, 3] = colors[i, 3]
|
|
259
|
+
|
|
260
|
+
return np.asarray(result)
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
@cython.boundscheck(False)
|
|
264
|
+
@cython.wraparound(False)
|
|
265
|
+
def batch_rotate_hue(float[:, :] colors, float degrees) -> cnp.ndarray:
|
|
266
|
+
"""
|
|
267
|
+
Rotate hue of RGB colors by degrees
|
|
268
|
+
colors: shape (N, 4) RGBA float array
|
|
269
|
+
degrees: rotation amount (0-360)
|
|
270
|
+
Returns: shape (N, 4) rotated colors
|
|
271
|
+
"""
|
|
272
|
+
cdef int n = colors.shape[0]
|
|
273
|
+
cdef int i
|
|
274
|
+
cdef float h, s, v, r, g, b
|
|
275
|
+
cdef float rotation = degrees / 360.0
|
|
276
|
+
cdef float[:, :] result = np.empty((n, 4), dtype=np.float32)
|
|
277
|
+
|
|
278
|
+
with nogil:
|
|
279
|
+
for i in range(n):
|
|
280
|
+
rgb_to_hsv_fast(colors[i, 0], colors[i, 1], colors[i, 2], &h, &s, &v)
|
|
281
|
+
h = fmod(h + rotation, 1.0)
|
|
282
|
+
if h < 0.0:
|
|
283
|
+
h += 1.0
|
|
284
|
+
hsv_to_rgb_fast(h, s, v, &r, &g, &b)
|
|
285
|
+
result[i, 0] = r
|
|
286
|
+
result[i, 1] = g
|
|
287
|
+
result[i, 2] = b
|
|
288
|
+
result[i, 3] = colors[i, 3]
|
|
289
|
+
|
|
290
|
+
return np.asarray(result)
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
@cython.boundscheck(False)
|
|
294
|
+
@cython.wraparound(False)
|
|
295
|
+
def batch_saturate(float[:, :] colors, float amount) -> cnp.ndarray:
|
|
296
|
+
"""
|
|
297
|
+
Adjust saturation of RGB colors
|
|
298
|
+
colors: shape (N, 4) RGBA float array
|
|
299
|
+
amount: saturation change (-1.0 to 1.0)
|
|
300
|
+
Returns: shape (N, 4) adjusted colors
|
|
301
|
+
"""
|
|
302
|
+
cdef int n = colors.shape[0]
|
|
303
|
+
cdef int i
|
|
304
|
+
cdef float h, s, v, r, g, b
|
|
305
|
+
cdef float[:, :] result = np.empty((n, 4), dtype=np.float32)
|
|
306
|
+
|
|
307
|
+
with nogil:
|
|
308
|
+
for i in range(n):
|
|
309
|
+
rgb_to_hsv_fast(colors[i, 0], colors[i, 1], colors[i, 2], &h, &s, &v)
|
|
310
|
+
s = clamp(s + amount, 0.0, 1.0)
|
|
311
|
+
hsv_to_rgb_fast(h, s, v, &r, &g, &b)
|
|
312
|
+
result[i, 0] = r
|
|
313
|
+
result[i, 1] = g
|
|
314
|
+
result[i, 2] = b
|
|
315
|
+
result[i, 3] = colors[i, 3]
|
|
316
|
+
|
|
317
|
+
return np.asarray(result)
|
|
318
|
+
|
|
319
|
+
|
|
320
|
+
@cython.boundscheck(False)
|
|
321
|
+
@cython.wraparound(False)
|
|
322
|
+
def generate_gradient(float[:, :] colors, int steps) -> cnp.ndarray:
|
|
323
|
+
"""
|
|
324
|
+
Generate smooth gradient between multiple colors
|
|
325
|
+
colors: shape (N, 4) RGBA float array (control points)
|
|
326
|
+
steps: total number of gradient steps
|
|
327
|
+
Returns: shape (steps, 4) gradient colors
|
|
328
|
+
"""
|
|
329
|
+
cdef int n_colors = colors.shape[0]
|
|
330
|
+
cdef int segments = n_colors - 1
|
|
331
|
+
cdef int steps_per_segment = steps // segments
|
|
332
|
+
cdef int i, j, k
|
|
333
|
+
cdef float t
|
|
334
|
+
cdef float[:, :] result = np.empty((steps, 4), dtype=np.float32)
|
|
335
|
+
cdef int idx = 0
|
|
336
|
+
|
|
337
|
+
with nogil:
|
|
338
|
+
for i in range(segments):
|
|
339
|
+
for j in range(steps_per_segment):
|
|
340
|
+
t = <float>j / <float>steps_per_segment
|
|
341
|
+
for k in range(4):
|
|
342
|
+
result[idx, k] = colors[i, k] + (colors[i + 1, k] - colors[i, k]) * t
|
|
343
|
+
idx += 1
|
|
344
|
+
|
|
345
|
+
# Add final color
|
|
346
|
+
if idx < steps:
|
|
347
|
+
for k in range(4):
|
|
348
|
+
result[idx, k] = colors[n_colors - 1, k]
|
|
349
|
+
|
|
350
|
+
return np.asarray(result)
|
e2D/color_defs.py
ADDED
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Pre-defined color palette for e2D
|
|
3
|
+
All colors are RGBA tuples (0.0-1.0) for GPU compatibility
|
|
4
|
+
Import individual colors as needed: from e2D.color_defs import RED, BLUE
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from typing import Final, TYPE_CHECKING
|
|
8
|
+
|
|
9
|
+
if TYPE_CHECKING:
|
|
10
|
+
from .types import ColorType
|
|
11
|
+
else:
|
|
12
|
+
ColorType = tuple[float, float, float, float]
|
|
13
|
+
|
|
14
|
+
# ============================================================================
|
|
15
|
+
# Basic Colors
|
|
16
|
+
# ============================================================================
|
|
17
|
+
TRANSPARENT: Final[ColorType] = (0.0, 0.0, 0.0, 0.0)
|
|
18
|
+
WHITE: Final[ColorType] = (1.0, 1.0, 1.0, 1.0)
|
|
19
|
+
BLACK: Final[ColorType] = (0.0, 0.0, 0.0, 1.0)
|
|
20
|
+
RED: Final[ColorType] = (1.0, 0.0, 0.0, 1.0)
|
|
21
|
+
GREEN: Final[ColorType] = (0.0, 1.0, 0.0, 1.0)
|
|
22
|
+
BLUE: Final[ColorType] = (0.0, 0.0, 1.0, 1.0)
|
|
23
|
+
CYAN: Final[ColorType] = (0.0, 1.0, 1.0, 1.0)
|
|
24
|
+
MAGENTA: Final[ColorType] = (1.0, 0.0, 1.0, 1.0)
|
|
25
|
+
YELLOW: Final[ColorType] = (1.0, 1.0, 0.0, 1.0)
|
|
26
|
+
|
|
27
|
+
# ============================================================================
|
|
28
|
+
# Extended Colors
|
|
29
|
+
# ============================================================================
|
|
30
|
+
ORANGE: Final[ColorType] = (1.0, 0.647, 0.0, 1.0)
|
|
31
|
+
PURPLE: Final[ColorType] = (0.5, 0.0, 0.5, 1.0)
|
|
32
|
+
PINK: Final[ColorType] = (1.0, 0.753, 0.796, 1.0)
|
|
33
|
+
BROWN: Final[ColorType] = (0.647, 0.165, 0.165, 1.0)
|
|
34
|
+
LIME: Final[ColorType] = (0.5, 1.0, 0.0, 1.0)
|
|
35
|
+
TEAL: Final[ColorType] = (0.0, 0.5, 0.5, 1.0)
|
|
36
|
+
NAVY: Final[ColorType] = (0.0, 0.0, 0.5, 1.0)
|
|
37
|
+
MAROON: Final[ColorType] = (0.5, 0.0, 0.0, 1.0)
|
|
38
|
+
OLIVE: Final[ColorType] = (0.5, 0.5, 0.0, 1.0)
|
|
39
|
+
SILVER: Final[ColorType] = (0.753, 0.753, 0.753, 1.0)
|
|
40
|
+
GOLD: Final[ColorType] = (1.0, 0.843, 0.0, 1.0)
|
|
41
|
+
INDIGO: Final[ColorType] = (0.294, 0.0, 0.51, 1.0)
|
|
42
|
+
VIOLET: Final[ColorType] = (0.933, 0.51, 0.933, 1.0)
|
|
43
|
+
TURQUOISE: Final[ColorType] = (0.251, 0.878, 0.816, 1.0)
|
|
44
|
+
CORAL: Final[ColorType] = (1.0, 0.498, 0.314, 1.0)
|
|
45
|
+
|
|
46
|
+
# ============================================================================
|
|
47
|
+
# Grayscale
|
|
48
|
+
# ============================================================================
|
|
49
|
+
GRAY10: Final[ColorType] = (0.1, 0.1, 0.1, 1.0)
|
|
50
|
+
GRAY20: Final[ColorType] = (0.2, 0.2, 0.2, 1.0)
|
|
51
|
+
GRAY30: Final[ColorType] = (0.3, 0.3, 0.3, 1.0)
|
|
52
|
+
GRAY40: Final[ColorType] = (0.4, 0.4, 0.4, 1.0)
|
|
53
|
+
GRAY50: Final[ColorType] = (0.5, 0.5, 0.5, 1.0)
|
|
54
|
+
GRAY60: Final[ColorType] = (0.6, 0.6, 0.6, 1.0)
|
|
55
|
+
GRAY70: Final[ColorType] = (0.7, 0.7, 0.7, 1.0)
|
|
56
|
+
GRAY80: Final[ColorType] = (0.8, 0.8, 0.8, 1.0)
|
|
57
|
+
GRAY90: Final[ColorType] = (0.9, 0.9, 0.9, 1.0)
|
|
58
|
+
|
|
59
|
+
# ============================================================================
|
|
60
|
+
# Material Design Colors (Primary Palette)
|
|
61
|
+
# ============================================================================
|
|
62
|
+
MD_RED: Final[ColorType] = (0.957, 0.263, 0.212, 1.0) # #F44336
|
|
63
|
+
MD_PINK: Final[ColorType] = (0.914, 0.118, 0.388, 1.0) # #E91E63
|
|
64
|
+
MD_PURPLE: Final[ColorType] = (0.612, 0.153, 0.690, 1.0) # #9C27B0
|
|
65
|
+
MD_DEEP_PURPLE: Final[ColorType] = (0.404, 0.227, 0.718, 1.0) # #673AB7
|
|
66
|
+
MD_INDIGO: Final[ColorType] = (0.247, 0.318, 0.710, 1.0) # #3F51B5
|
|
67
|
+
MD_BLUE: Final[ColorType] = (0.129, 0.588, 0.953, 1.0) # #2196F3
|
|
68
|
+
MD_LIGHT_BLUE: Final[ColorType] = (0.012, 0.663, 0.957, 1.0) # #03A9F4
|
|
69
|
+
MD_CYAN: Final[ColorType] = (0.0, 0.737, 0.831, 1.0) # #00BCD4
|
|
70
|
+
MD_TEAL: Final[ColorType] = (0.0, 0.588, 0.533, 1.0) # #009688
|
|
71
|
+
MD_GREEN: Final[ColorType] = (0.298, 0.686, 0.314, 1.0) # #4CAF50
|
|
72
|
+
MD_LIGHT_GREEN: Final[ColorType] = (0.545, 0.765, 0.290, 1.0) # #8BC34A
|
|
73
|
+
MD_LIME: Final[ColorType] = (0.804, 0.863, 0.224, 1.0) # #CDDC39
|
|
74
|
+
MD_YELLOW: Final[ColorType] = (1.0, 0.922, 0.231, 1.0) # #FFEB3B
|
|
75
|
+
MD_AMBER: Final[ColorType] = (1.0, 0.757, 0.027, 1.0) # #FFC107
|
|
76
|
+
MD_ORANGE: Final[ColorType] = (1.0, 0.596, 0.0, 1.0) # #FF9800
|
|
77
|
+
MD_DEEP_ORANGE: Final[ColorType] = (1.0, 0.341, 0.133, 1.0) # #FF5722
|
|
78
|
+
MD_BROWN: Final[ColorType] = (0.475, 0.333, 0.282, 1.0) # #795548
|
|
79
|
+
MD_GREY: Final[ColorType] = (0.620, 0.620, 0.620, 1.0) # #9E9E9E
|
|
80
|
+
MD_BLUE_GREY: Final[ColorType] = (0.376, 0.490, 0.545, 1.0) # #607D8B
|
|
81
|
+
|
|
82
|
+
# ============================================================================
|
|
83
|
+
# Pastel Colors
|
|
84
|
+
# ============================================================================
|
|
85
|
+
PASTEL_RED: Final[ColorType] = (1.0, 0.412, 0.380, 1.0)
|
|
86
|
+
PASTEL_ORANGE: Final[ColorType] = (1.0, 0.706, 0.510, 1.0)
|
|
87
|
+
PASTEL_YELLOW: Final[ColorType] = (1.0, 0.996, 0.635, 1.0)
|
|
88
|
+
PASTEL_GREEN: Final[ColorType] = (0.467, 0.867, 0.467, 1.0)
|
|
89
|
+
PASTEL_CYAN: Final[ColorType] = (0.467, 0.867, 0.867, 1.0)
|
|
90
|
+
PASTEL_BLUE: Final[ColorType] = (0.686, 0.933, 0.933, 1.0)
|
|
91
|
+
PASTEL_PURPLE: Final[ColorType] = (0.800, 0.600, 0.800, 1.0)
|
|
92
|
+
PASTEL_PINK: Final[ColorType] = (1.0, 0.820, 0.863, 1.0)
|
|
93
|
+
|
|
94
|
+
# ============================================================================
|
|
95
|
+
# Neon Colors
|
|
96
|
+
# ============================================================================
|
|
97
|
+
NEON_RED: Final[ColorType] = (1.0, 0.0, 0.0, 1.0)
|
|
98
|
+
NEON_ORANGE: Final[ColorType] = (1.0, 0.4, 0.0, 1.0)
|
|
99
|
+
NEON_YELLOW: Final[ColorType] = (1.0, 1.0, 0.0, 1.0)
|
|
100
|
+
NEON_GREEN: Final[ColorType] = (0.0, 1.0, 0.0, 1.0)
|
|
101
|
+
NEON_CYAN: Final[ColorType] = (0.0, 1.0, 1.0, 1.0)
|
|
102
|
+
NEON_BLUE: Final[ColorType] = (0.0, 0.4, 1.0, 1.0)
|
|
103
|
+
NEON_PURPLE: Final[ColorType] = (0.8, 0.0, 1.0, 1.0)
|
|
104
|
+
NEON_PINK: Final[ColorType] = (1.0, 0.0, 0.5, 1.0)
|
|
105
|
+
|
|
106
|
+
# ============================================================================
|
|
107
|
+
# UI Common Colors
|
|
108
|
+
# ============================================================================
|
|
109
|
+
UI_SUCCESS: Final[ColorType] = (0.298, 0.686, 0.314, 1.0) # Green
|
|
110
|
+
UI_WARNING: Final[ColorType] = (1.0, 0.757, 0.027, 1.0) # Amber
|
|
111
|
+
UI_ERROR: Final[ColorType] = (0.957, 0.263, 0.212, 1.0) # Red
|
|
112
|
+
UI_INFO: Final[ColorType] = (0.129, 0.588, 0.953, 1.0) # Blue
|
|
113
|
+
UI_DISABLED: Final[ColorType] = (0.62, 0.62, 0.62, 1.0) # Grey
|
|
114
|
+
|
|
115
|
+
# ============================================================================
|
|
116
|
+
# Color Dictionary (for dynamic lookup)
|
|
117
|
+
# ============================================================================
|
|
118
|
+
COLOR_NAMES: dict[str, ColorType] = {
|
|
119
|
+
# Basic
|
|
120
|
+
'transparent': TRANSPARENT,
|
|
121
|
+
'white': WHITE,
|
|
122
|
+
'black': BLACK,
|
|
123
|
+
'red': RED,
|
|
124
|
+
'green': GREEN,
|
|
125
|
+
'blue': BLUE,
|
|
126
|
+
'cyan': CYAN,
|
|
127
|
+
'magenta': MAGENTA,
|
|
128
|
+
'yellow': YELLOW,
|
|
129
|
+
# Extended
|
|
130
|
+
'orange': ORANGE,
|
|
131
|
+
'purple': PURPLE,
|
|
132
|
+
'pink': PINK,
|
|
133
|
+
'brown': BROWN,
|
|
134
|
+
'lime': LIME,
|
|
135
|
+
'teal': TEAL,
|
|
136
|
+
'navy': NAVY,
|
|
137
|
+
'maroon': MAROON,
|
|
138
|
+
'olive': OLIVE,
|
|
139
|
+
'silver': SILVER,
|
|
140
|
+
'gold': GOLD,
|
|
141
|
+
'indigo': INDIGO,
|
|
142
|
+
'violet': VIOLET,
|
|
143
|
+
'turquoise': TURQUOISE,
|
|
144
|
+
'coral': CORAL,
|
|
145
|
+
# Grayscale
|
|
146
|
+
'gray10': GRAY10,
|
|
147
|
+
'gray20': GRAY20,
|
|
148
|
+
'gray30': GRAY30,
|
|
149
|
+
'gray40': GRAY40,
|
|
150
|
+
'gray50': GRAY50,
|
|
151
|
+
'gray60': GRAY60,
|
|
152
|
+
'gray70': GRAY70,
|
|
153
|
+
'gray80': GRAY80,
|
|
154
|
+
'gray90': GRAY90,
|
|
155
|
+
# Material Design
|
|
156
|
+
'md_red': MD_RED,
|
|
157
|
+
'md_pink': MD_PINK,
|
|
158
|
+
'md_purple': MD_PURPLE,
|
|
159
|
+
'md_deep_purple': MD_DEEP_PURPLE,
|
|
160
|
+
'md_indigo': MD_INDIGO,
|
|
161
|
+
'md_blue': MD_BLUE,
|
|
162
|
+
'md_light_blue': MD_LIGHT_BLUE,
|
|
163
|
+
'md_cyan': MD_CYAN,
|
|
164
|
+
'md_teal': MD_TEAL,
|
|
165
|
+
'md_green': MD_GREEN,
|
|
166
|
+
'md_light_green': MD_LIGHT_GREEN,
|
|
167
|
+
'md_lime': MD_LIME,
|
|
168
|
+
'md_yellow': MD_YELLOW,
|
|
169
|
+
'md_amber': MD_AMBER,
|
|
170
|
+
'md_orange': MD_ORANGE,
|
|
171
|
+
'md_deep_orange': MD_DEEP_ORANGE,
|
|
172
|
+
'md_brown': MD_BROWN,
|
|
173
|
+
'md_grey': MD_GREY,
|
|
174
|
+
'md_blue_grey': MD_BLUE_GREY,
|
|
175
|
+
# Pastels
|
|
176
|
+
'pastel_red': PASTEL_RED,
|
|
177
|
+
'pastel_orange': PASTEL_ORANGE,
|
|
178
|
+
'pastel_yellow': PASTEL_YELLOW,
|
|
179
|
+
'pastel_green': PASTEL_GREEN,
|
|
180
|
+
'pastel_cyan': PASTEL_CYAN,
|
|
181
|
+
'pastel_blue': PASTEL_BLUE,
|
|
182
|
+
'pastel_purple': PASTEL_PURPLE,
|
|
183
|
+
'pastel_pink': PASTEL_PINK,
|
|
184
|
+
# Neon
|
|
185
|
+
'neon_red': NEON_RED,
|
|
186
|
+
'neon_orange': NEON_ORANGE,
|
|
187
|
+
'neon_yellow': NEON_YELLOW,
|
|
188
|
+
'neon_green': NEON_GREEN,
|
|
189
|
+
'neon_cyan': NEON_CYAN,
|
|
190
|
+
'neon_blue': NEON_BLUE,
|
|
191
|
+
'neon_purple': NEON_PURPLE,
|
|
192
|
+
'neon_pink': NEON_PINK,
|
|
193
|
+
# UI
|
|
194
|
+
'ui_success': UI_SUCCESS,
|
|
195
|
+
'ui_warning': UI_WARNING,
|
|
196
|
+
'ui_error': UI_ERROR,
|
|
197
|
+
'ui_info': UI_INFO,
|
|
198
|
+
'ui_disabled': UI_DISABLED,
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
def get_color(name: str) -> ColorType:
|
|
203
|
+
"""Get color by name (case-insensitive)"""
|
|
204
|
+
return COLOR_NAMES[name.lower()]
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
def has_color(name: str) -> bool:
|
|
208
|
+
"""Check if color name exists"""
|
|
209
|
+
return name.lower() in COLOR_NAMES
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
__all__ = [
|
|
213
|
+
# Basic
|
|
214
|
+
'TRANSPARENT', 'WHITE', 'BLACK', 'RED', 'GREEN', 'BLUE',
|
|
215
|
+
'CYAN', 'MAGENTA', 'YELLOW',
|
|
216
|
+
# Extended
|
|
217
|
+
'ORANGE', 'PURPLE', 'PINK', 'BROWN', 'LIME', 'TEAL',
|
|
218
|
+
'NAVY', 'MAROON', 'OLIVE', 'SILVER', 'GOLD', 'INDIGO',
|
|
219
|
+
'VIOLET', 'TURQUOISE', 'CORAL',
|
|
220
|
+
# Grayscale
|
|
221
|
+
'GRAY10', 'GRAY20', 'GRAY30', 'GRAY40', 'GRAY50',
|
|
222
|
+
'GRAY60', 'GRAY70', 'GRAY80', 'GRAY90',
|
|
223
|
+
# Material Design
|
|
224
|
+
'MD_RED', 'MD_PINK', 'MD_PURPLE', 'MD_DEEP_PURPLE', 'MD_INDIGO',
|
|
225
|
+
'MD_BLUE', 'MD_LIGHT_BLUE', 'MD_CYAN', 'MD_TEAL', 'MD_GREEN',
|
|
226
|
+
'MD_LIGHT_GREEN', 'MD_LIME', 'MD_YELLOW', 'MD_AMBER', 'MD_ORANGE',
|
|
227
|
+
'MD_DEEP_ORANGE', 'MD_BROWN', 'MD_GREY', 'MD_BLUE_GREY',
|
|
228
|
+
# Pastels
|
|
229
|
+
'PASTEL_RED', 'PASTEL_ORANGE', 'PASTEL_YELLOW', 'PASTEL_GREEN',
|
|
230
|
+
'PASTEL_CYAN', 'PASTEL_BLUE', 'PASTEL_PURPLE', 'PASTEL_PINK',
|
|
231
|
+
# Neon
|
|
232
|
+
'NEON_RED', 'NEON_ORANGE', 'NEON_YELLOW', 'NEON_GREEN',
|
|
233
|
+
'NEON_CYAN', 'NEON_BLUE', 'NEON_PURPLE', 'NEON_PINK',
|
|
234
|
+
# UI
|
|
235
|
+
'UI_SUCCESS', 'UI_WARNING', 'UI_ERROR', 'UI_INFO', 'UI_DISABLED',
|
|
236
|
+
# Functions
|
|
237
|
+
'COLOR_NAMES', 'get_color', 'has_color',
|
|
238
|
+
]
|