Unexpected behavior from inkex.paths.Path.reverse and disjoint paths
Summary:
Invoking inkex
's reverse
method on a path object containing multiple disjoint segments may combine the segments.
Steps to reproduce:
- Open the attached
disjoint.svg
file in Inkscape. - From an extension, execute the following code:
for node in self.svg.xpath('//svg:path'):
node.path = node.path.reverse()
Alternatively, if you use my Simple Inkscape Scripting extension, run the script
for node in svg_root.xpath('//svg:path'):
node.path = node.path.reverse()
from the dialog box.
What happened?
The path, which was originally M 128,64 L 128,128 M 128,196 L 128,256
, became M 128 256 L 128 196 M 128 196 L 128 64
. This is rendered as a single segment instead of two segments with an intervening gap. (Note the L 128 196
followed by a M 128 196
.)
What should have happened?
It should have become M 128,256 L 128,196 M 128,128 L 128,64
(or even M 128,256 V 196 M 128,128 V 64
), as is done by the Inkscape GUI when executing Path → Reverse.
Sample attachments:
Version info
Inkscape 1.2-alpha (f3d6d80, 2022-02-09)
GLib version: 2.64.6
GTK version: 3.24.20
glibmm version: 2.64.2
gtkmm version: 3.24.2
libxml2 version: 2.9.10
libxslt version: 1.1.34
Cairo version: 1.17.4
Pango version: 1.44.7
HarfBuzz version: 2.6.4
OS version: Ubuntu 21.10