In the application I’m using, I’m subtracting a closed Path from an open Path. But for some reason, the subract()
function is breaking the Path into two parts and in the result I see a Compound Path.
The path from which subtraction is done:
[
"Path",
{
"applyMatrix": true,
"segments": [
[41.47363, -24.54467],
[-19.17782, 46.31651],
[-97.3719, -21.43777],
[-36, -90],
[-45.06335, -79.27252],
[-29.81168, -66.3868],
[-29.69724, -66.52225],
[-26.21473, -64.17428],
[-20.74832, -63.07066],
[-15.28191, -64.17428],
[-10.81799, -67.18394],
[-10.15629, -68.16537]
],
"strokeScaling": false
}
]
The path that is subtracted:
[
"Path",
{
"applyMatrix": true,
"segments": [
[-29.81168, -66.3868],
[32.41027, -13.81719],
[41.47363, -24.54467],
[-20.74832, -77.11428]
],
"closed": true,
"strokeScaling": false
}
]
This is the result I’m getting:
[
"CompoundPath",
{
"applyMatrix": true,
"children": [
[
"Path",
{
"applyMatrix": true,
"segments": [
[-19.17782, 46.31651],
[-97.3719, -21.43777],
[-36, -90],
[-45.06335, -79.27252],
[32.3415, -13.8753]
],
"closed": true
}
],
[
"Path",
{
"applyMatrix": true,
"segments": [
[-29.69724, -66.52225]
],
"closed": true
}
]
],
"strokeScaling": false
}
]
You can see it pictorially here: https://www.desmos.com/calculator/xmi7ifhpul
You can see that the one point remains even after deletion even though it was inside the polygon to be subtracted. I couldn’t figure out why this is happening.