svg-ultralight 0.39.0__py3-none-any.whl → 0.39.1__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/supports_bounds.py +1 -1
- svg_ultralight/bounding_boxes/type_bound_collection.py +1 -1
- svg_ultralight/bounding_boxes/type_bound_element.py +1 -1
- svg_ultralight/bounding_boxes/type_bounding_box.py +2 -12
- svg_ultralight/bounding_boxes/type_padded_text.py +43 -4
- svg_ultralight/transformations.py +10 -3
- {svg_ultralight-0.39.0.dist-info → svg_ultralight-0.39.1.dist-info}/METADATA +1 -1
- {svg_ultralight-0.39.0.dist-info → svg_ultralight-0.39.1.dist-info}/RECORD +10 -10
- {svg_ultralight-0.39.0.dist-info → svg_ultralight-0.39.1.dist-info}/WHEEL +0 -0
- {svg_ultralight-0.39.0.dist-info → svg_ultralight-0.39.1.dist-info}/top_level.txt +0 -0
|
@@ -59,21 +59,11 @@ class HasBoundingBox(SupportsBounds):
|
|
|
59
59
|
)
|
|
60
60
|
return c0, c1, c2, c3
|
|
61
61
|
|
|
62
|
-
def _scale_scale_by_uniform_scalar(self, scalar: float) -> None:
|
|
63
|
-
"""Scale the bounding box uniformly by a factor.
|
|
64
|
-
|
|
65
|
-
:param scale: scale factor
|
|
66
|
-
Unlike self.scale, this does not set the scale, but scales the scale. So if
|
|
67
|
-
the current scale is (2, 6), and you call this with a scalar of 2, the new
|
|
68
|
-
scale will be (4, 12).
|
|
69
|
-
"""
|
|
70
|
-
self.transform(scale=(scalar, scalar))
|
|
71
|
-
|
|
72
62
|
def transform(
|
|
73
63
|
self,
|
|
74
64
|
transformation: _Matrix | None = None,
|
|
75
65
|
*,
|
|
76
|
-
scale: tuple[float, float] | None = None,
|
|
66
|
+
scale: tuple[float, float] | float | None = None,
|
|
77
67
|
dx: float | None = None,
|
|
78
68
|
dy: float | None = None,
|
|
79
69
|
):
|
|
@@ -241,7 +231,7 @@ class HasBoundingBox(SupportsBounds):
|
|
|
241
231
|
"""
|
|
242
232
|
current_x = self.x
|
|
243
233
|
current_y = self.y
|
|
244
|
-
self.
|
|
234
|
+
self.transform(scale=value / self.width)
|
|
245
235
|
self.x = current_x
|
|
246
236
|
self.y = current_y
|
|
247
237
|
|
|
@@ -122,7 +122,6 @@ class PaddedText(BoundElement):
|
|
|
122
122
|
self.y,
|
|
123
123
|
self.width,
|
|
124
124
|
self.height,
|
|
125
|
-
self.unpadded_bbox.transformation,
|
|
126
125
|
)
|
|
127
126
|
|
|
128
127
|
@bbox.setter
|
|
@@ -139,7 +138,7 @@ class PaddedText(BoundElement):
|
|
|
139
138
|
self,
|
|
140
139
|
transformation: _Matrix | None = None,
|
|
141
140
|
*,
|
|
142
|
-
scale: tuple[float, float] | None = None,
|
|
141
|
+
scale: tuple[float, float] | float | None = None,
|
|
143
142
|
dx: float | None = None,
|
|
144
143
|
dy: float | None = None,
|
|
145
144
|
):
|
|
@@ -208,7 +207,12 @@ class PaddedText(BoundElement):
|
|
|
208
207
|
*and* y2) when scaling.
|
|
209
208
|
"""
|
|
210
209
|
y2 = self.y2
|
|
211
|
-
|
|
210
|
+
|
|
211
|
+
no_margins_old = self.unpadded_bbox.width
|
|
212
|
+
no_margins_new = value - self.lpad - self.rpad
|
|
213
|
+
scale = no_margins_new / no_margins_old
|
|
214
|
+
self.transform(scale=(scale, scale))
|
|
215
|
+
|
|
212
216
|
self.y2 = y2
|
|
213
217
|
|
|
214
218
|
@property
|
|
@@ -226,7 +230,10 @@ class PaddedText(BoundElement):
|
|
|
226
230
|
:param height: The new height of this line of text.
|
|
227
231
|
:effects: the text_element bounding box is scaled to height - tpad - bpad.
|
|
228
232
|
"""
|
|
229
|
-
|
|
233
|
+
y2 = self.y2
|
|
234
|
+
scale = value / self.height
|
|
235
|
+
self.transform(scale=(scale, scale))
|
|
236
|
+
self.y2 = y2
|
|
230
237
|
|
|
231
238
|
@property
|
|
232
239
|
def x(self) -> float:
|
|
@@ -244,6 +251,22 @@ class PaddedText(BoundElement):
|
|
|
244
251
|
"""
|
|
245
252
|
self.transform(dx=value + self.lpad - self.unpadded_bbox.x)
|
|
246
253
|
|
|
254
|
+
@property
|
|
255
|
+
def cx(self) -> float:
|
|
256
|
+
"""The horizontal center of this line of text.
|
|
257
|
+
|
|
258
|
+
:return: The horizontal center of this line of text.
|
|
259
|
+
"""
|
|
260
|
+
return self.x + self.width / 2
|
|
261
|
+
|
|
262
|
+
@cx.setter
|
|
263
|
+
def cx(self, value: float) -> None:
|
|
264
|
+
"""Set the horizontal center of this line of text.
|
|
265
|
+
|
|
266
|
+
:param value: The horizontal center of this line of text.
|
|
267
|
+
"""
|
|
268
|
+
self.x += value - self.cx
|
|
269
|
+
|
|
247
270
|
@property
|
|
248
271
|
def x2(self) -> float:
|
|
249
272
|
"""The right margin of this line of text.
|
|
@@ -276,6 +299,22 @@ class PaddedText(BoundElement):
|
|
|
276
299
|
"""
|
|
277
300
|
self.transform(dy=value + self.tpad - self.unpadded_bbox.y)
|
|
278
301
|
|
|
302
|
+
@property
|
|
303
|
+
def cy(self) -> float:
|
|
304
|
+
"""The horizontal center of this line of text.
|
|
305
|
+
|
|
306
|
+
:return: The horizontal center of this line of text.
|
|
307
|
+
"""
|
|
308
|
+
return self.y + self.height / 2
|
|
309
|
+
|
|
310
|
+
@cy.setter
|
|
311
|
+
def cy(self, value: float) -> None:
|
|
312
|
+
"""Set the horizontal center of this line of text.
|
|
313
|
+
|
|
314
|
+
:param value: The horizontal center of this line of text.
|
|
315
|
+
"""
|
|
316
|
+
self.y += value - self.cy
|
|
317
|
+
|
|
279
318
|
@property
|
|
280
319
|
def y2(self) -> float:
|
|
281
320
|
"""The bottom of this line of text.
|
|
@@ -105,7 +105,7 @@ def get_transform_matrix(elem: EtreeElement) -> _Matrix:
|
|
|
105
105
|
def new_transformation_matrix(
|
|
106
106
|
transformation: _Matrix | None = None,
|
|
107
107
|
*,
|
|
108
|
-
scale: tuple[float, float] | None = None,
|
|
108
|
+
scale: tuple[float, float] | float | None = None,
|
|
109
109
|
dx: float | None = None,
|
|
110
110
|
dy: float | None = None,
|
|
111
111
|
) -> _Matrix:
|
|
@@ -115,10 +115,17 @@ def new_transformation_matrix(
|
|
|
115
115
|
svg-style transformation matrix.
|
|
116
116
|
"""
|
|
117
117
|
transformation = transformation or (1, 0, 0, 1, 0, 0)
|
|
118
|
-
|
|
118
|
+
|
|
119
|
+
if isinstance(scale, float):
|
|
120
|
+
scale_x, scale_y = (scale, scale)
|
|
121
|
+
elif scale is None:
|
|
122
|
+
scale_x, scale_y = (1, 1)
|
|
123
|
+
else:
|
|
124
|
+
scale_x, scale_y = cast("tuple[float, float]", scale)
|
|
125
|
+
|
|
119
126
|
dx = dx or 0
|
|
120
127
|
dy = dy or 0
|
|
121
|
-
return mat_dot((
|
|
128
|
+
return mat_dot((scale_x, 0, 0, scale_y, dx, dy), transformation)
|
|
122
129
|
|
|
123
130
|
|
|
124
131
|
def transform_element(elem: EtreeElement, matrix: _Matrix) -> EtreeElement:
|
|
@@ -10,20 +10,20 @@ svg_ultralight/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
|
10
10
|
svg_ultralight/query.py,sha256=wR8oixRYA489k03RU5apXaoami2KvYl8BKmwypQGTi0,10972
|
|
11
11
|
svg_ultralight/root_elements.py,sha256=E_H7HXk0M5F3IyFVOxO8PQmhww1-sHTzJhx8hBJPZvg,2911
|
|
12
12
|
svg_ultralight/string_conversion.py,sha256=7gaUWEJptAVZawlvoAJ7JoP996nALoJrAByM3o219Tc,7462
|
|
13
|
-
svg_ultralight/transformations.py,sha256=
|
|
13
|
+
svg_ultralight/transformations.py,sha256=T3vSxcTWOwWnwu3OF610LHMbKScUIVWICUAvru5zLnU,4488
|
|
14
14
|
svg_ultralight/unit_conversion.py,sha256=g07nhzXdjPvGcJmkhLdFbeDLrSmbI8uFoVgPo7G62Bg,9258
|
|
15
15
|
svg_ultralight/bounding_boxes/__init__.py,sha256=qUEn3r4s-1QNHaguhWhhaNfdP4tl_B6YEqxtiTFuzhQ,78
|
|
16
16
|
svg_ultralight/bounding_boxes/bound_helpers.py,sha256=LFkVsdYFKYCnEL6vLvEa_5cfu8D44ZGYeEEb7_0MnC0,7146
|
|
17
|
-
svg_ultralight/bounding_boxes/supports_bounds.py,sha256=
|
|
18
|
-
svg_ultralight/bounding_boxes/type_bound_collection.py,sha256=
|
|
19
|
-
svg_ultralight/bounding_boxes/type_bound_element.py,sha256=
|
|
20
|
-
svg_ultralight/bounding_boxes/type_bounding_box.py,sha256=
|
|
21
|
-
svg_ultralight/bounding_boxes/type_padded_text.py,sha256=
|
|
17
|
+
svg_ultralight/bounding_boxes/supports_bounds.py,sha256=T7LGse58fDBgmlzupSC63C1ZMXjFbyzBTsTUaqD_4Sw,4513
|
|
18
|
+
svg_ultralight/bounding_boxes/type_bound_collection.py,sha256=NAEpqo9H9ewhuLcOmBnMWUE0zQ1t4bvckovgvWy6hIo,2645
|
|
19
|
+
svg_ultralight/bounding_boxes/type_bound_element.py,sha256=Sc-R0uXkb0aS8-OcyM5pDukKhFUka0G6KCp6LcYDcIU,2204
|
|
20
|
+
svg_ultralight/bounding_boxes/type_bounding_box.py,sha256=UjyNmY6hVxKSpivjvGYwVny3Ncgq1p5E7CHhuULHELs,13184
|
|
21
|
+
svg_ultralight/bounding_boxes/type_padded_text.py,sha256=ZiigkcNipmouSXCnhfPFOYo-LW60BXchpWhhakKhHsA,11767
|
|
22
22
|
svg_ultralight/constructors/__init__.py,sha256=XLOInLhzMERWNnFAs-itMs-OZrBOpvQthZJ2T5duqBE,327
|
|
23
23
|
svg_ultralight/constructors/new_element.py,sha256=hRUW2hR_BTkthEqPClYV7-IeFe9iv2zwb6ehp1k1xDk,3475
|
|
24
24
|
svg_ultralight/strings/__init__.py,sha256=BMGhF1pulscIgkiYvZLr6kPRR0L4lW0jUNFxkul4_EM,295
|
|
25
25
|
svg_ultralight/strings/svg_strings.py,sha256=FQNxNmMkR2M-gCFo_woQKXLgCHi3ncUlRMiaRR_a9nQ,1978
|
|
26
|
-
svg_ultralight-0.39.
|
|
27
|
-
svg_ultralight-0.39.
|
|
28
|
-
svg_ultralight-0.39.
|
|
29
|
-
svg_ultralight-0.39.
|
|
26
|
+
svg_ultralight-0.39.1.dist-info/METADATA,sha256=lEu_GbUQnmw9sCUqWWVG4QEfGJoq32ffh8lO3GjcBsg,8971
|
|
27
|
+
svg_ultralight-0.39.1.dist-info/WHEEL,sha256=zaaOINJESkSfm_4HQVc5ssNzHCPXhJm0kEUakpsEHaU,91
|
|
28
|
+
svg_ultralight-0.39.1.dist-info/top_level.txt,sha256=se-6yqM_0Yg5orJKvKWdjQZ4iR4G_EjhL7oRgju-fdY,15
|
|
29
|
+
svg_ultralight-0.39.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|