Added method to convert image map coordinates to SVG polygon coordinates
authorThierry Florac <tflorac@ulthar.net>
Fri, 18 Oct 2019 12:46:26 +0200
changeset 1373 a845b564608f
parent 1372 d99436198c5f
child 1374 0bf83e0553c4
Added method to convert image map coordinates to SVG polygon coordinates
src/pyams_content/shared/imagemap/__init__.py
--- a/src/pyams_content/shared/imagemap/__init__.py	Wed Oct 16 18:52:12 2019 +0200
+++ b/src/pyams_content/shared/imagemap/__init__.py	Fri Oct 18 12:46:26 2019 +0200
@@ -48,6 +48,13 @@
     link = FieldProperty(IImageMapArea['link'])
     area = FieldProperty(IImageMapArea['area'])
 
+    @property
+    def svg_points(self):
+        points = self.area.split(',')
+        x = points[::2]
+        y = points[1::2]
+        return ' '.join(','.join(xy) for xy in zip(x, y))
+
 
 @implementer(IWfImageMap, IExtFileContainerTarget, ILinkContainerTarget,
              IPreviewTarget, IReviewTarget)