svg-ultralight 0.45.3__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.

@@ -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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: svg-ultralight
3
- Version: 0.45.3
3
+ Version: 0.45.4
4
4
  Summary: a sensible way to create svg files with Python
5
5
  Author-email: Shay Hill <shay_public@hotmail.com>
6
6
  License: MIT
@@ -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=WNIoqC9pfB8g_00P6RHcBdNE6VniqlLJXw_bh-GNjFA,13098
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.3.dist-info/METADATA,sha256=GT8dx7FHssg5EoGcNXRwHOezY4SJILTn6NQgv-MhWX0,9052
33
- svg_ultralight-0.45.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
34
- svg_ultralight-0.45.3.dist-info/top_level.txt,sha256=se-6yqM_0Yg5orJKvKWdjQZ4iR4G_EjhL7oRgju-fdY,15
35
- svg_ultralight-0.45.3.dist-info/RECORD,,
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,,