svg-ultralight 0.29.0__py3-none-any.whl → 0.30.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.

@@ -10,7 +10,11 @@ from svg_ultralight.bounding_boxes.bound_helpers import (
10
10
  new_element_union,
11
11
  )
12
12
  from svg_ultralight.bounding_boxes.supports_bounds import SupportsBounds
13
+ <<<<<<< HEAD
13
14
  from svg_ultralight.bounding_boxes.type_bound_confederation import BoundConfederation
15
+ =======
16
+ from svg_ultralight.bounding_boxes.type_bound_collection import BoundCollection
17
+ >>>>>>> dev
14
18
  from svg_ultralight.bounding_boxes.type_bound_element import BoundElement
15
19
  from svg_ultralight.bounding_boxes.type_bounding_box import BoundingBox
16
20
  from svg_ultralight.bounding_boxes.type_padded_text import PaddedText
@@ -41,7 +45,11 @@ from svg_ultralight.string_conversion import (
41
45
  from svg_ultralight.transformations import transform_element
42
46
 
43
47
  __all__ = [
48
+ <<<<<<< HEAD
44
49
  "BoundConfederation",
50
+ =======
51
+ "BoundCollection",
52
+ >>>>>>> dev
45
53
  "BoundElement",
46
54
  "BoundingBox",
47
55
  "NSMAP",
@@ -0,0 +1,71 @@
1
+ """A class to hold a list of bound elements and transform them together.
2
+
3
+ :author: Shay Hill
4
+ :created: 2024-05-05
5
+ """
6
+
7
+ from __future__ import annotations
8
+
9
+ import dataclasses
10
+ from typing import TYPE_CHECKING
11
+
12
+ from lxml.etree import _Element as EtreeElement # type: ignore
13
+
14
+ from svg_ultralight.bounding_boxes.bound_helpers import new_bbox_union
15
+ from svg_ultralight.bounding_boxes.type_bounding_box import HasBoundingBox
16
+ from svg_ultralight.transformations import new_transformation_matrix, transform_element
17
+
18
+ if TYPE_CHECKING:
19
+ from svg_ultralight.bounding_boxes.supports_bounds import SupportsBounds
20
+ from svg_ultralight.bounding_boxes.type_bounding_box import BoundingBox
21
+
22
+ _Matrix = tuple[float, float, float, float, float, float]
23
+
24
+
25
+ @dataclasses.dataclass
26
+ class BoundCollection(HasBoundingBox):
27
+ """A class to hold a list of bound elements and transform them together.
28
+
29
+ This will transform the individual elements in place.
30
+ """
31
+
32
+ blems: list[SupportsBounds | EtreeElement] = dataclasses.field(init=False)
33
+ bbox: BoundingBox = dataclasses.field(init=False)
34
+
35
+ def __init__(self, *blems: SupportsBounds | EtreeElement) -> None:
36
+ """Initialize the bound collection.
37
+
38
+ :param blems: bound elements to be transformed together
39
+ """
40
+ self.blems = list(blems)
41
+ self.bbox = new_bbox_union(*self.blems)
42
+
43
+ def transform(
44
+ self,
45
+ transformation: _Matrix | None = None,
46
+ *,
47
+ scale: float | None = None,
48
+ dx: float | None = None,
49
+ dy: float | None = None,
50
+ ):
51
+ """Transform each bound element in self.blems.
52
+
53
+ :param transformation: 2D transformation matrix
54
+ :param scale: optional scale factor
55
+ :param dx: optional x translation
56
+ :param dy: optional y translation
57
+
58
+ Keep track of all compounding transformations in order to have a value for
59
+ self.scale (required for membersh and to provide access to cumulative
60
+ transforms should this be useful for any reason. This means all
61
+ transformations must be applied to two bounding boxes: a persistant bbox to
62
+ keep track of the scale property and a temporary bbox to isolate each
63
+ transformation.
64
+ """
65
+ tmat = new_transformation_matrix(transformation, scale=scale, dx=dx, dy=dy)
66
+ self.bbox.transform(tmat)
67
+ for blem in self.blems:
68
+ if isinstance(blem, EtreeElement):
69
+ _ = transform_element(blem, tmat)
70
+ else:
71
+ blem.transform(tmat)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: svg-ultralight
3
- Version: 0.29.0
3
+ Version: 0.30.0
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
@@ -1,4 +1,4 @@
1
- svg_ultralight/__init__.py,sha256=b0cB7zUGr7o3XaKatJeVyHpJLfF26aXsSYZJlVnvBFQ,2079
1
+ svg_ultralight/__init__.py,sha256=KkTwZoRU2fOtStK38grA5Tjug5bJpUw78FZ9TLN-170,2256
2
2
  svg_ultralight/animate.py,sha256=fE-zRU_uFrZIL9W78fcGz7qmrts8fz5UoWEy7b4xb44,1144
3
3
  svg_ultralight/inkscape.py,sha256=M8yTxXOu4NlXnhsMycvEJiIDpnDeiZ_bZakJBM38ZoU,9152
4
4
  svg_ultralight/layout.py,sha256=TTETT_8WLBXnQxDGXdAeczCFN5pFo5kKY3Q6zv4FPX4,12238
@@ -14,6 +14,7 @@ svg_ultralight/unit_conversion.py,sha256=g07nhzXdjPvGcJmkhLdFbeDLrSmbI8uFoVgPo7G
14
14
  svg_ultralight/bounding_boxes/__init__.py,sha256=qUEn3r4s-1QNHaguhWhhaNfdP4tl_B6YEqxtiTFuzhQ,78
15
15
  svg_ultralight/bounding_boxes/bound_helpers.py,sha256=YMClhdekeYbzD_ijXDAer-H3moWKN3lUNnZs1UNFFKc,3458
16
16
  svg_ultralight/bounding_boxes/supports_bounds.py,sha256=fbHV6mGdeIVV3lS15vBKSrHiHKR7DMg4K5X__4LLmCE,4569
17
+ svg_ultralight/bounding_boxes/type_bound_collection.py,sha256=b89TM2UsdaeApyjTQeMbx_FG_WcCiLAImEiHiZ6EWPI,2600
17
18
  svg_ultralight/bounding_boxes/type_bound_confederation.py,sha256=PAUa8LSfyw0v2eq8EU2B_V5dlsl7ddrrPIsD-5fWU8U,2602
18
19
  svg_ultralight/bounding_boxes/type_bound_element.py,sha256=9RdxH8osOlAvPdWR0Ww9NsasHLPYFDs-MbydoV48x4E,2239
19
20
  svg_ultralight/bounding_boxes/type_bounding_box.py,sha256=cDrMp6uwaA--KJIQS2puG10qh8n3TBmiscg-cfk1f3w,16149
@@ -22,7 +23,7 @@ svg_ultralight/constructors/__init__.py,sha256=YcnO0iBQc19aL8Iemw0Y452MBMBIT2AN5
22
23
  svg_ultralight/constructors/new_element.py,sha256=VtMz9sPn9rMk6rui5Poysy3vezlOaS-tGIcGbu-SXmY,3406
23
24
  svg_ultralight/strings/__init__.py,sha256=Zalrf-ThFz7b7xKELx5lb2gOlBgV-6jk_k_EeSdVCVk,295
24
25
  svg_ultralight/strings/svg_strings.py,sha256=RYKMxOHq9abbZyGcFqsElBGLrBX-EjjNxln3s_ibi30,1296
25
- svg_ultralight-0.29.0.dist-info/METADATA,sha256=hLjRc-xXrwqasclTCthb-BuYGgjPRxMtXwQ-zSAh7qY,8871
26
- svg_ultralight-0.29.0.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
27
- svg_ultralight-0.29.0.dist-info/top_level.txt,sha256=se-6yqM_0Yg5orJKvKWdjQZ4iR4G_EjhL7oRgju-fdY,15
28
- svg_ultralight-0.29.0.dist-info/RECORD,,
26
+ svg_ultralight-0.30.0.dist-info/METADATA,sha256=vAGCbcN3nh37O6b5qU8tJbMfogcORk0u5-77R_2H8HM,8871
27
+ svg_ultralight-0.30.0.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
28
+ svg_ultralight-0.30.0.dist-info/top_level.txt,sha256=se-6yqM_0Yg5orJKvKWdjQZ4iR4G_EjhL7oRgju-fdY,15
29
+ svg_ultralight-0.30.0.dist-info/RECORD,,