svg-ultralight 0.36.0__py3-none-any.whl → 0.37.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.
Potentially problematic release.
This version of svg-ultralight might be problematic. Click here for more details.
- svg_ultralight/strings/svg_strings.py +22 -1
- {svg_ultralight-0.36.0.dist-info → svg_ultralight-0.37.0.dist-info}/METADATA +1 -1
- {svg_ultralight-0.36.0.dist-info → svg_ultralight-0.37.0.dist-info}/RECORD +5 -5
- {svg_ultralight-0.36.0.dist-info → svg_ultralight-0.37.0.dist-info}/WHEEL +0 -0
- {svg_ultralight-0.36.0.dist-info → svg_ultralight-0.37.0.dist-info}/top_level.txt +0 -0
|
@@ -17,13 +17,34 @@ if TYPE_CHECKING:
|
|
|
17
17
|
from collections.abc import Iterable
|
|
18
18
|
|
|
19
19
|
|
|
20
|
+
_MAX_8BIT = 255
|
|
21
|
+
_BIG_INT = 2**32 - 1
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def _float_to_8bit_int(clipped_float: float) -> int:
|
|
25
|
+
"""Convert a float between 0 and 255 to an int between 0 and 255.
|
|
26
|
+
|
|
27
|
+
:param float_: a float in the closed interval [0 .. 255]. Values outside this
|
|
28
|
+
range will be clipped.
|
|
29
|
+
:return: an int in the closed interval [0 .. 255]
|
|
30
|
+
|
|
31
|
+
Convert color floats [0 .. 255] to ints [0 .. 255] without rounding, which "short
|
|
32
|
+
changes" 0 and 255.
|
|
33
|
+
"""
|
|
34
|
+
clipped_float = min(_MAX_8BIT, max(0, clipped_float))
|
|
35
|
+
if clipped_float % 1:
|
|
36
|
+
high_int = int(clipped_float / _MAX_8BIT * _BIG_INT)
|
|
37
|
+
return high_int >> 24
|
|
38
|
+
return int(clipped_float)
|
|
39
|
+
|
|
40
|
+
|
|
20
41
|
def svg_color_tuple(rgb_floats: tuple[float, float, float]) -> str:
|
|
21
42
|
"""Turn an rgb tuple (0-255, 0-255, 0-255) into an svg color definition.
|
|
22
43
|
|
|
23
44
|
:param rgb_floats: (0-255, 0-255, 0-255)
|
|
24
45
|
:return: "rgb(128,128,128)"
|
|
25
46
|
"""
|
|
26
|
-
r, g, b = (
|
|
47
|
+
r, g, b = map(_float_to_8bit_int, rgb_floats)
|
|
27
48
|
return f"rgb({r},{g},{b})"
|
|
28
49
|
|
|
29
50
|
|
|
@@ -22,8 +22,8 @@ svg_ultralight/bounding_boxes/type_padded_text.py,sha256=QA6PfeO_sQYc5pEXuyfyQ3l
|
|
|
22
22
|
svg_ultralight/constructors/__init__.py,sha256=XLOInLhzMERWNnFAs-itMs-OZrBOpvQthZJ2T5duqBE,327
|
|
23
23
|
svg_ultralight/constructors/new_element.py,sha256=8nqmOEgt3j-aOVeRaMLFHqrwKg2Dm5w0AfuK9MP4ak8,3433
|
|
24
24
|
svg_ultralight/strings/__init__.py,sha256=BMGhF1pulscIgkiYvZLr6kPRR0L4lW0jUNFxkul4_EM,295
|
|
25
|
-
svg_ultralight/strings/svg_strings.py,sha256=
|
|
26
|
-
svg_ultralight-0.
|
|
27
|
-
svg_ultralight-0.
|
|
28
|
-
svg_ultralight-0.
|
|
29
|
-
svg_ultralight-0.
|
|
25
|
+
svg_ultralight/strings/svg_strings.py,sha256=FQNxNmMkR2M-gCFo_woQKXLgCHi3ncUlRMiaRR_a9nQ,1978
|
|
26
|
+
svg_ultralight-0.37.0.dist-info/METADATA,sha256=wWTDiiOScZrgr_Np0_XCqyJ9WKEAEKHJRXvPU5Qw5-Y,8933
|
|
27
|
+
svg_ultralight-0.37.0.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
|
28
|
+
svg_ultralight-0.37.0.dist-info/top_level.txt,sha256=se-6yqM_0Yg5orJKvKWdjQZ4iR4G_EjhL7oRgju-fdY,15
|
|
29
|
+
svg_ultralight-0.37.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|