OpenJSCAD.org icon indicating copy to clipboard operation
OpenJSCAD.org copied to clipboard

Malformed svg path at x:y. Path closed itself with command.

Open hrgdavor opened this issue 3 years ago • 0 comments

Expected Behavior

closed path from svg

Actual Behavior

error because last line ends at the begining

Steps to Reproduce the Problem

create simple script:

const { deserializers } = require("@jscad/io")
let svg = `<svg><g><path d="M0 0 L10 10L10 0L0 0" id="path4544" /></g></svg>`

const jscad = require('@jscad/modeling')
function main() {
    return deserializers.svg({ output: "geometry", segments: 128 }, svg)
}

module.exports = {main}
  1. run it on openjscad.xyz
  2. error is generated "Error: Malformed svg path at 2:50. Path closed itself with command # 3 L0 0"

This is what inkscape produces and is not unexpectd path in general. I was part of adding this error report for cases when svg path closes on itself somewhere in the middle, but failed to account for this valid case when start point and end point meet.

workaround is to replace last command L 0 0 with Z

let svg = `<svg><g><path d="M0 0 L10 10L10 0Z" id="path4544" /></g></svg>` 

Specifications

  • Version: 2.5.12
  • Platform: all
  • Environment: all

hrgdavor avatar Aug 08 '22 18:08 hrgdavor