svg-ultralight 0.30.1__tar.gz → 0.31.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.30.1/src/svg_ultralight.egg-info → svg_ultralight-0.31.0}/PKG-INFO +1 -1
  2. {svg_ultralight-0.30.1 → svg_ultralight-0.31.0}/pyproject.toml +2 -2
  3. {svg_ultralight-0.30.1 → svg_ultralight-0.31.0}/src/svg_ultralight/__init__.py +9 -1
  4. {svg_ultralight-0.30.1 → svg_ultralight-0.31.0}/src/svg_ultralight/transformations.py +14 -0
  5. {svg_ultralight-0.30.1 → svg_ultralight-0.31.0/src/svg_ultralight.egg-info}/PKG-INFO +1 -1
  6. {svg_ultralight-0.30.1 → svg_ultralight-0.31.0}/src/svg_ultralight.egg-info/SOURCES.txt +1 -0
  7. svg_ultralight-0.31.0/tests/test_matrices.py +34 -0
  8. {svg_ultralight-0.30.1 → svg_ultralight-0.31.0}/.gitignore +0 -0
  9. {svg_ultralight-0.30.1 → svg_ultralight-0.31.0}/.pre-commit-config.yaml +0 -0
  10. {svg_ultralight-0.30.1 → svg_ultralight-0.31.0}/README.md +0 -0
  11. {svg_ultralight-0.30.1 → svg_ultralight-0.31.0}/setup.cfg +0 -0
  12. {svg_ultralight-0.30.1 → svg_ultralight-0.31.0}/src/svg_ultralight/animate.py +0 -0
  13. {svg_ultralight-0.30.1 → svg_ultralight-0.31.0}/src/svg_ultralight/bounding_boxes/__init__.py +0 -0
  14. {svg_ultralight-0.30.1 → svg_ultralight-0.31.0}/src/svg_ultralight/bounding_boxes/bound_helpers.py +0 -0
  15. {svg_ultralight-0.30.1 → svg_ultralight-0.31.0}/src/svg_ultralight/bounding_boxes/supports_bounds.py +0 -0
  16. {svg_ultralight-0.30.1 → svg_ultralight-0.31.0}/src/svg_ultralight/bounding_boxes/type_bound_collection.py +0 -0
  17. {svg_ultralight-0.30.1 → svg_ultralight-0.31.0}/src/svg_ultralight/bounding_boxes/type_bound_element.py +0 -0
  18. {svg_ultralight-0.30.1 → svg_ultralight-0.31.0}/src/svg_ultralight/bounding_boxes/type_bounding_box.py +0 -0
  19. {svg_ultralight-0.30.1 → svg_ultralight-0.31.0}/src/svg_ultralight/bounding_boxes/type_padded_text.py +0 -0
  20. {svg_ultralight-0.30.1 → svg_ultralight-0.31.0}/src/svg_ultralight/constructors/__init__.py +0 -0
  21. {svg_ultralight-0.30.1 → svg_ultralight-0.31.0}/src/svg_ultralight/constructors/new_element.py +0 -0
  22. {svg_ultralight-0.30.1 → svg_ultralight-0.31.0}/src/svg_ultralight/inkscape.py +0 -0
  23. {svg_ultralight-0.30.1 → svg_ultralight-0.31.0}/src/svg_ultralight/layout.py +0 -0
  24. {svg_ultralight-0.30.1 → svg_ultralight-0.31.0}/src/svg_ultralight/main.py +0 -0
  25. {svg_ultralight-0.30.1 → svg_ultralight-0.31.0}/src/svg_ultralight/metadata.py +0 -0
  26. {svg_ultralight-0.30.1 → svg_ultralight-0.31.0}/src/svg_ultralight/nsmap.py +0 -0
  27. {svg_ultralight-0.30.1 → svg_ultralight-0.31.0}/src/svg_ultralight/py.typed +0 -0
  28. {svg_ultralight-0.30.1 → svg_ultralight-0.31.0}/src/svg_ultralight/query.py +0 -0
  29. {svg_ultralight-0.30.1 → svg_ultralight-0.31.0}/src/svg_ultralight/root_elements.py +0 -0
  30. {svg_ultralight-0.30.1 → svg_ultralight-0.31.0}/src/svg_ultralight/string_conversion.py +0 -0
  31. {svg_ultralight-0.30.1 → svg_ultralight-0.31.0}/src/svg_ultralight/strings/__init__.py +0 -0
  32. {svg_ultralight-0.30.1 → svg_ultralight-0.31.0}/src/svg_ultralight/strings/svg_strings.py +0 -0
  33. {svg_ultralight-0.30.1 → svg_ultralight-0.31.0}/src/svg_ultralight/unit_conversion.py +0 -0
  34. {svg_ultralight-0.30.1 → svg_ultralight-0.31.0}/src/svg_ultralight.egg-info/dependency_links.txt +0 -0
  35. {svg_ultralight-0.30.1 → svg_ultralight-0.31.0}/src/svg_ultralight.egg-info/requires.txt +0 -0
  36. {svg_ultralight-0.30.1 → svg_ultralight-0.31.0}/src/svg_ultralight.egg-info/top_level.txt +0 -0
  37. {svg_ultralight-0.30.1 → svg_ultralight-0.31.0}/tests/__init__.py +0 -0
  38. {svg_ultralight-0.30.1 → svg_ultralight-0.31.0}/tests/conftest.py +0 -0
  39. {svg_ultralight-0.30.1 → svg_ultralight-0.31.0}/tests/test_bounding.py +0 -0
  40. {svg_ultralight-0.30.1 → svg_ultralight-0.31.0}/tests/test_inkscape.py +0 -0
  41. {svg_ultralight-0.30.1 → svg_ultralight-0.31.0}/tests/test_layout.py +0 -0
  42. {svg_ultralight-0.30.1 → svg_ultralight-0.31.0}/tests/test_metadata.py +0 -0
  43. {svg_ultralight-0.30.1 → svg_ultralight-0.31.0}/tests/test_new_element.py +0 -0
  44. {svg_ultralight-0.30.1 → svg_ultralight-0.31.0}/tests/test_queries.py +0 -0
  45. {svg_ultralight-0.30.1 → svg_ultralight-0.31.0}/tests/test_root_elements.py +0 -0
  46. {svg_ultralight-0.30.1 → svg_ultralight-0.31.0}/tests/test_string_conversion.py +0 -0
  47. {svg_ultralight-0.30.1 → svg_ultralight-0.31.0}/tests/test_svg_ultralight.py +0 -0
  48. {svg_ultralight-0.30.1 → svg_ultralight-0.31.0}/tox.ini +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: svg-ultralight
3
- Version: 0.30.1
3
+ Version: 0.31.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.30.1"
3
+ version = "0.31.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.30.1"
40
+ version = "0.31.0"
41
41
  tag_format = "$version"
42
42
  version_files = ["pyproject.toml:^version"]
43
43
  annotated_tag = true
@@ -38,7 +38,12 @@ from svg_ultralight.string_conversion import (
38
38
  format_numbers,
39
39
  format_numbers_in_string,
40
40
  )
41
- from svg_ultralight.transformations import transform_element
41
+ from svg_ultralight.transformations import (
42
+ mat_apply,
43
+ mat_dot,
44
+ mat_invert,
45
+ transform_element,
46
+ )
42
47
 
43
48
  __all__ = [
44
49
  "BoundCollection",
@@ -52,6 +57,9 @@ __all__ = [
52
57
  "format_number",
53
58
  "format_numbers",
54
59
  "format_numbers_in_string",
60
+ "mat_apply",
61
+ "mat_dot",
62
+ "mat_invert",
55
63
  "new_bbox_union",
56
64
  "new_bound_union",
57
65
  "new_element",
@@ -59,6 +59,20 @@ def mat_apply(mat1: _Matrix, mat2: tuple[float, float]) -> tuple[float, float]:
59
59
  return mat1[0] * mat2[0] + mat1[4], mat1[3] * mat2[1] + mat1[5]
60
60
 
61
61
 
62
+ def mat_invert(tmat: _Matrix) -> _Matrix:
63
+ """Invert a 2D transformation matrix in svg format."""
64
+ a, b, c, d, e, f = tmat
65
+ det = a * d - b * c
66
+ return (
67
+ d / det,
68
+ -b / det,
69
+ -c / det,
70
+ a / det,
71
+ (c * f - d * e) / det,
72
+ (b * e - a * f) / det,
73
+ )
74
+
75
+
62
76
  def get_transform_matrix(elem: EtreeElement) -> _Matrix:
63
77
  """Get the transformation matrix from an svg element.
64
78
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: svg-ultralight
3
- Version: 0.30.1
3
+ Version: 0.31.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
@@ -37,6 +37,7 @@ tests/conftest.py
37
37
  tests/test_bounding.py
38
38
  tests/test_inkscape.py
39
39
  tests/test_layout.py
40
+ tests/test_matrices.py
40
41
  tests/test_metadata.py
41
42
  tests/test_new_element.py
42
43
  tests/test_queries.py
@@ -0,0 +1,34 @@
1
+ """Test transformations of matrices.
2
+
3
+ :author: Shay Hill
4
+ :created: 2024-05-05
5
+ """
6
+
7
+ from svg_ultralight.transformations import mat_dot, mat_apply, mat_invert
8
+ import random
9
+ import math
10
+
11
+
12
+ class TestMat:
13
+ def test_explicit(self):
14
+ expect = (31, 46, 12, 22, 10, 14)
15
+ assert mat_dot((1, 2, 3, 4, 5, 6), (7, 8, 9, 1, 2, 1)) == expect
16
+
17
+ def test_apply(self):
18
+ expect = (12, 38)
19
+ assert mat_apply((1, 2, 3, 4, 5, 6), (7, 8)) == expect
20
+
21
+ def test_invert(self):
22
+ identity = (1, 0, 0, 1, 0, 0)
23
+ for _ in range(10):
24
+ tmat = (
25
+ random.randint(-10, 10),
26
+ random.randint(-10, 10),
27
+ random.randint(-10, 10),
28
+ random.randint(-10, 10),
29
+ random.randint(-10, 10),
30
+ random.randint(-10, 10),
31
+ )
32
+ result = mat_dot(tmat, mat_invert(tmat))
33
+ for x, y in zip(result, identity):
34
+ assert math.isclose(x, y, abs_tol=0.0001)
File without changes