aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorViatrix2026-03-12 14:46:44 -0700
committerViatrix2026-03-12 14:46:44 -0700
commite475a7d88c9cc4128852a431dfe1977e426e4efc (patch)
tree4f9dc4aec034a8f38489d942b53bbccfe38d9b28
parent318a84508163ad786f12ee72d01b1b15d3295f73 (diff)
Objects with both fill and stroke now work
-rw-r--r--imagemap.py2
-rw-r--r--tests/data/refs/imagemap__--maptype__HTML__fillstroke__svg.out1
-rw-r--r--tests/data/svg/fillstroke.svg6
-rw-r--r--tests/test_imagemap_comparison.py1
4 files changed, 9 insertions, 1 deletions
diff --git a/imagemap.py b/imagemap.py
index 89452be..3d25403 100644
--- a/imagemap.py
+++ b/imagemap.py
@@ -70,7 +70,7 @@ class ImageMap(inkex.OutputExtension):
if len(links)==0:
raise inkex.AbortExtension(_("Image has no hyperlinks.\nAdd a hyperlink to an object with right-click → \"{}\".").format(_("Create Anchor (Hyperlink)")))
command=\
- ';'.join(f'select-clear;select-by-selector:[style~="{CSS_LINK_INDEX}-{i}"];object-stroke-to-path;path-union;object-set-attribute:style,{CSS_LINK_INDEX}:" {CSS_LINK_INDEX}-{i} "' for i in range(len(links))) \
+ ';'.join(f'select-clear;select-by-selector:[style~="{CSS_LINK_INDEX}-{i}"];object-stroke-to-path;selection-ungroup;path-union;object-set-attribute:style,{CSS_LINK_INDEX}:" {CSS_LINK_INDEX}-{i} "' for i in range(len(links))) \
+';select-all;path-flatten;path-split'
# (we re-set the existing style attribute in case it got unset on non-paths)
newbytes=inkscape_command(self.svg,actions=command)
diff --git a/tests/data/refs/imagemap__--maptype__HTML__fillstroke__svg.out b/tests/data/refs/imagemap__--maptype__HTML__fillstroke__svg.out
new file mode 100644
index 0000000..60683ce
--- /dev/null
+++ b/tests/data/refs/imagemap__--maptype__HTML__fillstroke__svg.out
@@ -0,0 +1 @@
+<area shape=poly coords=25,20,24,20,22,21,21,22,20,24,20,75,20,76,21,78,22,79,24,80,75,80,76,80,78,79,79,78,80,76,80,25,80,24,79,22,78,21,76,20 href=http://example.com>
diff --git a/tests/data/svg/fillstroke.svg b/tests/data/svg/fillstroke.svg
new file mode 100644
index 0000000..70911c3
--- /dev/null
+++ b/tests/data/svg/fillstroke.svg
@@ -0,0 +1,6 @@
+<svg width="100" height="100" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
+ <!-- Transparent areas of the image should remain part of the link. -->
+ <a xlink:href="http://example.com">
+ <rect x="25" y="25" width="50" height="50" fill="red" stroke="blue" stroke-width="10" stroke-linejoin="round"/>
+ </a>
+</svg>
diff --git a/tests/test_imagemap_comparison.py b/tests/test_imagemap_comparison.py
index a703b5e..445f981 100644
--- a/tests/test_imagemap_comparison.py
+++ b/tests/test_imagemap_comparison.py
@@ -5,6 +5,7 @@ class ImageMapComparisonTest(ComparisonMixin, TestCase):
effect_class = ImageMap
compare_file = (
'svg/enclave.svg',
+ 'svg/fillstroke.svg',
'svg/image.svg',
'svg/intersect.svg',
'svg/overlap.svg',