• Parameters

    • file: string | SVGElement

      the SVG element as a document element node, or as a string

    • options: any

      an options object or an epsilon number

    Returns FOLD

    a FOLD representation of the SVG

    Description

    Convert an SVG to a FOLD object. This only works with SVGs of crease patterns, this will not work with an SVG of a folded form.

    Example

    const svgFile = fs.readFileSync("./crane.svg", "utf-8");
    const fold = svgToFold(svgFile);
    fs.writeFileSync("./crane.fold", JSON.stringify(fold, null, 2));

    Example

    // with options
    const svgFile = fs.readFileSync("./crane.svg", "utf-8");
    const fold = svgToFold(svgFile, { boundary: false, epsilon: 0.1, invertVertical: true });
    fs.writeFileSync("./crane.fold", JSON.stringify(fold, null, 2));