diff options
| author | Viatrix | 2026-03-11 13:59:20 -0700 |
|---|---|---|
| committer | Viatrix | 2026-03-11 13:59:20 -0700 |
| commit | e8b45cae1841c4ed30013cd3cb85257fce027e7f (patch) | |
| tree | bb454f1640cfbcbc823757ecde8bce29e9d8fd70 /imagemap.py | |
| parent | 8cea9e2a48fa7965614997ebee832bb39e7154ca (diff) | |
Enclave test case added
Updated other test cases that changed order due to enclave handling code
Diffstat (limited to 'imagemap.py')
| -rw-r--r-- | imagemap.py | 10 |
1 files changed, 5 insertions, 5 deletions
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<len(coords): if coords[i]==coords[(i+1)%len(coords)]: coords.pop(i) else: i+=1 - if rectifiable(coords): shapes.append(shapemarkup('rect',rectify(coords),href,alt)) - elif len(coords)>=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() |
