svg-ultralight 0.45.2__py3-none-any.whl → 0.45.4__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/bounding_boxes/type_padded_text.py +36 -0
- svg_ultralight/transformations.py +4 -3
- {svg_ultralight-0.45.2.dist-info → svg_ultralight-0.45.4.dist-info}/METADATA +1 -1
- {svg_ultralight-0.45.2.dist-info → svg_ultralight-0.45.4.dist-info}/RECORD +6 -6
- {svg_ultralight-0.45.2.dist-info → svg_ultralight-0.45.4.dist-info}/WHEEL +0 -0
- {svg_ultralight-0.45.2.dist-info → svg_ultralight-0.45.4.dist-info}/top_level.txt +0 -0
|
@@ -64,6 +64,7 @@ enough to lay out text on a business card.
|
|
|
64
64
|
|
|
65
65
|
from __future__ import annotations
|
|
66
66
|
|
|
67
|
+
import math
|
|
67
68
|
from typing import TYPE_CHECKING
|
|
68
69
|
|
|
69
70
|
from paragraphs import par
|
|
@@ -223,6 +224,41 @@ class PaddedText(BoundElement):
|
|
|
223
224
|
"""
|
|
224
225
|
self.base_bpad = value / self.unpadded_bbox.scale[1]
|
|
225
226
|
|
|
227
|
+
@property
|
|
228
|
+
def scale(self) -> tuple[float, float]:
|
|
229
|
+
"""Get scale of the bounding box.
|
|
230
|
+
|
|
231
|
+
:return: uniform scale of the bounding box
|
|
232
|
+
|
|
233
|
+
Use caution, the scale attribute can cause errors in intuition. Changing
|
|
234
|
+
width or height will change the scale attribute, but not the x or y values.
|
|
235
|
+
The scale setter, on the other hand, will work in the tradational manner.
|
|
236
|
+
I.e., x => x*scale, y => y*scale, x2 => x*scale, y2 => y*scale, width =>
|
|
237
|
+
width*scale, height => height*scale, scale => scale*scale. This matches how
|
|
238
|
+
scale works in almost every other context.
|
|
239
|
+
"""
|
|
240
|
+
xx, xy, yx, yy, *_ = self.unpadded_bbox.transformation
|
|
241
|
+
return math.sqrt(xx * xx + xy * xy), math.sqrt(yx * yx + yy * yy)
|
|
242
|
+
|
|
243
|
+
@scale.setter
|
|
244
|
+
def scale(self, value: tuple[float, float]) -> None:
|
|
245
|
+
"""Scale the bounding box by a uniform factor.
|
|
246
|
+
|
|
247
|
+
:param value: new scale value
|
|
248
|
+
|
|
249
|
+
Don't miss this! You are setting the scale, not scaling the scale! If you
|
|
250
|
+
have a previously defined scale other than 1, this is probably not what you
|
|
251
|
+
want. Most of the time, you will want to use the *= operator.
|
|
252
|
+
|
|
253
|
+
`scale = 2` -> ignore whatever scale was previously defined and set scale to 2
|
|
254
|
+
`scale *= 2` -> make it twice as big as it was.
|
|
255
|
+
"""
|
|
256
|
+
new_scale = (
|
|
257
|
+
value[0] / self.unpadded_bbox.scale[0],
|
|
258
|
+
value[1] / self.unpadded_bbox.scale[1],
|
|
259
|
+
)
|
|
260
|
+
self.transform(scale=new_scale)
|
|
261
|
+
|
|
226
262
|
@property
|
|
227
263
|
def width(self) -> float:
|
|
228
264
|
"""The width of this line of text with padding.
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
from __future__ import annotations
|
|
8
8
|
|
|
9
|
+
import numbers
|
|
9
10
|
import re
|
|
10
11
|
from contextlib import suppress
|
|
11
12
|
from typing import TYPE_CHECKING, cast
|
|
@@ -116,16 +117,16 @@ def new_transformation_matrix(
|
|
|
116
117
|
"""
|
|
117
118
|
transformation = transformation or (1, 0, 0, 1, 0, 0)
|
|
118
119
|
|
|
119
|
-
if isinstance(scale, float):
|
|
120
|
+
if isinstance(scale, (float, int, numbers.Real)):
|
|
120
121
|
scale_x, scale_y = (scale, scale)
|
|
121
122
|
elif scale is None:
|
|
122
123
|
scale_x, scale_y = (1, 1)
|
|
123
124
|
else:
|
|
124
|
-
scale_x, scale_y =
|
|
125
|
+
scale_x, scale_y = scale
|
|
125
126
|
|
|
126
127
|
dx = dx or 0
|
|
127
128
|
dy = dy or 0
|
|
128
|
-
return mat_dot((scale_x, 0, 0, scale_y, dx, dy), transformation)
|
|
129
|
+
return mat_dot((float(scale_x), 0, 0, float(scale_y), dx, dy), transformation)
|
|
129
130
|
|
|
130
131
|
|
|
131
132
|
def transform_element(elem: EtreeElement, matrix: _Matrix) -> EtreeElement:
|
|
@@ -11,7 +11,7 @@ svg_ultralight/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
|
11
11
|
svg_ultralight/query.py,sha256=iFFsK78TuUT6h3iv_V8_fwCggIAdYa97K7oOPhhoPuY,9711
|
|
12
12
|
svg_ultralight/root_elements.py,sha256=H_J7GMO8yqoie169uDUB1LxWSpc7BgUH6H657ZPRahg,3292
|
|
13
13
|
svg_ultralight/string_conversion.py,sha256=NWguHAmuKWON7Fh2EkVDfMIwp-jk6k7SW8hAUh72H0o,8850
|
|
14
|
-
svg_ultralight/transformations.py,sha256=
|
|
14
|
+
svg_ultralight/transformations.py,sha256=q-9GC01fh8vXyddjpDlal9BfebMuMWGl46ubg-0FalU,4510
|
|
15
15
|
svg_ultralight/unit_conversion.py,sha256=g07nhzXdjPvGcJmkhLdFbeDLrSmbI8uFoVgPo7G62Bg,9258
|
|
16
16
|
svg_ultralight/bounding_boxes/__init__.py,sha256=qUEn3r4s-1QNHaguhWhhaNfdP4tl_B6YEqxtiTFuzhQ,78
|
|
17
17
|
svg_ultralight/bounding_boxes/bound_helpers.py,sha256=iCinp_kFsxi29gJEMnDZpKs13Fj1fj8SWqbbWO94UTI,7203
|
|
@@ -20,7 +20,7 @@ svg_ultralight/bounding_boxes/supports_bounds.py,sha256=T7LGse58fDBgmlzupSC63C1Z
|
|
|
20
20
|
svg_ultralight/bounding_boxes/type_bound_collection.py,sha256=NAEpqo9H9ewhuLcOmBnMWUE0zQ1t4bvckovgvWy6hIo,2645
|
|
21
21
|
svg_ultralight/bounding_boxes/type_bound_element.py,sha256=Sc-R0uXkb0aS8-OcyM5pDukKhFUka0G6KCp6LcYDcIU,2204
|
|
22
22
|
svg_ultralight/bounding_boxes/type_bounding_box.py,sha256=bABFT-BwVdOmRJ-BHOLE_7LZv57MDwqABHvRDcVmvtI,13509
|
|
23
|
-
svg_ultralight/bounding_boxes/type_padded_text.py,sha256=
|
|
23
|
+
svg_ultralight/bounding_boxes/type_padded_text.py,sha256=Xk96emqmfIS6FF3DSVegWh6XDAo4gQNLHV0YsB3hOBA,14651
|
|
24
24
|
svg_ultralight/constructors/__init__.py,sha256=XLOInLhzMERWNnFAs-itMs-OZrBOpvQthZJ2T5duqBE,327
|
|
25
25
|
svg_ultralight/constructors/new_element.py,sha256=kGRaVsT1yugADUCKz3NjFW_14Ts1M8UQeLPTarTXtBY,3529
|
|
26
26
|
svg_ultralight/font_tools/__init__.py,sha256=NX3C0vvoB-G4S-h1f0NLWePjYAMMR37D1cl_G4WBjHc,83
|
|
@@ -29,7 +29,7 @@ svg_ultralight/font_tools/font_info.py,sha256=-MEEM8Jslirevocv97RNRaArxaP3xeNiB7
|
|
|
29
29
|
svg_ultralight/font_tools/globs.py,sha256=JdrrGMqDtD4WcY7YGUWV43DUW63RVev-x9vWqsQUhxU,119
|
|
30
30
|
svg_ultralight/strings/__init__.py,sha256=BMGhF1pulscIgkiYvZLr6kPRR0L4lW0jUNFxkul4_EM,295
|
|
31
31
|
svg_ultralight/strings/svg_strings.py,sha256=FQNxNmMkR2M-gCFo_woQKXLgCHi3ncUlRMiaRR_a9nQ,1978
|
|
32
|
-
svg_ultralight-0.45.
|
|
33
|
-
svg_ultralight-0.45.
|
|
34
|
-
svg_ultralight-0.45.
|
|
35
|
-
svg_ultralight-0.45.
|
|
32
|
+
svg_ultralight-0.45.4.dist-info/METADATA,sha256=0EFsA3w0Xh52UjUrfVkTXP6_7840gS9YGai2pGOt-nI,9052
|
|
33
|
+
svg_ultralight-0.45.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
34
|
+
svg_ultralight-0.45.4.dist-info/top_level.txt,sha256=se-6yqM_0Yg5orJKvKWdjQZ4iR4G_EjhL7oRgju-fdY,15
|
|
35
|
+
svg_ultralight-0.45.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|