svg-ultralight 0.29.0__tar.gz → 0.30.0__tar.gz

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.

Files changed (48) hide show
  1. {svg_ultralight-0.29.0/src/svg_ultralight.egg-info → svg_ultralight-0.30.0}/PKG-INFO +1 -1
  2. {svg_ultralight-0.29.0 → svg_ultralight-0.30.0}/pyproject.toml +2 -2
  3. {svg_ultralight-0.29.0 → svg_ultralight-0.30.0}/src/svg_ultralight/__init__.py +8 -0
  4. svg_ultralight-0.30.0/src/svg_ultralight/bounding_boxes/type_bound_collection.py +71 -0
  5. {svg_ultralight-0.29.0 → svg_ultralight-0.30.0/src/svg_ultralight.egg-info}/PKG-INFO +1 -1
  6. {svg_ultralight-0.29.0 → svg_ultralight-0.30.0}/src/svg_ultralight.egg-info/SOURCES.txt +1 -0
  7. {svg_ultralight-0.29.0 → svg_ultralight-0.30.0}/tests/test_bounding.py +23 -0
  8. {svg_ultralight-0.29.0 → svg_ultralight-0.30.0}/.gitignore +0 -0
  9. {svg_ultralight-0.29.0 → svg_ultralight-0.30.0}/.pre-commit-config.yaml +0 -0
  10. {svg_ultralight-0.29.0 → svg_ultralight-0.30.0}/README.md +0 -0
  11. {svg_ultralight-0.29.0 → svg_ultralight-0.30.0}/setup.cfg +0 -0
  12. {svg_ultralight-0.29.0 → svg_ultralight-0.30.0}/src/svg_ultralight/animate.py +0 -0
  13. {svg_ultralight-0.29.0 → svg_ultralight-0.30.0}/src/svg_ultralight/bounding_boxes/__init__.py +0 -0
  14. {svg_ultralight-0.29.0 → svg_ultralight-0.30.0}/src/svg_ultralight/bounding_boxes/bound_helpers.py +0 -0
  15. {svg_ultralight-0.29.0 → svg_ultralight-0.30.0}/src/svg_ultralight/bounding_boxes/supports_bounds.py +0 -0
  16. {svg_ultralight-0.29.0 → svg_ultralight-0.30.0}/src/svg_ultralight/bounding_boxes/type_bound_confederation.py +0 -0
  17. {svg_ultralight-0.29.0 → svg_ultralight-0.30.0}/src/svg_ultralight/bounding_boxes/type_bound_element.py +0 -0
  18. {svg_ultralight-0.29.0 → svg_ultralight-0.30.0}/src/svg_ultralight/bounding_boxes/type_bounding_box.py +0 -0
  19. {svg_ultralight-0.29.0 → svg_ultralight-0.30.0}/src/svg_ultralight/bounding_boxes/type_padded_text.py +0 -0
  20. {svg_ultralight-0.29.0 → svg_ultralight-0.30.0}/src/svg_ultralight/constructors/__init__.py +0 -0
  21. {svg_ultralight-0.29.0 → svg_ultralight-0.30.0}/src/svg_ultralight/constructors/new_element.py +0 -0
  22. {svg_ultralight-0.29.0 → svg_ultralight-0.30.0}/src/svg_ultralight/inkscape.py +0 -0
  23. {svg_ultralight-0.29.0 → svg_ultralight-0.30.0}/src/svg_ultralight/layout.py +0 -0
  24. {svg_ultralight-0.29.0 → svg_ultralight-0.30.0}/src/svg_ultralight/main.py +0 -0
  25. {svg_ultralight-0.29.0 → svg_ultralight-0.30.0}/src/svg_ultralight/metadata.py +0 -0
  26. {svg_ultralight-0.29.0 → svg_ultralight-0.30.0}/src/svg_ultralight/nsmap.py +0 -0
  27. {svg_ultralight-0.29.0 → svg_ultralight-0.30.0}/src/svg_ultralight/py.typed +0 -0
  28. {svg_ultralight-0.29.0 → svg_ultralight-0.30.0}/src/svg_ultralight/query.py +0 -0
  29. {svg_ultralight-0.29.0 → svg_ultralight-0.30.0}/src/svg_ultralight/root_elements.py +0 -0
  30. {svg_ultralight-0.29.0 → svg_ultralight-0.30.0}/src/svg_ultralight/string_conversion.py +0 -0
  31. {svg_ultralight-0.29.0 → svg_ultralight-0.30.0}/src/svg_ultralight/strings/__init__.py +0 -0
  32. {svg_ultralight-0.29.0 → svg_ultralight-0.30.0}/src/svg_ultralight/strings/svg_strings.py +0 -0
  33. {svg_ultralight-0.29.0 → svg_ultralight-0.30.0}/src/svg_ultralight/transformations.py +0 -0
  34. {svg_ultralight-0.29.0 → svg_ultralight-0.30.0}/src/svg_ultralight/unit_conversion.py +0 -0
  35. {svg_ultralight-0.29.0 → svg_ultralight-0.30.0}/src/svg_ultralight.egg-info/dependency_links.txt +0 -0
  36. {svg_ultralight-0.29.0 → svg_ultralight-0.30.0}/src/svg_ultralight.egg-info/requires.txt +0 -0
  37. {svg_ultralight-0.29.0 → svg_ultralight-0.30.0}/src/svg_ultralight.egg-info/top_level.txt +0 -0
  38. {svg_ultralight-0.29.0 → svg_ultralight-0.30.0}/tests/__init__.py +0 -0
  39. {svg_ultralight-0.29.0 → svg_ultralight-0.30.0}/tests/conftest.py +0 -0
  40. {svg_ultralight-0.29.0 → svg_ultralight-0.30.0}/tests/test_inkscape.py +0 -0
  41. {svg_ultralight-0.29.0 → svg_ultralight-0.30.0}/tests/test_layout.py +0 -0
  42. {svg_ultralight-0.29.0 → svg_ultralight-0.30.0}/tests/test_metadata.py +0 -0
  43. {svg_ultralight-0.29.0 → svg_ultralight-0.30.0}/tests/test_new_element.py +0 -0
  44. {svg_ultralight-0.29.0 → svg_ultralight-0.30.0}/tests/test_queries.py +0 -0
  45. {svg_ultralight-0.29.0 → svg_ultralight-0.30.0}/tests/test_root_elements.py +0 -0
  46. {svg_ultralight-0.29.0 → svg_ultralight-0.30.0}/tests/test_string_conversion.py +0 -0
  47. {svg_ultralight-0.29.0 → svg_ultralight-0.30.0}/tests/test_svg_ultralight.py +0 -0
  48. {svg_ultralight-0.29.0 → svg_ultralight-0.30.0}/tox.ini +0 -0
@@ -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,6 +1,6 @@
1
1
  [project]
2
2
  name = "svg-ultralight"
3
- version = "0.29.0"
3
+ version = "0.30.0"
4
4
  description = "a sensible way to create svg files with Python"
5
5
  authors = [{ name = "Shay Hill", email = "shay_public@hotmail.com" }]
6
6
  license = { text = "MIT" }
@@ -37,7 +37,7 @@ legacy_tox_ini = """
37
37
 
38
38
  [tool.commitizen]
39
39
  name = "cz_conventional_commits"
40
- version = "0.29.0"
40
+ version = "0.30.0"
41
41
  tag_format = "$version"
42
42
  version_files = ["pyproject.toml:^version"]
43
43
  annotated_tag = true
@@ -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
@@ -24,6 +24,7 @@ src/svg_ultralight.egg-info/top_level.txt
24
24
  src/svg_ultralight/bounding_boxes/__init__.py
25
25
  src/svg_ultralight/bounding_boxes/bound_helpers.py
26
26
  src/svg_ultralight/bounding_boxes/supports_bounds.py
27
+ src/svg_ultralight/bounding_boxes/type_bound_collection.py
27
28
  src/svg_ultralight/bounding_boxes/type_bound_confederation.py
28
29
  src/svg_ultralight/bounding_boxes/type_bound_element.py
29
30
  src/svg_ultralight/bounding_boxes/type_bounding_box.py
@@ -9,7 +9,11 @@ import math
9
9
  from svg_ultralight.bounding_boxes.type_bound_element import BoundElement
10
10
  from svg_ultralight.bounding_boxes.type_padded_text import PaddedText
11
11
  from svg_ultralight.bounding_boxes.type_bounding_box import BoundingBox
12
+ <<<<<<< HEAD
12
13
  from svg_ultralight.bounding_boxes.type_bound_confederation import BoundConfederation
14
+ =======
15
+ from svg_ultralight.bounding_boxes.type_bound_collection import BoundCollection
16
+ >>>>>>> dev
13
17
  import copy
14
18
  from svg_ultralight.constructors import new_element
15
19
 
@@ -155,6 +159,7 @@ class TestPaddedText:
155
159
  assert math.isclose(bound_element.height, 252.76)
156
160
  assert bound_element.y2 == 203.0
157
161
 
162
+ <<<<<<< HEAD
158
163
  class TestBoundConfederation:
159
164
 
160
165
  @pytest.fixture
@@ -163,6 +168,16 @@ class TestBoundConfederation:
163
168
  bbox = BoundingBox(0, 0, 100, 200)
164
169
  blem = PaddedText(elem, bbox, 1, 2, 3, 4)
165
170
  return BoundConfederation(blem, copy.deepcopy(elem))
171
+ =======
172
+ class TestBoundCollection:
173
+
174
+ @pytest.fixture
175
+ def bound_collection(self) -> BoundCollection:
176
+ elem = new_element("rect", x=0, y=0, width=100, height=200)
177
+ bbox = BoundingBox(0, 0, 100, 200)
178
+ blem = PaddedText(elem, bbox, 1, 2, 3, 4)
179
+ return BoundCollection(blem, copy.deepcopy(elem))
180
+ >>>>>>> dev
166
181
 
167
182
  def test_blem_and_elem(self):
168
183
  """Test that bound element and unbound element transforms are the same."""
@@ -170,11 +185,19 @@ class TestBoundConfederation:
170
185
  bbox = BoundingBox(0, 0, 100, 200)
171
186
  blem = BoundElement(rect, bbox)
172
187
  elem = copy.deepcopy(rect)
188
+ <<<<<<< HEAD
173
189
  bound_confederation = BoundConfederation(blem, elem)
174
190
  bound_confederation.x = -4
175
191
  bound_confederation.scale = 10
176
192
  bound_confederation.width = 60
177
193
  bound_confederation.cy = -40
194
+ =======
195
+ bound_collection = BoundCollection(blem, elem)
196
+ bound_collection.x = -4
197
+ bound_collection.scale = 10
198
+ bound_collection.width = 60
199
+ bound_collection.cy = -40
200
+ >>>>>>> dev
178
201
  blem_trans = blem.elem.attrib["transform"]
179
202
  elem_trans = elem.attrib["transform"]
180
203
  assert blem_trans == elem_trans
File without changes