From e8b45cae1841c4ed30013cd3cb85257fce027e7f Mon Sep 17 00:00:00 2001 From: Viatrix Date: Wed, 11 Mar 2026 13:59:20 -0700 Subject: Enclave test case added Updated other test cases that changed order due to enclave handling code --- imagemap.py | 10 +++++----- tests/data/refs/imagemap__--maptype__HTML__enclave__svg.out | 6 ++++++ tests/data/refs/imagemap__--maptype__HTML__intersect__svg.out | 2 +- tests/data/refs/imagemap__--maptype__HTML__overlap__svg.out | 2 +- tests/data/svg/enclave.svg | 8 ++++++++ tests/test_imagemap_comparison.py | 1 + 6 files changed, 22 insertions(+), 7 deletions(-) create mode 100644 tests/data/refs/imagemap__--maptype__HTML__enclave__svg.out create mode 100644 tests/data/svg/enclave.svg diff --git a/imagemap.py b/imagemap.py index 9a88a42..e595f08 100644 --- a/imagemap.py +++ b/imagemap.py @@ -72,6 +72,7 @@ class ImageMap(inkex.OutputExtension): self.svg=self.load(newbytes).getroot() seen=set() + shapes=[[] for i in range(len(links))] for el in self.svg.iterdescendants(): if not isinstance(el,inkex.ShapeElement): continue linkindex=el.cascaded_style().get(CSS_LINK_INDEX) @@ -80,7 +81,6 @@ class ImageMap(inkex.OutputExtension): link=links[linkindex] href=link['href'] alt=link['alt'] if int(linkindex) not in seen else None - shapes=[] path=el.get_path().transform(el.composed_transform()).to_superpath() bezier.cspsubdiv(path,0.5) for subpath in path: @@ -89,12 +89,12 @@ class ImageMap(inkex.OutputExtension): while i=3: shapes.append(shapemarkup('poly',coords,href,alt)) + if rectifiable(coords): shapes[linkindex].insert(0,shapemarkup('rect',rectify(coords),href,alt)) + elif len(coords)>=3: shapes[linkindex].insert(0,shapemarkup('poly',coords,href,alt)) href=None # because subsequent subpaths must be enclaves - alt=None + alt=None # TODO make it come first even though the order's reversed seen.add(linkindex) - stream.write(bytes(''.join(reversed(shapes)),'utf-8')) + stream.write(bytes(''.join(sum(shapes,start=[])),'utf-8')) if __name__ == "__main__": ImageMap().run() diff --git a/tests/data/refs/imagemap__--maptype__HTML__enclave__svg.out b/tests/data/refs/imagemap__--maptype__HTML__enclave__svg.out new file mode 100644 index 0000000..611ef39 --- /dev/null +++ b/tests/data/refs/imagemap__--maptype__HTML__enclave__svg.out @@ -0,0 +1,6 @@ + + + + + + diff --git a/tests/data/refs/imagemap__--maptype__HTML__intersect__svg.out b/tests/data/refs/imagemap__--maptype__HTML__intersect__svg.out index cab9492..5af12ea 100644 --- a/tests/data/refs/imagemap__--maptype__HTML__intersect__svg.out +++ b/tests/data/refs/imagemap__--maptype__HTML__intersect__svg.out @@ -1,2 +1,2 @@ - + diff --git a/tests/data/refs/imagemap__--maptype__HTML__overlap__svg.out b/tests/data/refs/imagemap__--maptype__HTML__overlap__svg.out index 8f8d95d..de38166 100644 --- a/tests/data/refs/imagemap__--maptype__HTML__overlap__svg.out +++ b/tests/data/refs/imagemap__--maptype__HTML__overlap__svg.out @@ -1,4 +1,4 @@ - + diff --git a/tests/data/svg/enclave.svg b/tests/data/svg/enclave.svg new file mode 100644 index 0000000..db8d777 --- /dev/null +++ b/tests/data/svg/enclave.svg @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/tests/test_imagemap_comparison.py b/tests/test_imagemap_comparison.py index 087a3d8..959e98e 100644 --- a/tests/test_imagemap_comparison.py +++ b/tests/test_imagemap_comparison.py @@ -4,6 +4,7 @@ from imagemap import ImageMap class ImageMapComparisonTest(ComparisonMixin, TestCase): effect_class = ImageMap compare_file = ( + 'svg/enclave.svg', 'svg/intersect.svg', 'svg/overlap.svg', 'svg/rect.svg', -- cgit